mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-11-29 15:01:10 +00:00
Accept both actor objects and links for Follows
This commit is contained in:
parent
6fe70cd723
commit
f79f01a93f
1 changed files with 4 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
||||||
use activitypub::{Actor, activity::{Accept, Follow as FollowAct}};
|
use activitypub::{Actor, activity::{Accept, Follow as FollowAct}, actor::Person};
|
||||||
use diesel::{self, PgConnection, ExpressionMethods, QueryDsl, RunQueryDsl};
|
use diesel::{self, PgConnection, ExpressionMethods, QueryDsl, RunQueryDsl};
|
||||||
|
|
||||||
use plume_common::activity_pub::{broadcast, Id, IntoId, inbox::{FromActivity, Notify, WithInbox}, sign::Signer};
|
use plume_common::activity_pub::{broadcast, Id, IntoId, inbox::{FromActivity, Notify, WithInbox}, sign::Signer};
|
||||||
|
@ -55,7 +55,9 @@ impl Follow {
|
||||||
|
|
||||||
impl FromActivity<FollowAct, PgConnection> for Follow {
|
impl FromActivity<FollowAct, PgConnection> for Follow {
|
||||||
fn from_activity(conn: &PgConnection, follow: FollowAct, _actor: Id) -> Follow {
|
fn from_activity(conn: &PgConnection, follow: FollowAct, _actor: Id) -> Follow {
|
||||||
let from = User::from_url(conn, follow.follow_props.actor.as_str().unwrap().to_string()).unwrap();
|
let from_id = follow.follow_props.actor_link::<Id>().map(|l| l.into())
|
||||||
|
.unwrap_or_else(|_| follow.follow_props.actor_object::<Person>().expect("No actor object (nor ID) on Follow").object_props.id_string().expect("No ID on actor on Follow"));
|
||||||
|
let from = User::from_url(conn, from_id).unwrap();
|
||||||
match User::from_url(conn, follow.follow_props.object.as_str().unwrap().to_string()) {
|
match User::from_url(conn, follow.follow_props.object.as_str().unwrap().to_string()) {
|
||||||
Some(user) => Follow::accept_follow(conn, &from, &user, follow, from.id, user.id),
|
Some(user) => Follow::accept_follow(conn, &from, &user, follow, from.id, user.id),
|
||||||
None => {
|
None => {
|
||||||
|
|
Loading…
Reference in a new issue