Move is_good_locale_code? to object validator
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
c160ef7b6a
commit
b52d189fcc
5 changed files with 13 additions and 9 deletions
|
|
@ -10,6 +10,9 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do
|
|||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Web.CommonAPI.Utils
|
||||
|
||||
import Pleroma.EctoType.ActivityPub.ObjectValidators.LanguageCode,
|
||||
only: [is_good_locale_code?: 1]
|
||||
|
||||
import Pleroma.Web.Gettext
|
||||
|
||||
defstruct valid?: true,
|
||||
|
|
@ -195,7 +198,7 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do
|
|||
defp language(draft) do
|
||||
language = draft.params[:language]
|
||||
|
||||
if Utils.is_good_locale_code?(language) do
|
||||
if is_good_locale_code?(language) do
|
||||
%__MODULE__{draft | language: language}
|
||||
else
|
||||
draft
|
||||
|
|
|
|||
|
|
@ -494,8 +494,4 @@ defmodule Pleroma.Web.CommonAPI.Utils do
|
|||
{:error, dgettext("errors", "Too many attachments")}
|
||||
end
|
||||
end
|
||||
|
||||
def is_good_locale_code?(code) when is_binary(code), do: code =~ ~r<^[a-zA-Z0-9\-]+$>
|
||||
|
||||
def is_good_locale_code?(_code), do: false
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue