aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2024-01-15 16:36:17 -0800
committerAnton Tananaev <anton@traccar.org>2024-01-15 16:36:17 -0800
commitacebabc690f78921a1bc10191df092c207393415 (patch)
tree8731d43fd4e71543a09873d5a9a309052801fe47
parent72cfe80fb23bb5e1d2aec2f2d2b4cfcd3662a82d (diff)
downloadtrackermap-server-acebabc690f78921a1bc10191df092c207393415.tar.gz
trackermap-server-acebabc690f78921a1bc10191df092c207393415.tar.bz2
trackermap-server-acebabc690f78921a1bc10191df092c207393415.zip
Make device sharing configurable
-rw-r--r--src/main/java/org/traccar/api/resource/DeviceResource.java7
-rw-r--r--src/main/java/org/traccar/config/Keys.java14
2 files changed, 21 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/api/resource/DeviceResource.java b/src/main/java/org/traccar/api/resource/DeviceResource.java
index 217ccda65..540450cbb 100644
--- a/src/main/java/org/traccar/api/resource/DeviceResource.java
+++ b/src/main/java/org/traccar/api/resource/DeviceResource.java
@@ -19,6 +19,8 @@ import jakarta.ws.rs.FormParam;
import org.traccar.api.BaseObjectResource;
import org.traccar.api.signature.TokenManager;
import org.traccar.broadcast.BroadcastService;
+import org.traccar.config.Config;
+import org.traccar.config.Keys;
import org.traccar.database.MediaManager;
import org.traccar.helper.LogAction;
import org.traccar.model.Device;
@@ -61,6 +63,9 @@ import java.util.List;
public class DeviceResource extends BaseObjectResource<Device> {
@Inject
+ private Config config;
+
+ @Inject
private CacheManager cacheManager;
@Inject
@@ -212,6 +217,8 @@ public class DeviceResource extends BaseObjectResource<Device> {
share.setExpirationTime(expiration);
share.setTemporary(true);
share.setReadonly(true);
+ share.setLimitCommands(!config.getBoolean(Keys.WEB_SHARE_DEVICE_COMMANDS));
+ share.setDisableReports(!config.getBoolean(Keys.WEB_SHARE_DEVICE_REPORTS));
share.setId(storage.addObject(share, new Request(new Columns.Exclude("id"))));
diff --git a/src/main/java/org/traccar/config/Keys.java b/src/main/java/org/traccar/config/Keys.java
index 1da68e1c0..e79264908 100644
--- a/src/main/java/org/traccar/config/Keys.java
+++ b/src/main/java/org/traccar/config/Keys.java
@@ -1806,6 +1806,20 @@ public final class Keys {
List.of(KeyType.CONFIG));
/**
+ * Enable commands for a shared device.
+ */
+ public static final ConfigKey<Boolean> WEB_SHARE_DEVICE_COMMANDS = new BooleanConfigKey(
+ "web.shareDevice.commands",
+ List.of(KeyType.CONFIG));
+
+ /**
+ * Enable reports for a shared device.
+ */
+ public static final ConfigKey<Boolean> WEB_SHARE_DEVICE_REPORTS = new BooleanConfigKey(
+ "web.shareDevice.reports",
+ List.of(KeyType.CONFIG));
+
+ /**
* Output logging to the standard terminal output instead of a log file.
*/
public static final ConfigKey<Boolean> LOGGER_CONSOLE = new BooleanConfigKey(