summaryrefslogtreecommitdiff
path: root/lib/pleroma/web/common_api/utils.ex
diff options
context:
space:
mode:
authorAlex Gleason <alex@alexgleason.me>2022-02-09 11:14:30 -0600
committerAlex Gleason <alex@alexgleason.me>2022-02-09 11:14:30 -0600
commitc735444f3803a8cff15c1a4aaee82b821ef27441 (patch)
tree506fb60d08c6daa1dd73384eb31a919d9fcd2f65 /lib/pleroma/web/common_api/utils.ex
parent11f03344d385de78e79e35ccfe8c980f9f6e32b3 (diff)
parentfa8e2ffa3f493d5b2911507b0ac06094615e9d8f (diff)
Merge remote-tracking branch 'origin/develop' into operation-warpsneedoperation-warpsneed
Diffstat (limited to 'lib/pleroma/web/common_api/utils.ex')
-rw-r--r--lib/pleroma/web/common_api/utils.ex15
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