X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Factivity_pub%2Factivity_pub.ex;h=2470b4a710dfefc67e2b4dbe3f2b6e283005c301;hb=3cc2554fa3d63ba22dc5f598229a02b928b9fd14;hp=779ee139b0984bc71d75cd8e91a0c89fb1f81e54;hpb=c8f31e0bc2764c924a4045e007e828052c837ac2;p=akkoma diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 779ee139b..2470b4a71 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -370,20 +370,38 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do content: content } = params ) do - additional = params[:additional] || %{} - # only accept false as false value local = !(params[:local] == false) + forward = !(params[:forward] == false) + + additional = params[:additional] || %{} - %{ + params = %{ actor: actor, context: context, account: account, statuses: statuses, content: content } - |> make_flag_data(additional) - |> insert(local) + + additional = + if forward do + Map.merge(additional, %{"to" => [], "cc" => [account.ap_id]}) + else + 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 def fetch_activities_for_context(context, opts \\ %{}) do @@ -679,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( @@ -706,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 @@ -951,17 +982,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do entire_thread_visible_for_user?(activity, user) end - # filter out muted threads - def contain_muted_boosts(%Activity{data: %{"type" => "Announce"}} = activity, %User{} = user) do - id = User.get_by_ap_id(activity.actor).id - id not in user.info.muted_reblogs - end - - def contain_muted_boosts(%Activity{} = _activity, %User{} = _user), do: true - # do post-processing on a specific activity def contain_activity(%Activity{} = activity, %User{} = user) do - contain_broken_threads(activity, user) and contain_muted_boosts(activity, user) + contain_broken_threads(activity, user) end # do post-processing on a timeline