From cd9d3f9db41f20941a1fd3bc5f7453a1ab5019f7 Mon Sep 17 00:00:00 2001 From: alemi Date: Sun, 21 Apr 2024 21:15:58 +0200 Subject: [PATCH] fix: use preferred_username before using url --- src/model/user.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/model/user.rs b/src/model/user.rs index 37490dc..068a00b 100644 --- a/src/model/user.rs +++ b/src/model/user.rs @@ -42,9 +42,11 @@ pub struct Model { impl Model { pub fn new(object: &impl Actor) -> Result { let ap_id = object.id().ok_or(super::FieldError("id"))?.to_string(); - let (domain, preferred_username) = split_user_id(&ap_id); + let (domain, fallback_preferred_username) = split_user_id(&ap_id); Ok(Model { - id: ap_id, preferred_username, domain, + id: ap_id, + domain, + preferred_username: object.preferred_username().unwrap_or(&fallback_preferred_username).to_string(), actor_type: object.actor_type().ok_or(super::FieldError("type"))?, name: object.name().map(|x| x.to_string()), summary: object.summary().map(|x| x.to_string()),