From f79f01a93f564e8cbd8eaaa8f00c0b450a7f30ac Mon Sep 17 00:00:00 2001 From: Bat Date: Sun, 8 Jul 2018 20:01:19 +0200 Subject: [PATCH] Accept both actor objects and links for Follows --- plume-models/src/follows.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plume-models/src/follows.rs b/plume-models/src/follows.rs index af3412f..05c50a3 100644 --- a/plume-models/src/follows.rs +++ b/plume-models/src/follows.rs @@ -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 plume_common::activity_pub::{broadcast, Id, IntoId, inbox::{FromActivity, Notify, WithInbox}, sign::Signer}; @@ -55,7 +55,9 @@ impl Follow { impl FromActivity for 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::().map(|l| l.into()) + .unwrap_or_else(|_| follow.follow_props.actor_object::().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()) { Some(user) => Follow::accept_follow(conn, &from, &user, follow, from.id, user.id), None => {