aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/api/resource/CommandResource.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/api/resource/CommandResource.java')
-rw-r--r--src/org/traccar/api/resource/CommandResource.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/org/traccar/api/resource/CommandResource.java b/src/org/traccar/api/resource/CommandResource.java
index 8da9f8447..996c15daf 100644
--- a/src/org/traccar/api/resource/CommandResource.java
+++ b/src/org/traccar/api/resource/CommandResource.java
@@ -62,15 +62,19 @@ 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().checkPermission(Command.class, getUserId(), id);
Context.getPermissionsManager().checkDevice(getUserId(), deviceId);
Context.getPermissionsManager().checkUserDeviceCommand(getUserId(), deviceId, id);
- Context.getCommandsManager().sendCommand(id, deviceId);
+ sent = Context.getCommandsManager().sendCommand(id, deviceId);
} else {
Context.getPermissionsManager().checkLimitCommands(getUserId());
Context.getPermissionsManager().checkDevice(getUserId(), deviceId);
- Context.getCommandsManager().sendCommand(entity);
+ sent = Context.getCommandsManager().sendCommand(entity, deviceId);
+ }
+ if (!sent) {
+ return Response.accepted(entity).build();
}
return Response.ok(entity).build();
}