Implement AsObject07<User, FollowAct07, &DbConn> for User

This commit is contained in:
Kitaiti Makoto 2022-04-24 05:51:24 +09:00
parent 44799e94fd
commit 86609b51fa

View file

@ -12,7 +12,7 @@ use activitystreams::{
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl};
use plume_common::activity_pub::{ use plume_common::activity_pub::{
broadcast, broadcast07, broadcast, broadcast07,
inbox::{AsActor, AsObject, FromId}, inbox::{AsActor, AsObject, AsObject07, FromId},
sign::Signer, sign::Signer,
Id, IntoId, PUBLIC_VISIBILITY, Id, IntoId, PUBLIC_VISIBILITY,
}; };
@ -258,6 +258,18 @@ impl AsObject<User, FollowAct, &DbConn> for User {
} }
} }
impl AsObject07<User, FollowAct07, &DbConn> for User {
type Error = Error;
type Output = Follow;
fn activity07(self, conn: &DbConn, actor: User, id: &str) -> Result<Follow> {
// Mastodon (at least) requires the full Follow object when accepting it,
// so we rebuilt it here
let follow = FollowAct07::new(id.parse::<IriString>()?, actor.ap_url.parse::<IriString>()?);
Follow::accept_follow07(conn, &actor, &self, follow, actor.id, self.id)
}
}
impl FromId<DbConn> for Follow { impl FromId<DbConn> for Follow {
type Error = Error; type Error = Error;
type Object = FollowAct; type Object = FollowAct;