Resource fixes

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2022-03-31 10:41:38 +02:00
parent 9ab95efb08
commit 4c9065ce68
6 changed files with 79 additions and 26 deletions

View File

@@ -63,6 +63,10 @@ defmodule Mobilizon.Resources.Resource do
|> maybe_add_published_at()
|> validate_resource_or_folder()
|> validate_required(@required_attrs)
|> validate_length(:title, max: 200)
|> validate_length(:summary, max: 400)
|> validate_length(:resource_url, max: 400)
|> validate_length(:path, max: 500)
|> unique_constraint(:url, name: :resource_url_index)
end

View File

@@ -119,7 +119,11 @@ defmodule Mobilizon.Resources do
{:ok, resource}
{:error, operation, reason, _changes} ->
{:error, "Error while inserting resource when #{operation} because of #{inspect(reason)}"}
Logger.error(
"Error while inserting resource when #{operation} because of #{inspect(reason)}"
)
{:error, reason}
end
end