diff options
author | Anton Tananaev <anton@traccar.org> | 2022-06-28 08:13:03 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-06-28 08:13:03 -0700 |
commit | a487c1efa5dff2a7644ee7f2874967f4bb867b6a (patch) | |
tree | 0d266dd5809dbc5a78d293675005e11b27bf0c2b /src/main/java/org/traccar/session | |
parent | ef644e5185b3109b0da30972a0b5c56768c69957 (diff) | |
download | trackermap-server-a487c1efa5dff2a7644ee7f2874967f4bb867b6a.tar.gz trackermap-server-a487c1efa5dff2a7644ee7f2874967f4bb867b6a.tar.bz2 trackermap-server-a487c1efa5dff2a7644ee7f2874967f4bb867b6a.zip |
Fix new device updates
Diffstat (limited to 'src/main/java/org/traccar/session')
-rw-r--r-- | src/main/java/org/traccar/session/ConnectionManager.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/session/ConnectionManager.java b/src/main/java/org/traccar/session/ConnectionManager.java index c2f602c11..27d6184c2 100644 --- a/src/main/java/org/traccar/session/ConnectionManager.java +++ b/src/main/java/org/traccar/session/ConnectionManager.java @@ -364,6 +364,18 @@ public class ConnectionManager implements BroadcastInterface { } } + @Override + public synchronized void invalidatePermission( + Class<? extends BaseModel> clazz1, long id1, + Class<? extends BaseModel> clazz2, long id2) { + if (clazz1.equals(User.class) && clazz2.equals(Device.class)) { + if (listeners.containsKey(id1)) { + userDevices.get(id1).add(id2); + deviceUsers.put(id2, Set.of(id1)); + } + } + } + public interface UpdateListener { void onKeepalive(); void onUpdateDevice(Device device); @@ -379,7 +391,7 @@ public class ConnectionManager implements BroadcastInterface { var devices = storage.getObjects(Device.class, new Request( new Columns.Include("id"), new Condition.Permission(User.class, userId, Device.class))); - userDevices.put(userId, devices.stream().map(BaseModel::getId).collect(Collectors.toUnmodifiableSet())); + userDevices.put(userId, devices.stream().map(BaseModel::getId).collect(Collectors.toSet())); devices.forEach(device -> deviceUsers.computeIfAbsent(device.getId(), id -> new HashSet<>()).add(userId)); } set.add(listener); |