Don't add public recipient to notes that don't contain it.
This commit is contained in:
parent
d8bbbeb03a
commit
fc7016a88c
2 changed files with 45 additions and 2 deletions
|
@ -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
|
||||
|
|
27
test/fixtures/dm.xml
vendored
Normal file
27
test/fixtures/dm.xml
vendored
Normal file
|
@ -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"><p><span class="h-card"><a href="https://pleroma.soykaf.com/users/lain" class="u-url mention">@<span>lain</span></a></span> Hey.</p></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>
|
Loading…
Reference in a new issue