diff options
author | Haelwenn <contact+git.pleroma.social@hacktivis.me> | 2020-07-07 03:00:52 +0000 |
---|---|---|
committer | Haelwenn <contact+git.pleroma.social@hacktivis.me> | 2020-07-07 03:00:52 +0000 |
commit | d81acb5f6250766eef1dc8c51ed0c79e819ae2af (patch) | |
tree | d54e27b8306f5323d434d54639ca38a5f9c874d5 /lib | |
parent | 2a323d37971d364fefd46e840424c631cc4a7d2b (diff) | |
parent | 58da575935f19b86c614717f4fe0d4b8508f395d (diff) | |
download | pleroma-d81acb5f6250766eef1dc8c51ed0c79e819ae2af.tar.gz |
Merge branch 'description-limits' into 'develop'
Add limits to image descriptions
See merge request pleroma/pleroma!2724
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/upload.ex | 9 | ||||
-rw-r--r-- | lib/pleroma/web/mastodon_api/views/instance_view.ex | 2 |
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/pleroma/upload.ex b/lib/pleroma/upload.ex index 797555bff..0fa6b89dc 100644 --- a/lib/pleroma/upload.ex +++ b/lib/pleroma/upload.ex @@ -63,6 +63,10 @@ defmodule Pleroma.Upload do with {:ok, upload} <- prepare_upload(upload, opts), upload = %__MODULE__{upload | path: upload.path || "#{upload.id}/#{upload.name}"}, {:ok, upload} <- Pleroma.Upload.Filter.filter(opts.filters, upload), + description = Map.get(opts, :description) || upload.name, + {_, true} <- + {:description_limit, + String.length(description) <= Pleroma.Config.get([:instance, :description_limit])}, {:ok, url_spec} <- Pleroma.Uploaders.Uploader.put_file(opts.uploader, upload) do {:ok, %{ @@ -75,9 +79,12 @@ defmodule Pleroma.Upload do "href" => url_from_spec(upload, opts.base_url, url_spec) } ], - "name" => Map.get(opts, :description) || upload.name + "name" => description }} else + {:description_limit, _} -> + {:error, :description_too_long} + {:error, error} -> Logger.error( "#{__MODULE__} store (using #{inspect(opts.uploader)}) failed: #{inspect(error)}" diff --git a/lib/pleroma/web/mastodon_api/views/instance_view.ex b/lib/pleroma/web/mastodon_api/views/instance_view.ex index 89e48fba5..5deb0d7ed 100644 --- a/lib/pleroma/web/mastodon_api/views/instance_view.ex +++ b/lib/pleroma/web/mastodon_api/views/instance_view.ex @@ -34,6 +34,8 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do background_upload_limit: Keyword.get(instance, :background_upload_limit), banner_upload_limit: Keyword.get(instance, :banner_upload_limit), background_image: Keyword.get(instance, :background_image), + chat_limit: Keyword.get(instance, :chat_limit), + description_limit: Keyword.get(instance, :description_limit), pleroma: %{ metadata: %{ account_activation_required: Keyword.get(instance, :account_activation_required), |