2018-12-23 21:04:54 +01:00
|
|
|
# Pleroma: A lightweight social networking server
|
2018-12-31 16:41:47 +01:00
|
|
|
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
2018-12-23 21:04:54 +01:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2017-05-10 18:46:23 +02:00
|
|
|
defmodule Pleroma.Web.OStatus.FollowHandler do
|
|
|
|
alias Pleroma.User
|
2019-03-05 03:52:23 +01:00
|
|
|
alias Pleroma.Web.ActivityPub.ActivityPub
|
|
|
|
alias Pleroma.Web.OStatus
|
|
|
|
alias Pleroma.Web.XML
|
2017-05-10 18:46:23 +02:00
|
|
|
|
|
|
|
def handle(entry, doc) do
|
2019-07-31 19:23:16 +02:00
|
|
|
with {:ok, actor} <- OStatus.find_make_or_update_actor(doc),
|
2017-05-10 18:46:23 +02:00
|
|
|
id when not is_nil(id) <- XML.string_from_xpath("/entry/id", entry),
|
2018-03-30 15:01:53 +02:00
|
|
|
followed_uri when not is_nil(followed_uri) <-
|
|
|
|
XML.string_from_xpath("/entry/activity:object/id", entry),
|
2017-05-10 18:46:23 +02:00
|
|
|
{:ok, followed} <- OStatus.find_or_make_user(followed_uri),
|
|
|
|
{:ok, activity} <- ActivityPub.follow(actor, followed, id, false) do
|
|
|
|
User.follow(actor, followed)
|
|
|
|
{:ok, activity}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|