Hide pleroma:report for non-privileged users

Before we deleted the notifications, but that was a side effect and didn't always trigger any more.
Now we just hide them when an unprivileged user asks them.
This commit is contained in:
Ilja 2022-03-02 18:05:50 +01:00
commit eab13fed3e
2 changed files with 52 additions and 5 deletions

View file

@ -61,7 +61,18 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPI do
end
def get_notifications(user, params \\ %{}) do
options = cast_params(params)
options =
cast_params(params) |> Map.update(:include_types, [], fn include_types -> include_types end)
options =
if "pleroma:report" not in options.include_types or User.privileged?(user, :report_handle) do
options
else
options
|> Map.update(:exclude_types, ["pleroma:report"], fn current_exclude_types ->
current_exclude_types ++ ["pleroma:report"]
end)
end
user
|> Notification.for_user_query(options)