Merge branch 'feld-varnish' into 'develop'
[akkoma] / lib / pleroma / web / ostatus / handlers / follow_handler.ex
1 defmodule Pleroma.Web.OStatus.FollowHandler do
2 alias Pleroma.Web.{XML, OStatus}
3 alias Pleroma.Web.ActivityPub.ActivityPub
4 alias Pleroma.User
5
6 def handle(entry, doc) do
7 with {:ok, actor} <- OStatus.find_make_or_update_user(doc),
8 id when not is_nil(id) <- XML.string_from_xpath("/entry/id", entry),
9 followed_uri when not is_nil(followed_uri) <-
10 XML.string_from_xpath("/entry/activity:object/id", entry),
11 {:ok, followed} <- OStatus.find_or_make_user(followed_uri),
12 {:ok, activity} <- ActivityPub.follow(actor, followed, id, false) do
13 User.follow(actor, followed)
14 {:ok, activity}
15 end
16 end
17 end