unfollow_handler.ex (848B)
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.UnfollowHandler do 6 alias Pleroma.User 7 alias Pleroma.Web.ActivityPub.ActivityPub 8 alias Pleroma.Web.OStatus 9 alias Pleroma.Web.XML 10 11 def handle(entry, doc) do 12 with {:ok, actor} <- OStatus.find_make_or_update_actor(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.unfollow(actor, followed, id, false) do 18 User.unfollow(actor, followed) 19 {:ok, activity} 20 end 21 end 22 end