1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2025-08-01 17:38:36 +00:00

style(presence): reformat

This commit is contained in:
Jakub Kubík 2022-11-21 21:50:30 +01:00
parent 8d161c6a36
commit 230f09f8f7
No known key found for this signature in database
GPG key ID: D3A0D5D60F3A173F
2 changed files with 19 additions and 12 deletions

View file

@ -225,7 +225,8 @@ impl service::rooms::edus::presence::Data for KeyValueDatabase {
// TODO: Get rid of this hack (hinting correct types to rustc) // TODO: Get rid of this hack (hinting correct types to rustc)
timers.push(create_presence_timer( timers.push(create_presence_timer(
Duration::from_secs(1), Duration::from_secs(1),
UserId::parse_with_server_name("conduit", services().globals.server_name()).expect("Conduit user always exists") UserId::parse_with_server_name("conduit", services().globals.server_name())
.expect("Conduit user always exists"),
)); ));
tokio::spawn(async move { tokio::spawn(async move {
@ -306,19 +307,21 @@ impl service::rooms::edus::presence::Data for KeyValueDatabase {
tokio::spawn(async move { tokio::spawn(async move {
loop { loop {
let mut removed_events: u64 = 0; let mut removed_events: u64 = 0;
let age_limit_curr = millis_since_unix_epoch().saturating_sub(age_limit.as_millis() as u64); let age_limit_curr =
millis_since_unix_epoch().saturating_sub(age_limit.as_millis() as u64);
for user_id in userid_presenceupdate for user_id in userid_presenceupdate
.iter() .iter()
.map(|(user_id_bytes, update_bytes)| { .map(|(user_id_bytes, update_bytes)| {
( (
UserId::parse( UserId::parse(
utils::string_from_bytes(&user_id_bytes) utils::string_from_bytes(&user_id_bytes)
.expect("UserID bytes are a valid string"), .expect("UserID bytes are a valid string"),
) )
.expect("UserID bytes from database are a valid UserID"), .expect("UserID bytes from database are a valid UserID"),
PresenceUpdate::from_be_bytes(&update_bytes) PresenceUpdate::from_be_bytes(&update_bytes).expect(
.expect("PresenceUpdate bytes from database are a valid PresenceUpdate"), "PresenceUpdate bytes from database are a valid PresenceUpdate",
),
) )
}) })
.filter_map(|(user_id, presence_update)| { .filter_map(|(user_id, presence_update)| {
@ -335,9 +338,13 @@ impl service::rooms::edus::presence::Data for KeyValueDatabase {
.rooms_joined(&user_id) .rooms_joined(&user_id)
.filter_map(|room_id| room_id.ok()) .filter_map(|room_id| room_id.ok())
{ {
match roomuserid_presenceevent.remove(&*[room_id.as_bytes(), &[0xff], user_id.as_bytes()].concat()) { match roomuserid_presenceevent
.remove(&*[room_id.as_bytes(), &[0xff], user_id.as_bytes()].concat())
{
Ok(_) => removed_events += 1, Ok(_) => removed_events += 1,
Err(e) => error!("An errord occured while removing a stale presence event: {e}") Err(e) => error!(
"An errord occured while removing a stale presence event: {e}"
),
} }
} }
} }

View file

@ -24,7 +24,7 @@ impl Service {
service.presence_maintain(receiver)?; service.presence_maintain(receiver)?;
service.presence_cleanup()?; service.presence_cleanup()?;
Ok(service) Ok(service)
} }