diff options
Diffstat (limited to 'src/org/traccar/api/resource/CommandResource.java')
-rw-r--r-- | src/org/traccar/api/resource/CommandResource.java | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/org/traccar/api/resource/CommandResource.java b/src/org/traccar/api/resource/CommandResource.java index 996c15daf..a25421e31 100644 --- a/src/org/traccar/api/resource/CommandResource.java +++ b/src/org/traccar/api/resource/CommandResource.java @@ -62,17 +62,14 @@ public class CommandResource extends ExtendedObjectResource<Command> { Context.getPermissionsManager().checkReadonly(getUserId()); long deviceId = entity.getDeviceId(); long id = entity.getId(); - boolean sent; - if (deviceId != 0 && id != 0) { + Context.getPermissionsManager().checkDevice(getUserId(), deviceId); + if (id != 0) { Context.getPermissionsManager().checkPermission(Command.class, getUserId(), id); - Context.getPermissionsManager().checkDevice(getUserId(), deviceId); Context.getPermissionsManager().checkUserDeviceCommand(getUserId(), deviceId, id); - sent = Context.getCommandsManager().sendCommand(id, deviceId); } else { Context.getPermissionsManager().checkLimitCommands(getUserId()); - Context.getPermissionsManager().checkDevice(getUserId(), deviceId); - sent = Context.getCommandsManager().sendCommand(entity, deviceId); } + boolean sent = Context.getCommandsManager().sendCommand(entity); if (!sent) { return Response.accepted(entity).build(); } |