aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/common_api/common_api.ex
diff options
context:
space:
mode:
authoreugenijm <eugenijm@protonmail.com>2019-03-04 00:50:00 +0300
committereugenijm <eugenijm@protonmail.com>2019-03-04 01:00:37 +0300
commit594694607cce6e6afc8261911e44273cb3cb03c0 (patch)
tree0e5e1108b2d39b5a43b8937b379c8abba930ea4c /lib/pleroma/web/common_api/common_api.ex
parentdd5865535eb16f535ff996eb3dec5e947a905268 (diff)
downloadpleroma-594694607cce6e6afc8261911e44273cb3cb03c0.tar.gz
Unify Mastodon and Twitter follow implementations using CommonAPI
Diffstat (limited to 'lib/pleroma/web/common_api/common_api.ex')
-rw-r--r--lib/pleroma/web/common_api/common_api.ex13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex
index 7114d6de6..55a9c2572 100644
--- a/lib/pleroma/web/common_api/common_api.ex
+++ b/lib/pleroma/web/common_api/common_api.ex
@@ -14,6 +14,19 @@ defmodule Pleroma.Web.CommonAPI do
import Pleroma.Web.CommonAPI.Utils
+ def follow(follower, followed) do
+ with {:ok, follower} <- User.maybe_direct_follow(follower, followed),
+ {:ok, activity} <- ActivityPub.follow(follower, followed),
+ {:ok, follower, followed} <-
+ User.wait_and_refresh(
+ Pleroma.Config.get([:activitypub, :follow_handshake_timeout]),
+ follower,
+ followed
+ ) do
+ {:ok, follower, followed, activity}
+ end
+ end
+
def delete(activity_id, user) do
with %Activity{data: %{"object" => %{"id" => object_id}}} <- Repo.get(Activity, activity_id),
%Object{} = object <- Object.normalize(object_id),