aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)