Add update for device last_seen_ts. (closes #40)

Piggyback on presence ping for controlled device seen updates.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk committed 2025-11-02 00:02:49 +00:00
1 parent 240b498489
commit 8b1de3d8db
8 files changed
+82 -19

No files matched your search

+20
View File
@@ -362,6 +362,26 @@ pub async fn remove_to_device_events<Until>(
.await;
}
#[implement(super::Service)]
pub async fn update_device_last_seen(
&self,
user_id: &UserId,
device_id: &DeviceId,
last_seen: Option<MilliSecondsSinceUnixEpoch>,
) -> Result {
let mut device = self
.get_device_metadata(user_id, device_id)
.await?;
device
.last_seen_ts
.replace(last_seen.unwrap_or_else(MilliSecondsSinceUnixEpoch::now));
self.put_device_metadata(user_id, false, &device);
Ok(())
}
#[implement(super::Service)]
pub fn put_device_metadata(&self, user_id: &UserId, notify: bool, device: &Device) {
let key = (user_id, &device.device_id);