aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-10-05 08:45:12 -0700
committerAnton Tananaev <anton@traccar.org>2022-10-05 08:45:12 -0700
commit2e0cdf2cec9be08392be2ae8826e14bc757db186 (patch)
treebf113fba796c95f8f8e3dd322e11fabb4997179d /src/main/java/org/traccar
parent525fb440430343a73a8ed402677fa24c01262372 (diff)
downloadtrackermap-server-2e0cdf2cec9be08392be2ae8826e14bc757db186.tar.gz
trackermap-server-2e0cdf2cec9be08392be2ae8826e14bc757db186.tar.bz2
trackermap-server-2e0cdf2cec9be08392be2ae8826e14bc757db186.zip
Fix commands linked to group
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r--src/main/java/org/traccar/api/resource/CommandResource.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/api/resource/CommandResource.java b/src/main/java/org/traccar/api/resource/CommandResource.java
index 636b45023..92804e725 100644
--- a/src/main/java/org/traccar/api/resource/CommandResource.java
+++ b/src/main/java/org/traccar/api/resource/CommandResource.java
@@ -27,6 +27,7 @@ import org.traccar.model.Command;
import org.traccar.model.Device;
import org.traccar.model.Position;
import org.traccar.model.Typed;
+import org.traccar.model.User;
import org.traccar.model.UserRestrictions;
import org.traccar.storage.StorageException;
import org.traccar.storage.query.Columns;
@@ -82,7 +83,15 @@ public class CommandResource extends ExtendedObjectResource<Command> {
public Collection<Command> get(@QueryParam("deviceId") long deviceId) throws StorageException {
permissionsService.checkPermission(Device.class, getUserId(), deviceId);
BaseProtocol protocol = getDeviceProtocol(deviceId);
- return get(false, 0, 0, deviceId).stream().filter(command -> {
+
+ var commands = storage.getObjects(Command.class, new Request(
+ new Columns.All(),
+ Condition.merge(List.of(
+ new Condition.Permission(User.class, getUserId(), Command.class),
+ new Condition.Permission(Device.class, deviceId, baseClass)
+ ))));
+
+ return commands.stream().filter(command -> {
String type = command.getType();
if (protocol != null) {
return command.getTextChannel() && protocol.getSupportedTextCommands().contains(type)