Positionsupdate und NAvigations Deeplink in mobilen Views
This commit is contained in:
1 parent
d312442e62
commit
91ff49b688
6 files changed
+395
-16
No files matched your search
+17
-10
@@ -542,28 +542,35 @@ class WebSocketBroker:
|
||||
# manipulierbare Client-Zeitangaben verfälscht wird.
|
||||
pos_at = datetime.now(timezone.utc).strftime('%Y-%m-%d %H:%M:%S')
|
||||
ts_ms = int(time.time() * 1000)
|
||||
automatic = payload.get('automatic') is True
|
||||
|
||||
db.execute(
|
||||
'UPDATE groups SET last_lat = ?, last_lon = ?, last_pos_at = ?, '
|
||||
'updated_at = CURRENT_TIMESTAMP WHERE id = ? AND tenant_id = ?',
|
||||
(lat, lon, pos_at, group_id, tenant_id)
|
||||
)
|
||||
db.execute(
|
||||
'''INSERT INTO group_state_history
|
||||
(tenant_id, group_id, from_state, to_state, last_lat, last_lon,
|
||||
last_pos_at, actor_account_id)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||
(tenant_id, group_id, group['state'], group['state'],
|
||||
lat, lon, pos_at, sender['id'])
|
||||
)
|
||||
# Automatische Positionsmeldungen der Gruppen-View aktualisieren nur
|
||||
# die Live-Position. Die Historie und das Transaktionslog bleiben
|
||||
# manuellen Positionsänderungen vorbehalten, damit sie nicht durch
|
||||
# regelmäßige Telemetrie geflutet werden.
|
||||
if not automatic:
|
||||
db.execute(
|
||||
'''INSERT INTO group_state_history
|
||||
(tenant_id, group_id, from_state, to_state, last_lat, last_lon,
|
||||
last_pos_at, actor_account_id)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||
(tenant_id, group_id, group['state'], group['state'],
|
||||
lat, lon, pos_at, sender['id'])
|
||||
)
|
||||
db.commit()
|
||||
GroupsService.update_cache_entry(tenant_id, group_id, {
|
||||
'last_lat': lat,
|
||||
'last_lon': lon,
|
||||
'last_pos_at': pos_at
|
||||
})
|
||||
self._log_business(tenant_id, sender['id'], 'group.position_change', 'group',
|
||||
group_id, {'lat': lat, 'lon': lon})
|
||||
if not automatic:
|
||||
self._log_business(tenant_id, sender['id'], 'group.position_change', 'group',
|
||||
group_id, {'lat': lat, 'lon': lon})
|
||||
|
||||
message.receiver_id = group_id
|
||||
# Auch der Nachrichten-Zeitstempel wird serverseitig gesetzt, damit
|
||||
|
||||
Reference in new issue
Block a user