Skip to main content

tuwunel_admin/user/
refresh_profile.rs

1use ruma::{OwnedUserId, profile::ProfileFieldName};
2use tuwunel_core::{Result, itertools::Itertools};
3
4use crate::{admin_command, utils::check_known_remote_user};
5
6#[admin_command]
7pub(super) async fn refresh_profile(&self, user_id: OwnedUserId) -> Result {
8	check_known_remote_user(self.services, &user_id).await?;
9
10	let removed = self
11		.services
12		.profile
13		.mirror_remote_profile(&user_id)
14		.await?;
15
16	if removed.is_empty() {
17		return write!(self, "Refreshed the profile of {user_id}; no cached field was stale.")
18			.await;
19	}
20
21	let names = removed
22		.iter()
23		.map(ProfileFieldName::as_str)
24		.format(", ");
25
26	write!(self, "Refreshed the profile of {user_id}; removed {names}.").await
27}