logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma
commit: fc7016a88c483701ab8eb4ecf7a3fbc5af3810d9
parent: d8bbbeb03abfd0cc26f7bb46ff2788f8ff3c4ed3
Author: Roger Braun <roger@rogerbraun.net>
Date:   Fri, 30 Jun 2017 15:54:32 +0200

Don't add public recipient to notes that don't contain it.

Diffstat:

Mlib/pleroma/web/ostatus/handlers/note_handler.ex20++++++++++++++++++--
Atest/fixtures/dm.xml27+++++++++++++++++++++++++++
2 files changed, 45 insertions(+), 2 deletions(-)

diff --git 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 @@ -0,0 +1,27 @@ +<?xml version="1.0"?> +<entry xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:poco="http://portablecontacts.net/spec/1.0" xmlns:media="http://purl.org/syndication/atommedia" xmlns:ostatus="http://ostatus.org/schema/1.0" xmlns:mastodon="http://mastodon.social/schema/1.0"> + <id>tag:mastodon.social,2017-06-30:objectId=11260427:objectType=Status</id> + <published>2017-06-30T13:27:47Z</published> + <updated>2017-06-30T13:27:47Z</updated> + <title>New status by lambadalambda</title> + <author> + <id>https://mastodon.social/users/lambadalambda</id> + <activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type> + <uri>https://mastodon.social/users/lambadalambda</uri> + <name>lambadalambda</name> + <email>lambadalambda@mastodon.social</email> + <link rel="alternate" type="text/html" href="https://mastodon.social/@lambadalambda"/> + <link rel="avatar" type="image/gif" media:width="120" media:height="120" href="https://files.mastodon.social/accounts/avatars/000/000/264/original/1429214160519.gif"/> + <poco:preferredUsername>lambadalambda</poco:preferredUsername> + <poco:displayName>Critical Value</poco:displayName> + <mastodon:scope>public</mastodon:scope> + </author> + <activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type> + <activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb> + <content type="html" xml:lang="ky">&lt;p&gt;&lt;span class="h-card"&gt;&lt;a href="https://pleroma.soykaf.com/users/lain" class="u-url mention"&gt;@&lt;span&gt;lain&lt;/span&gt;&lt;/a&gt;&lt;/span&gt; Hey.&lt;/p&gt;</content> + <link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://pleroma.soykaf.com/users/lain"/> + <mastodon:scope>direct</mastodon:scope> + <link rel="alternate" type="text/html" href="https://mastodon.social/users/lambadalambda/updates/3514345"/> + <link rel="self" type="application/atom+xml" href="https://mastodon.social/users/lambadalambda/updates/3514345.atom"/> + <ostatus:conversation ref="tag:mastodon.social,2017-06-30:objectId=4009714:objectType=Conversation"/> +</entry>