Add profile URL field to Account type

This commit is contained in:
silverpill 2022-01-15 00:18:17 +00:00
parent f1f3829b8d
commit cd8791c881
3 changed files with 8 additions and 0 deletions

View file

@ -469,6 +469,10 @@ components:
description: The Webfinger account URI. Equal to username for local actors, or username@domain for remote actors.
type: string
example: user@example.com
url:
description: The location of the user's profile page.
type: string
example: https://example.com/@user
wallet_address:
description: Ethereum wallet address.
type: string

View file

@ -31,6 +31,7 @@ pub struct Account {
pub id: Uuid,
pub username: String,
pub acct: String,
pub url: String,
pub display_name: Option<String>,
pub created_at: DateTime<Utc>,
pub note: Option<String>,
@ -48,6 +49,7 @@ pub struct Account {
impl Account {
pub fn from_profile(profile: DbActorProfile, instance_url: &str) -> Self {
let profile_url = profile.actor_url(instance_url);
let avatar_url = profile.avatar_file_name.as_ref()
.map(|name| get_file_url(instance_url, name));
let header_url = profile.banner_file_name.as_ref()
@ -59,6 +61,7 @@ impl Account {
id: profile.id,
username: profile.username,
acct: profile.acct,
url: profile_url,
display_name: profile.display_name,
created_at: profile.created_at,
note: profile.bio,

View file

@ -95,6 +95,7 @@ impl DbActorProfile {
}
}
/// Profile URL
pub fn actor_url(&self, instance_url: &str) -> String {
if let Some(ref actor) = self.actor_json {
if let Some(ref actor_url) = actor.url {