diff options
author | lambda <pleromagit@rogerbraun.net> | 2018-03-08 12:29:02 +0000 |
---|---|---|
committer | lambda <pleromagit@rogerbraun.net> | 2018-03-08 12:29:02 +0000 |
commit | 460062f2b04220ffcd8f20aa842cc95582d1f849 (patch) | |
tree | f56c298bed6b289aa2dd81766862265ccef05947 /lib/pleroma/web/common_api/utils.ex | |
parent | 0f2bf3eefb0adba13a3f3d37e8d8b1bd414a33e4 (diff) | |
parent | 611ca385dea3d611a97579000311cc42684305e6 (diff) | |
download | pleroma-460062f2b04220ffcd8f20aa842cc95582d1f849.tar.gz |
Merge branch 'feature/activitypub' into 'develop'
Feature/activitypub
See merge request pleroma/pleroma!67
Diffstat (limited to 'lib/pleroma/web/common_api/utils.ex')
-rw-r--r-- | lib/pleroma/web/common_api/utils.ex | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index 2b359dd72..75c63e5f4 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -24,17 +24,34 @@ defmodule Pleroma.Web.CommonAPI.Utils do end) end - def to_for_user_and_mentions(user, mentions, inReplyTo) do - default_to = [ - user.follower_address, - "https://www.w3.org/ns/activitystreams#Public" - ] + def to_for_user_and_mentions(user, mentions, inReplyTo, "public") do + to = ["https://www.w3.org/ns/activitystreams#Public"] - to = default_to ++ Enum.map(mentions, fn ({_, %{ap_id: ap_id}}) -> ap_id end) + mentioned_users = Enum.map(mentions, fn ({_, %{ap_id: ap_id}}) -> ap_id end) + cc = [user.follower_address | mentioned_users] if inReplyTo do - Enum.uniq([inReplyTo.data["actor"] | to]) + {to, Enum.uniq([inReplyTo.data["actor"] | cc])} else - to + {to, cc} + end + end + + def to_for_user_and_mentions(user, mentions, inReplyTo, "unlisted") do + {to, cc} = to_for_user_and_mentions(user, mentions, inReplyTo, "public") + {cc, to} + end + + def to_for_user_and_mentions(user, mentions, inReplyTo, "private") do + {to, cc} = to_for_user_and_mentions(user, mentions, inReplyTo, "direct") + {[user.follower_address | to], cc} + end + + def to_for_user_and_mentions(user, mentions, inReplyTo, "direct") do + mentioned_users = Enum.map(mentions, fn ({_, %{ap_id: ap_id}}) -> ap_id end) + if inReplyTo do + {Enum.uniq([inReplyTo.data["actor"] | mentioned_users]), []} + else + {mentioned_users, []} end end @@ -99,10 +116,11 @@ defmodule Pleroma.Web.CommonAPI.Utils do end) end - def make_note_data(actor, to, context, content_html, attachments, inReplyTo, tags, cw \\ nil) do + def make_note_data(actor, to, context, content_html, attachments, inReplyTo, tags, cw \\ nil, cc \\ []) do object = %{ "type" => "Note", "to" => to, + "cc" => cc, "content" => content_html, "summary" => cw, "context" => context, |