[Feat] load anonymous user data
This commit is contained in:
parent
c359b0626a
commit
163e789379
4 changed files with 72 additions and 1 deletions
|
|
@ -71,6 +71,10 @@ impl AnonymousClientConnection {
|
|||
self.display_name.read().await.clone()
|
||||
}
|
||||
|
||||
pub async fn set_display_name(&self, display: String) {
|
||||
*self.display_name.write().await = display;
|
||||
}
|
||||
|
||||
/// Get the avatar
|
||||
pub async fn get_avatar(&self) -> String {
|
||||
self.avatar.read().await.clone()
|
||||
|
|
@ -260,7 +264,14 @@ impl AnonymousClientConnection {
|
|||
}
|
||||
|
||||
if cv.is_type(CommunicationType::change_user_data) {
|
||||
// TODO
|
||||
if let Some(display_name) = cv
|
||||
.get_data(DataTypes::display)
|
||||
.unwrap_or(&JsonValue::Null)
|
||||
.as_str()
|
||||
{
|
||||
let _ = self.set_display_name(display_name.to_string()).await;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,3 +19,18 @@ pub async fn remove_anonymous_user(user_id: i64) {
|
|||
pub async fn get_anonymous_user(user_id: i64) -> Option<Arc<AnonymousClientConnection>> {
|
||||
ANONYMOUS_USERS.get(&user_id).map(|c| c.clone())
|
||||
}
|
||||
|
||||
pub async fn get_anonymous_user_by_name(
|
||||
username: String,
|
||||
) -> Option<Arc<AnonymousClientConnection>> {
|
||||
for user_conn in ANONYMOUS_USERS
|
||||
.iter()
|
||||
.map(|ref_multi| ref_multi.value().clone())
|
||||
{
|
||||
if user_conn.get_user_name().await == username {
|
||||
return Some(user_conn);
|
||||
}
|
||||
}
|
||||
|
||||
return None;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue