Delete NotifyLocalUsersPolicy
This commit is contained in:
parent
a578626a9d
commit
8e1affa00a
|
@ -1,55 +0,0 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ActivityPub.MRF.NotifyLocalUsersPolicy do
|
||||
alias Pleroma.User
|
||||
@behaviour Pleroma.Web.ActivityPub.MRF
|
||||
@moduledoc "Notifies all local users by configurable tag in subject field (only for admins)"
|
||||
|
||||
require Pleroma.Constants
|
||||
|
||||
@impl true
|
||||
def filter(
|
||||
%{
|
||||
"type" => "Create",
|
||||
"to" => to,
|
||||
"actor" => actor,
|
||||
"object" => object
|
||||
} = message
|
||||
)
|
||||
when is_map(object) do
|
||||
user = User.get_cached_by_ap_id(actor)
|
||||
|
||||
if user.is_admin and object["inReplyTo"] == nil do
|
||||
tag = Pleroma.Config.get([:mrf_notifylocalusers, :tag])
|
||||
if object["summary"] == tag do
|
||||
ap_ids =
|
||||
User.Query.build(%{local: true, internal: false, deactivated: false})
|
||||
|> Pleroma.Repo.all()
|
||||
|> Enum.map(fn s -> s.ap_id end)
|
||||
to = to ++ ap_ids
|
||||
|
||||
object =
|
||||
object
|
||||
|> Map.put("to", to)
|
||||
|
||||
message =
|
||||
message
|
||||
|> Map.put("to", to)
|
||||
|> Map.put("object", object)
|
||||
{:ok, message}
|
||||
else
|
||||
{:ok, message}
|
||||
end
|
||||
else
|
||||
{:ok, message}
|
||||
end
|
||||
end
|
||||
|
||||
@impl true
|
||||
def filter(message), do: {:ok, message}
|
||||
|
||||
@impl true
|
||||
def describe, do: {:ok, %{}}
|
||||
end
|
Loading…
Reference in New Issue