diff options
author | Anton Tananaev <anton@traccar.org> | 2022-08-29 17:03:00 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-08-29 17:03:00 -0700 |
commit | 4b2102596354446c291540a8c38e7cb4b0dd1086 (patch) | |
tree | faa68f92ca6b937d7d52ddd2cb61407bdf81b1e1 | |
parent | 5b174c67e5433a1ceceddc159ee6db6e229d5ba6 (diff) | |
download | trackermap-server-4b2102596354446c291540a8c38e7cb4b0dd1086.tar.gz trackermap-server-4b2102596354446c291540a8c38e7cb4b0dd1086.tar.bz2 trackermap-server-4b2102596354446c291540a8c38e7cb4b0dd1086.zip |
Allow saved commands (fix #4932)
-rw-r--r-- | src/main/java/org/traccar/api/resource/CommandResource.java | 10 |
1 files changed, 9 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 60f1f8eb0..636b45023 100644 --- a/src/main/java/org/traccar/api/resource/CommandResource.java +++ b/src/main/java/org/traccar/api/resource/CommandResource.java @@ -97,7 +97,15 @@ public class CommandResource extends ExtendedObjectResource<Command> { @Path("send") public Response send(Command entity) throws Exception { permissionsService.checkRestriction(getUserId(), UserRestrictions::getReadonly); - permissionsService.checkRestriction(getUserId(), UserRestrictions::getLimitCommands); + if (entity.getId() > 0) { + permissionsService.checkPermission(Command.class, getUserId(), entity.getId()); + long deviceId = entity.getDeviceId(); + entity = storage.getObject(baseClass, new Request( + new Columns.All(), new Condition.Equals("id", "id", entity.getId()))); + entity.setDeviceId(deviceId); + } else { + permissionsService.checkRestriction(getUserId(), UserRestrictions::getLimitCommands); + } permissionsService.checkPermission(Device.class, getUserId(), entity.getDeviceId()); if (!commandsManager.sendCommand(entity)) { return Response.accepted(entity).build(); |