به Nostr بپیوندید
2024-09-06 15:54:28 UTC

Blurry Moon on Nostr: Anyway here's the MRF for eliminating ReplyGuy spam so you don't have to resort to ...

Anyway here's the MRF for eliminating ReplyGuy spam so you don't have to resort to tricks:

```
# Copyright © 2024 Moon Man
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Web.ActivityPub.MRF.ReplyGuySpam do
alias Pleroma.User

@behaviour Pleroma.Web.ActivityPub.MRF.Policy

require Logger

@impl true
def history_awareness, do: :auto

@impl true
def filter(
%{
"type" => "Create",
"actor" => actor_id,
"object" => %{
"type" => "Note"
}
} = activity
) do
with %User{:name => name, :nickname => "npub" <> _} <-
User.get_cached_by_ap_id(actor_id),
true <- String.contains?(String.downcase(name), "replyguy") do
Logger.info("Dropping Nostr replyguy spam")
{:reject, activity}
else
_ ->
# pass through
{:ok, activity}
end
end

@impl true
def filter(activity = %{}), do: {:ok, activity}

@impl true
def describe, do: {:ok, %{}}
end
```