2018-12-23 13:04:54 -07:00
|
|
|
# Pleroma: A lightweight social networking server
|
2018-12-31 08:41:47 -07:00
|
|
|
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
2018-12-23 13:04:54 -07:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2018-05-21 02:36:20 -06:00
|
|
|
defmodule Pleroma.Web.OStatus.UnfollowHandler do
|
2019-02-09 08:16:26 -07:00
|
|
|
alias Pleroma.Web.XML
|
|
|
|
alias Pleroma.Web.OStatus
|
2018-05-21 02:36:20 -06:00
|
|
|
alias Pleroma.Web.ActivityPub.ActivityPub
|
|
|
|
alias Pleroma.User
|
|
|
|
|
|
|
|
def handle(entry, doc) do
|
|
|
|
with {:ok, actor} <- OStatus.find_make_or_update_user(doc),
|
|
|
|
id when not is_nil(id) <- XML.string_from_xpath("/entry/id", entry),
|
|
|
|
followed_uri when not is_nil(followed_uri) <-
|
|
|
|
XML.string_from_xpath("/entry/activity:object/id", entry),
|
|
|
|
{:ok, followed} <- OStatus.find_or_make_user(followed_uri),
|
|
|
|
{:ok, activity} <- ActivityPub.unfollow(actor, followed, id, false) do
|
|
|
|
User.unfollow(actor, followed)
|
|
|
|
{:ok, activity}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|