From 86609b51faec52ac98f4d0b5b474e789c3e21d15 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Sun, 24 Apr 2022 05:51:24 +0900 Subject: [PATCH] Implement AsObject07 for User --- plume-models/src/follows.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/plume-models/src/follows.rs b/plume-models/src/follows.rs index df47b708..0aeaba90 100644 --- a/plume-models/src/follows.rs +++ b/plume-models/src/follows.rs @@ -12,7 +12,7 @@ use activitystreams::{ use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl}; use plume_common::activity_pub::{ broadcast, broadcast07, - inbox::{AsActor, AsObject, FromId}, + inbox::{AsActor, AsObject, AsObject07, FromId}, sign::Signer, Id, IntoId, PUBLIC_VISIBILITY, }; @@ -258,6 +258,18 @@ impl AsObject for User { } } +impl AsObject07 for User { + type Error = Error; + type Output = Follow; + + fn activity07(self, conn: &DbConn, actor: User, id: &str) -> Result { + // Mastodon (at least) requires the full Follow object when accepting it, + // so we rebuilt it here + let follow = FollowAct07::new(id.parse::()?, actor.ap_url.parse::()?); + Follow::accept_follow07(conn, &actor, &self, follow, actor.id, self.id) + } +} + impl FromId for Follow { type Error = Error; type Object = FollowAct;