diff options
author | Alex Gleason <alex@alexgleason.me> | 2022-02-06 18:25:14 +0000 |
---|---|---|
committer | Alex Gleason <alex@alexgleason.me> | 2022-02-06 18:25:14 +0000 |
commit | fa8e2ffa3f493d5b2911507b0ac06094615e9d8f (patch) | |
tree | 34686c246e9517ae9018175ffee93804935d59c0 /lib/pleroma/web/common_api/utils.ex | |
parent | 60deddb7e5b8bb10037cca6e6f11a5bbef298d39 (diff) | |
parent | e473bcf7a0390584377d89ff68267a25fe31e44d (diff) | |
download | pleroma-fa8e2ffa3f493d5b2911507b0ac06094615e9d8f.tar.gz |
Merge branch 'max_media_attachments' into 'develop'
Allow specifying max media attachment count
Closes #2665
See merge request pleroma/pleroma!3630
Diffstat (limited to 'lib/pleroma/web/common_api/utils.ex')
-rw-r--r-- | lib/pleroma/web/common_api/utils.ex | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index b6feaf32a..5bba01cc4 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -492,4 +492,19 @@ defmodule Pleroma.Web.CommonAPI.Utils do {:error, dgettext("errors", "The status is over the character limit")} end end + + def validate_attachments_count([] = _attachments) do + :ok + end + + def validate_attachments_count(attachments) do + limit = Config.get([:instance, :max_media_attachments]) + count = length(attachments) + + if count <= limit do + :ok + else + {:error, dgettext("errors", "Too many attachments")} + end + end end |