transmogrifier: upgrade: when upgrading OStatus users to AP, ensure we always use...
[akkoma] / lib / pleroma / web / activity_pub / activity_pub.ex
index 7d21fe65f7ff4c0ee588495cd1328a7dcba8daf3..2470b4a710dfefc67e2b4dbe3f2b6e283005c301 100644 (file)
@@ -388,12 +388,18 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
       if forward do
         Map.merge(additional, %{"to" => [], "cc" => [account.ap_id]})
       else
-        additional
+        Map.merge(additional, %{"to" => [], "cc" => []})
       end
 
     with flag_data <- make_flag_data(params, additional),
          {:ok, activity} <- insert(flag_data, local),
          :ok <- maybe_federate(activity) do
+      Enum.each(User.all_superusers(), fn superuser ->
+        superuser
+        |> Pleroma.AdminEmail.report(actor, account, statuses, content)
+        |> Pleroma.Mailer.deliver_async()
+      end)
+
       {:ok, activity}
     end
   end
@@ -691,6 +697,18 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
 
   defp restrict_pinned(query, _), do: query
 
+  defp restrict_muted_reblogs(query, %{"muting_user" => %User{info: info}}) do
+    muted_reblogs = info.muted_reblogs || []
+
+    from(
+      activity in query,
+      where: fragment("not ?->>'type' = 'Announce'", activity.data),
+      where: fragment("not ? = ANY(?)", activity.actor, ^muted_reblogs)
+    )
+  end
+
+  defp restrict_muted_reblogs(query, _), do: query
+
   def fetch_activities_query(recipients, opts \\ %{}) do
     base_query =
       from(
@@ -718,6 +736,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
     |> restrict_replies(opts)
     |> restrict_reblogs(opts)
     |> restrict_pinned(opts)
+    |> restrict_muted_reblogs(opts)
   end
 
   def fetch_activities(recipients, opts \\ %{}) do