Filter out our username when resyncing (with an allocation).

This commit is contained in:
projectmoon 2020-11-22 22:13:11 +00:00
parent dda0d74f45
commit 18352c8c19
1 changed files with 6 additions and 1 deletions

View File

@ -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.