Implement Follow::accept_follow07()
This commit is contained in:
parent
f14c307786
commit
44799e94fd
@ -11,7 +11,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,
|
broadcast, broadcast07,
|
||||||
inbox::{AsActor, AsObject, FromId},
|
inbox::{AsActor, AsObject, FromId},
|
||||||
sign::Signer,
|
sign::Signer,
|
||||||
Id, IntoId, PUBLIC_VISIBILITY,
|
Id, IntoId, PUBLIC_VISIBILITY,
|
||||||
@ -128,6 +128,39 @@ impl Follow {
|
|||||||
Ok(res)
|
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>(
|
pub fn build_accept<A: Signer + IntoId + Clone, B: Clone + AsActor<T> + IntoId, T>(
|
||||||
&self,
|
&self,
|
||||||
from: &B,
|
from: &B,
|
||||||
|
Loading…
Reference in New Issue
Block a user