fix: lysand ap fetch UUID change and wrong URI

This commit is contained in:
aprilthepink 2024-07-17 01:07:23 +02:00
parent b5b4144f39
commit 45a7555db3
3 changed files with 15 additions and 5 deletions

View file

@ -110,7 +110,7 @@ pub async fn lysand_user_from_db(
);
let user = super::objects::User {
rtype: super::objects::LysandType::User,
id: uuid::Uuid::parse_str(&user.id)?,
id: uuid::Uuid::try_parse(&user.id)?,
uri: url.clone(),
username: user.username,
display_name,
@ -129,7 +129,8 @@ pub async fn lysand_user_from_db(
created_at: OffsetDateTime::from_unix_timestamp(user.created_at.timestamp()).unwrap(),
public_key: PublicKey {
actor: url.clone(),
public_key: "AAAAC3NzaC1lZDI1NTE5AAAAIMxsX+lEWkHZt9NOvn9yYFP0Z++186LY4b97C4mwj/f2".to_string(), // dummy key
public_key: "AAAAC3NzaC1lZDI1NTE5AAAAIMxsX+lEWkHZt9NOvn9yYFP0Z++186LY4b97C4mwj/f2"
.to_string(), // dummy key
},
};
Ok(user)

View file

@ -58,9 +58,18 @@ async fn query_post(
}
if let Some(user) = query.user_url.clone() {
let target = ObjectId::<user::Model>::from(user)
let opt_model = prelude::User::find()
.filter(user::Column::Url.eq(user.as_str()))
.one(db)
.await?;
let target;
if let Some(model) = opt_model {
target = model;
} else {
target = ObjectId::<user::Model>::from(user)
.dereference(&data.to_request_data())
.await?;
}
let lysand_user = lysand_user_from_db(target).await?;
return Ok(HttpResponse::Ok()

View file

@ -143,7 +143,7 @@ impl Object for user::Model {
public_key: Set(json.public_key.public_key_pem),
local: Set(false),
summary: Set(json.summary),
url: Set(json.url.to_string()),
url: Set(json.id.to_string()),
follower_count: Set(0),
following_count: Set(0),
created_at: Set(Utc::now()),