Fix delete activities not federating
[akkoma] / lib / pleroma / web / ostatus / handlers / follow_handler.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.OStatus.FollowHandler do
6 alias Pleroma.Web.XML
7 alias Pleroma.Web.OStatus
8 alias Pleroma.Web.ActivityPub.ActivityPub
9 alias Pleroma.User
10
11 def handle(entry, doc) do
12 with {:ok, actor} <- OStatus.find_make_or_update_user(doc),
13 id when not is_nil(id) <- XML.string_from_xpath("/entry/id", entry),
14 followed_uri when not is_nil(followed_uri) <-
15 XML.string_from_xpath("/entry/activity:object/id", entry),
16 {:ok, followed} <- OStatus.find_or_make_user(followed_uri),
17 {:ok, activity} <- ActivityPub.follow(actor, followed, id, false) do
18 User.follow(actor, followed)
19 {:ok, activity}
20 end
21 end
22 end