diff options
author | rtkay123 <dev@kanjala.com> | 2025-07-16 08:55:36 +0200 |
---|---|---|
committer | rtkay123 <dev@kanjala.com> | 2025-07-16 08:55:36 +0200 |
commit | ea71fa9d9cc136bd3eec5ecb58a592282697531b (patch) | |
tree | efdfc2d94c515e61b18dc291bb8a4a4299305e90 /src | |
parent | da6ab098acacf6233542a591110f8b28ffd298ed (diff) | |
download | sellershut-ea71fa9d9cc136bd3eec5ecb58a592282697531b.tar.bz2 sellershut-ea71fa9d9cc136bd3eec5ecb58a592282697531b.zip |
feat: follow collections to user
Diffstat (limited to 'src')
-rw-r--r-- | src/entity/user.rs | 24 | ||||
-rw-r--r-- | src/entity/user/followers.rs | 1 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/entity/user.rs b/src/entity/user.rs index aa1207d..24315e0 100644 --- a/src/entity/user.rs +++ b/src/entity/user.rs @@ -1,3 +1,5 @@ +pub mod followers; + use activitypub_federation::{ config::Data, fetch::object_id::ObjectId, @@ -8,6 +10,7 @@ use activitypub_federation::{ }; use async_trait::async_trait; use serde::{Deserialize, Serialize}; +use sqlx::types::time::OffsetDateTime; use stack_up::{Environment, Services}; use tracing::trace; use url::Url; @@ -21,6 +24,8 @@ pub(crate) struct User { pub username: String, pub ap_id: ObjectId<User>, pub private_key: Option<String>, + pub description: Option<String>, + pub avatar_url: Option<String>, pub public_key: String, pub inbox: Url, pub outbox: Option<Url>, @@ -28,13 +33,17 @@ pub(crate) struct User { pub struct DbUser { pub id: String, + pub description: Option<String>, pub username: String, pub ap_id: String, pub private_key: Option<String>, pub public_key: String, pub inbox: String, pub outbox: Option<String>, + pub avatar_url: Option<String>, pub local: bool, + pub updated_at: OffsetDateTime, + pub created_at: OffsetDateTime, } impl TryFrom<DbUser> for User { @@ -51,6 +60,8 @@ impl TryFrom<DbUser> for User { Some(ref url) => Some(Url::parse(url)?), None => None, }, + description: value.description, + avatar_url: value.avatar_url, }) } } @@ -119,6 +130,12 @@ pub struct Person { public_key: PublicKey, #[serde(skip_serializing_if = "Option::is_none")] outbox: Option<Url>, + followers: Url, + following: Url, + #[serde(skip_serializing_if = "Option::is_none")] + summary: Option<String>, + #[serde(skip_serializing_if = "Option::is_none")] + image: Option<Url>, } #[async_trait] @@ -158,6 +175,13 @@ impl Object for User { inbox: self.inbox.clone(), public_key: self.public_key(), outbox: self.outbox.clone(), + followers: Url::parse(&format!("{}/followers", self.ap_id))?, + following: Url::parse(&format!("{}/following", self.ap_id))?, + summary: self.description, + image: match self.avatar_url { + Some(ref v) => Some(Url::parse(v)?), + None => None, + }, }) } diff --git a/src/entity/user/followers.rs b/src/entity/user/followers.rs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/entity/user/followers.rs @@ -0,0 +1 @@ + |