feat(database/presence): add skeleton for presence maintenance

This commit is contained in:
Jakub Kubík 2022-08-13 23:29:01 +02:00 committed by Nyaaori
parent f56424bc8d
commit fd0ea4bf71
No known key found for this signature in database
GPG Key ID: E7819C3ED4D1F82E

View File

@ -100,6 +100,23 @@ impl service::room::edus::presence::Data for KeyValueDatabase {
Ok(hashmap)
}
fn presence_maintain(&self, db: Arc<TokioRwLock<Database>>) {
// TODO @M0dEx: move this to a timed tasks module
tokio::spawn(async move {
loop {
select! {
Some(user_id) = self.presence_timers.next() {
// TODO @M0dEx: would it be better to acquire the lock outside the loop?
let guard = db.read().await;
// TODO @M0dEx: add self.presence_timers
// TODO @M0dEx: maintain presence
}
}
}
});
}
}
fn parse_presence_event(bytes: &[u8]) -> Result<PresenceEvent> {
@ -121,4 +138,3 @@ fn parse_presence_event(bytes: &[u8]) -> Result<PresenceEvent> {
.map(|timestamp| current_timestamp - timestamp);
}
}