mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-06-10 09:19:34 +00:00
Compile the regex
This commit is contained in:
parent
879a94c755
commit
d2f8053552
|
@ -12,6 +12,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.AutoSubjectPolicy do
|
|||
require Pleroma.Constants
|
||||
require Logger
|
||||
|
||||
@trim_regex Regex.compile!("[.?!:;]+$")
|
||||
|
||||
@impl true
|
||||
def filter(%{"type" => "Create", "actor" => actor, "object" => _object} = message) do
|
||||
with {:ok, %User{local: true}} <- User.get_or_fetch_by_ap_id(actor),
|
||||
|
@ -84,7 +86,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.AutoSubjectPolicy do
|
|||
|> Enum.uniq()
|
||||
|
||||
defp trim_punct(wordlist) when is_list(wordlist),
|
||||
do: wordlist |> Enum.map(fn word -> String.replace(word, ~r/[.?!:;]+$/, "") end)
|
||||
do: wordlist |> Enum.map(fn word -> String.replace(word, @trim_regex, "") end)
|
||||
|
||||
@impl true
|
||||
def describe do
|
||||
|
|
Loading…
Reference in a new issue