summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authortusooa <tusooa@kazv.moe>2023-11-06 19:59:05 -0500
committertusooa <tusooa@kazv.moe>2023-12-27 12:28:04 -0500
commit5459bbc1efabc373e5619990be8d811df072e5e6 (patch)
tree1ede6418bc9ce2bf81326af03c0849420f4dff5d /lib
parent7a58ddfa486048d17fa653662914e0f02d11fadb (diff)
downloadpleroma-5459bbc1efabc373e5619990be8d811df072e5e6.tar.gz
pleroma-5459bbc1efabc373e5619990be8d811df072e5e6.zip
Allow group actors to boost posts
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub.ex1
-rw-r--r--lib/pleroma/web/activity_pub/side_effects.ex2
-rw-r--r--lib/pleroma/web/activity_pub/utils.ex17
3 files changed, 20 insertions, 0 deletions
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex
index 32d1a1037..3b0140d96 100644
--- a/lib/pleroma/web/activity_pub/activity_pub.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub.ex
@@ -319,6 +319,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
{:ok, _actor} <- update_last_status_at_if_public(actor, activity),
_ <- notify_and_stream(activity),
:ok <- maybe_schedule_poll_notifications(activity),
+ :ok <- maybe_handle_group_posts(activity),
:ok <- maybe_federate(activity) do
{:ok, activity}
else
diff --git a/lib/pleroma/web/activity_pub/side_effects.ex b/lib/pleroma/web/activity_pub/side_effects.ex
index 10f268f05..59b19180d 100644
--- a/lib/pleroma/web/activity_pub/side_effects.ex
+++ b/lib/pleroma/web/activity_pub/side_effects.ex
@@ -233,6 +233,8 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
Pleroma.Search.add_to_index(Map.put(activity, :object, object))
+ Utils.maybe_handle_group_posts(activity)
+
meta =
meta
|> add_notifications(notifications)
diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex
index b32f19740..e4edbd5ee 100644
--- a/lib/pleroma/web/activity_pub/utils.ex
+++ b/lib/pleroma/web/activity_pub/utils.ex
@@ -935,4 +935,21 @@ defmodule Pleroma.Web.ActivityPub.Utils do
|> where([a, object: o], fragment("(?)->>'type' = 'Answer'", o.data))
|> Repo.all()
end
+
+ def maybe_handle_group_posts(activity) do
+ mentions =
+ activity.data["to"]
+ |> Enum.filter(&(&1 != activity.actor))
+
+ mentioned_local_groups =
+ User.get_all_by_ap_id(mentions)
+ |> Enum.filter(&(&1.actor_type == "Group" and &1.local))
+
+ mentioned_local_groups
+ |> Enum.each(fn group ->
+ Pleroma.Web.CommonAPI.repeat(activity.id, group)
+ end)
+
+ :ok
+ end
end