diff --git a/docs/openapi.yaml b/docs/openapi.yaml index 35aa142..f9a6026 100644 --- a/docs/openapi.yaml +++ b/docs/openapi.yaml @@ -1162,6 +1162,7 @@ components: - reblog - subscription - subscription_expiration + - move example: reply created_at: description: The timestamp of the notification. diff --git a/src/activitypub/handlers/move_person.rs b/src/activitypub/handlers/move_person.rs index 6876885..fcb5bab 100644 --- a/src/activitypub/handlers/move_person.rs +++ b/src/activitypub/handlers/move_person.rs @@ -13,6 +13,7 @@ use crate::activitypub::{ use crate::config::Config; use crate::errors::{DatabaseError, ValidationError}; use crate::models::{ + notifications::queries::create_move_notification, relationships::queries::{ create_follow_request, get_followers, @@ -92,6 +93,11 @@ pub async fn handle_move_person( Err(DatabaseError::AlreadyExists(_)) => (), // already following Err(other_error) => return Err(other_error.into()), }; + create_move_notification( + db_client, + &new_profile.id, + &follower.id, + ).await?; }; tokio::spawn(async move { for activity in activities { diff --git a/src/mastodon_api/notifications/types.rs b/src/mastodon_api/notifications/types.rs index 1567060..4b7435a 100644 --- a/src/mastodon_api/notifications/types.rs +++ b/src/mastodon_api/notifications/types.rs @@ -50,6 +50,7 @@ impl ApiNotification { EventType::Subscription => "subscription", EventType::SubscriptionStart => "", // not supported EventType::SubscriptionExpiration => "subscription_expiration", + EventType::Move => "move", }; Self { id: notification.id.to_string(), diff --git a/src/models/notifications/queries.rs b/src/models/notifications/queries.rs index b810dbd..6985c90 100644 --- a/src/models/notifications/queries.rs +++ b/src/models/notifications/queries.rs @@ -116,6 +116,17 @@ pub async fn create_subscription_expiration_notification( ).await } +pub async fn create_move_notification( + db_client: &impl GenericClient, + sender_id: &Uuid, + recipient_id: &Uuid, +) -> Result<(), DatabaseError> { + create_notification( + db_client, sender_id, recipient_id, None, + EventType::Move, + ).await +} + pub async fn get_notifications( db_client: &impl GenericClient, recipient_id: &Uuid, diff --git a/src/models/notifications/types.rs b/src/models/notifications/types.rs index 6483134..fc35c1b 100644 --- a/src/models/notifications/types.rs +++ b/src/models/notifications/types.rs @@ -22,6 +22,7 @@ pub enum EventType { Subscription, SubscriptionStart, SubscriptionExpiration, + Move, } impl From<&EventType> for i16 { @@ -36,6 +37,7 @@ impl From<&EventType> for i16 { EventType::Subscription => 7, EventType::SubscriptionStart => unimplemented!("not supported"), EventType::SubscriptionExpiration => 9, + EventType::Move => 10, } } } @@ -54,6 +56,7 @@ impl TryFrom for EventType { 7 => Self::Subscription, 8 => Self::SubscriptionStart, 9 => Self::SubscriptionExpiration, + 10 => Self::Move, _ => return Err(ConversionError), }; Ok(event_type)