From: Roger Braun Date: Fri, 30 Jun 2017 13:54:32 +0000 (+0200) Subject: Don't add public recipient to notes that don't contain it. X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=fc7016a88c483701ab8eb4ecf7a3fbc5af3810d9;p=akkoma Don't add public recipient to notes that don't contain it. --- diff --git a/lib/pleroma/web/ostatus/handlers/note_handler.ex b/lib/pleroma/web/ostatus/handlers/note_handler.ex index 82e60676f..e0e4afef6 100644 --- a/lib/pleroma/web/ostatus/handlers/note_handler.ex +++ b/lib/pleroma/web/ostatus/handlers/note_handler.ex @@ -37,14 +37,30 @@ defmodule Pleroma.Web.OStatus.NoteHandler do end end - def get_mentions(entry) do + def get_people_mentions(entry) do :xmerl_xpath.string('//link[@rel="mentioned" and @ostatus:object-type="http://activitystrea.ms/schema/1.0/person"]', entry) |> Enum.map(fn(person) -> XML.string_from_xpath("@href", person) end) end + def get_collection_mentions(entry) do + transmogrify = fn + ("http://activityschema.org/collection/public") -> + "https://www.w3.org/ns/activitystreams#Public" + (group) -> + group + end + + :xmerl_xpath.string('//link[@rel="mentioned" and @ostatus:object-type="http://activitystrea.ms/schema/1.0/collection"]', entry) + |> Enum.map(fn(collection) -> XML.string_from_xpath("@href", collection) |> transmogrify.() end) + end + + def get_mentions(entry) do + get_people_mentions(entry) + ++ get_collection_mentions(entry) + end + def make_to_list(actor, mentions) do [ - "https://www.w3.org/ns/activitystreams#Public", User.ap_followers(actor) ] ++ mentions end diff --git a/test/fixtures/dm.xml b/test/fixtures/dm.xml new file mode 100644 index 000000000..d0b8aa811 --- /dev/null +++ b/test/fixtures/dm.xml @@ -0,0 +1,27 @@ + + + tag:mastodon.social,2017-06-30:objectId=11260427:objectType=Status + 2017-06-30T13:27:47Z + 2017-06-30T13:27:47Z + New status by lambadalambda + + https://mastodon.social/users/lambadalambda + http://activitystrea.ms/schema/1.0/person + https://mastodon.social/users/lambadalambda + lambadalambda + lambadalambda@mastodon.social + + + lambadalambda + Critical Value + public + + http://activitystrea.ms/schema/1.0/note + http://activitystrea.ms/schema/1.0/post + <p><span class="h-card"><a href="https://pleroma.soykaf.com/users/lain" class="u-url mention">@<span>lain</span></a></span> Hey.</p> + + direct + + + +