diff options
author | William Pitcock <nenolod@dereferenced.org> | 2018-08-29 08:37:36 +0000 |
---|---|---|
committer | William Pitcock <nenolod@dereferenced.org> | 2018-08-29 08:42:33 +0000 |
commit | 81673b81366ee1779802a9fec7f5119e664cd8ce (patch) | |
tree | 673d70b7b30e6b72ab4dbc0e36569098503c6f6d /lib | |
parent | 0fd2eaf7afbbe557f56d4aa781f83fb8289316a1 (diff) | |
download | pleroma-81673b81366ee1779802a9fec7f5119e664cd8ce.tar.gz |
activity: add recipients_to and recipients_cc fields
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/activity.ex | 2 | ||||
-rw-r--r-- | lib/pleroma/web/activity_pub/activity_pub.ex | 21 |
2 files changed, 18 insertions, 5 deletions
diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex index bed96861f..4f1f8292d 100644 --- a/lib/pleroma/activity.ex +++ b/lib/pleroma/activity.ex @@ -8,6 +8,8 @@ defmodule Pleroma.Activity do field(:local, :boolean, default: true) field(:actor, :string) field(:recipients, {:array, :string}) + field(:recipients_to, {:array, :string}) + field(:recipients_cc, {:array, :string}) has_many(:notifications, Notification, on_delete: :delete_all) timestamps() diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 68b398786..fdbd7fed0 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -14,8 +14,10 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do # For Announce activities, we filter the recipients based on following status for any actors # that match actual users. See issue #164 for more information about why this is necessary. - def get_recipients(%{"type" => "Announce"} = data) do - recipients = (data["to"] || []) ++ (data["cc"] || []) + defp get_recipients(%{"type" => "Announce"} = data) do + to = data["to"] || [] + cc = data["cc"] || [] + recipients = to ++ cc actor = User.get_cached_by_ap_id(data["actor"]) recipients @@ -28,10 +30,15 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do User.following?(user, actor) end end) + + {recipients, to, cc} end - def get_recipients(data) do - (data["to"] || []) ++ (data["cc"] || []) + defp get_recipients(data) do + to = data["to"] || [] + cc = data["cc"] || [] + recipients = to ++ cc + {recipients, to, cc} end defp check_actor_is_active(actor) do @@ -53,12 +60,16 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do :ok <- check_actor_is_active(map["actor"]), {:ok, map} <- MRF.filter(map), :ok <- insert_full_object(map) do + {recipients, recipients_to, recipients_cc} = get_recipients(map) + {:ok, activity} = Repo.insert(%Activity{ data: map, local: local, actor: map["actor"], - recipients: get_recipients(map) + recipients: recipients, + recipients_to: recipients_to, + recipients_cc: recipients_cc }) Notification.create_notifications(activity) |