From 18352c8c195ba81b8a635709fc29b6248018dd3d Mon Sep 17 00:00:00 2001 From: projectmoon Date: Sun, 22 Nov 2020 22:13:11 +0000 Subject: [PATCH] Filter out our username when resyncing (with an allocation). --- src/commands/management.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/commands/management.rs b/src/commands/management.rs index 8964c86..a8e38f5 100644 --- a/src/commands/management.rs +++ b/src/commands/management.rs @@ -18,11 +18,16 @@ impl Command for ResyncCommand { async fn execute(&self, ctx: &Context<'_>) -> Execution { let room_id = RoomId::try_from(ctx.room_id).expect("failed to decode room ID"); + let our_username = match ctx.matrix_client.user_id().await { + Some(username) => username.as_str().to_owned(), + _ => "".to_owned(), + }; + let usernames = matrix::get_users_in_room(&ctx.matrix_client, &room_id).await; let result: ResyncResult = usernames .into_iter() - //.filter(|username| username != &event.state_key) + .filter(|username| username != &our_username) .map(|username| ctx.db.rooms.add_user_to_room(&username, room_id.as_str())) .collect(); //Make use of collect impl on Result.