Make user age limit configurable

Switch to milliseconds for consistency with other configuration options in codebase
This commit is contained in:
Mark Felder 2024-05-27 12:31:29 -04:00
parent 0d092a3d4f
commit cab6372d7a
2 changed files with 6 additions and 2 deletions

View File

@ -430,6 +430,8 @@ config :pleroma, :mrf_force_mention,
mention_parent: true, mention_parent: true,
mention_quoted: true mention_quoted: true
config :pleroma, :mrf_antimentionspam, user_age_limit: 30_000
config :pleroma, :rich_media, config :pleroma, :rich_media,
enabled: true, enabled: true,
ignore_hosts: [], ignore_hosts: [],

View File

@ -3,6 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only # SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.MRF.AntiMentionSpamPolicy do defmodule Pleroma.Web.ActivityPub.MRF.AntiMentionSpamPolicy do
alias Pleroma.Config
alias Pleroma.User alias Pleroma.User
require Pleroma.Constants 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_posted?(%User{} = u), do: u.note_count > 0
defp user_has_age?(%User{} = u) do defp user_has_age?(%User{} = u) do
diff = NaiveDateTime.utc_now() |> NaiveDateTime.diff(u.inserted_at, :second) user_age_limit = Config.get([:mrf_antimentionspam, :user_age_limit], 30_000)
diff >= :timer.seconds(30) diff = NaiveDateTime.utc_now() |> NaiveDateTime.diff(u.inserted_at, :millisecond)
diff >= user_age_limit
end end
defp good_reputation?(%User{} = u) do defp good_reputation?(%User{} = u) do