commit: cab6372d7a1bdf50436eff1b4023fd6e05586dbc
parent 0d092a3d4fd89a7f8df30f080087bd24ce53c597
Author: Mark Felder <feld@feld.me>
Date: Mon, 27 May 2024 12:31:29 -0400
Make user age limit configurable
Switch to milliseconds for consistency with other configuration options in codebase
Diffstat:
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/config/config.exs b/config/config.exs
@@ -430,6 +430,8 @@ config :pleroma, :mrf_force_mention,
mention_parent: true,
mention_quoted: true
+config :pleroma, :mrf_antimentionspam, user_age_limit: 30_000
+
config :pleroma, :rich_media,
enabled: true,
ignore_hosts: [],
diff --git a/lib/pleroma/web/activity_pub/mrf/anti_mention_spam_policy.ex b/lib/pleroma/web/activity_pub/mrf/anti_mention_spam_policy.ex
@@ -3,6 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.MRF.AntiMentionSpamPolicy do
+ alias Pleroma.Config
alias Pleroma.User
require Pleroma.Constants
@@ -11,8 +12,9 @@ defmodule Pleroma.Web.ActivityPub.MRF.AntiMentionSpamPolicy do
defp user_has_posted?(%User{} = u), do: u.note_count > 0
defp user_has_age?(%User{} = u) do
- diff = NaiveDateTime.utc_now() |> NaiveDateTime.diff(u.inserted_at, :second)
- diff >= :timer.seconds(30)
+ user_age_limit = Config.get([:mrf_antimentionspam, :user_age_limit], 30_000)
+ diff = NaiveDateTime.utc_now() |> NaiveDateTime.diff(u.inserted_at, :millisecond)
+ diff >= user_age_limit
end
defp good_reputation?(%User{} = u) do