2021-01-30 14:17:34 +00:00
|
|
|
use super::{Command, CommandResult, Execution};
|
2020-11-22 21:30:24 +00:00
|
|
|
use crate::context::Context;
|
2020-11-30 19:53:26 +00:00
|
|
|
use crate::logic::record_room_information;
|
2020-11-22 21:30:24 +00:00
|
|
|
use async_trait::async_trait;
|
2020-11-29 21:03:45 +00:00
|
|
|
use matrix_sdk::identifiers::UserId;
|
2020-11-22 21:30:24 +00:00
|
|
|
|
|
|
|
pub struct ResyncCommand;
|
|
|
|
|
|
|
|
#[async_trait]
|
|
|
|
impl Command for ResyncCommand {
|
|
|
|
fn name(&self) -> &'static str {
|
|
|
|
"resync room information"
|
|
|
|
}
|
|
|
|
|
2021-01-30 14:17:34 +00:00
|
|
|
async fn execute(&self, ctx: &Context<'_>) -> CommandResult {
|
2020-11-23 19:54:16 +00:00
|
|
|
let our_username: Option<UserId> = ctx.matrix_client.user_id().await;
|
|
|
|
let our_username: &str = our_username.as_ref().map_or("", UserId::as_str);
|
2020-11-22 22:13:11 +00:00
|
|
|
|
2021-01-30 14:17:34 +00:00
|
|
|
record_room_information(
|
2021-01-29 22:35:07 +00:00
|
|
|
ctx.matrix_client,
|
|
|
|
&ctx.db,
|
|
|
|
ctx.room.id,
|
|
|
|
&ctx.room.display_name,
|
|
|
|
our_username,
|
|
|
|
)
|
2021-01-30 14:17:34 +00:00
|
|
|
.await?;
|
2020-11-22 21:30:24 +00:00
|
|
|
|
2021-01-31 14:06:25 +00:00
|
|
|
let message = "Room information resynced.".to_string();
|
|
|
|
Execution::new(message)
|
2020-11-22 21:30:24 +00:00
|
|
|
}
|
|
|
|
}
|