attempt keeping track/cache remote profiles locally again

also fixes logic error where we always say
we couldnt find the profile

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-03-04 19:51:00 -05:00 committed by June
parent b527ec4666
commit 465533d32b
2 changed files with 62 additions and 68 deletions

View file

@ -1,8 +1,6 @@
mod data;
use std::{collections::HashSet, sync::Arc};
pub use data::Data;
use ruma::api::federation;
use ruma::{
api::appservice::Registration,
events::{
@ -20,8 +18,12 @@ use ruma::{
};
use tracing::warn;
pub use data::Data;
use crate::{services, Error, Result};
mod data;
pub struct Service {
pub db: &'static dyn Data,
}
@ -39,12 +41,14 @@ impl Service {
update_joined_count: bool,
) -> Result<()> {
let membership = membership_event.membership;
// Keep track what remote users exist by adding them as "deactivated" users
if user_id.server_name() != services().globals.server_name() {
services().users.create(user_id, None)?;
/*
if !services().users.exists(user_id)? {
services().users.create(user_id, None)?;
}
// Try to update our local copy of the user if ours does not match
// TODO: ignore errors properly?
if ((services().users.displayname(user_id)? != membership_event.displayname)
|| (services().users.avatar_url(user_id)? != membership_event.avatar_url)
|| (services().users.blurhash(user_id)? != membership_event.blurhash))
@ -56,24 +60,24 @@ impl Service {
user_id.server_name(),
federation::query::get_profile_information::v1::Request {
user_id: user_id.into(),
field: Some(ProfileField::AvatarUrl),
field: None, // we want the full user's profile to update locally too
},
)
.await?;
let _ = services()
services()
.users
.set_displayname(user_id, response.displayname.clone())
.await;
let _ = services()
.await?;
services()
.users
.set_avatar_url(user_id, response.avatar_url)
.await;
let _ = services()
.await?;
services()
.users
.set_blurhash(user_id, response.blurhash)
.await;
.await?;
};
*/
}
match &membership {