mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-11-26 13:31:02 +00:00
Implement Follow::accept_follow07()
This commit is contained in:
parent
f14c307786
commit
44799e94fd
1 changed files with 34 additions and 1 deletions
|
@ -11,7 +11,7 @@ use activitystreams::{
|
|||
};
|
||||
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl};
|
||||
use plume_common::activity_pub::{
|
||||
broadcast,
|
||||
broadcast, broadcast07,
|
||||
inbox::{AsActor, AsObject, FromId},
|
||||
sign::Signer,
|
||||
Id, IntoId, PUBLIC_VISIBILITY,
|
||||
|
@ -128,6 +128,39 @@ impl Follow {
|
|||
Ok(res)
|
||||
}
|
||||
|
||||
/// from -> The one sending the follow request
|
||||
/// target -> The target of the request, responding with Accept
|
||||
pub fn accept_follow07<A: Signer + IntoId + Clone, B: Clone + AsActor<T> + IntoId, T>(
|
||||
conn: &Connection,
|
||||
from: &B,
|
||||
target: &A,
|
||||
follow: FollowAct07,
|
||||
from_id: i32,
|
||||
target_id: i32,
|
||||
) -> Result<Follow> {
|
||||
let res = Follow::insert(
|
||||
conn,
|
||||
NewFollow {
|
||||
follower_id: from_id,
|
||||
following_id: target_id,
|
||||
ap_url: follow
|
||||
.id_unchecked()
|
||||
.ok_or(Error::MissingApProperty)?
|
||||
.to_string(),
|
||||
},
|
||||
)?;
|
||||
res.notify(conn)?;
|
||||
|
||||
let accept = res.build_accept07(from, target, follow)?;
|
||||
broadcast07(
|
||||
&*target,
|
||||
accept,
|
||||
vec![from.clone()],
|
||||
CONFIG.proxy().cloned(),
|
||||
);
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
pub fn build_accept<A: Signer + IntoId + Clone, B: Clone + AsActor<T> + IntoId, T>(
|
||||
&self,
|
||||
from: &B,
|
||||
|
|
Loading…
Reference in a new issue