aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/common_api/utils.ex
diff options
context:
space:
mode:
authortusooa <tusooa@kazv.moe>2022-07-31 21:32:49 +0000
committertusooa <tusooa@kazv.moe>2022-07-31 21:32:49 +0000
commitc80096522cad1255f53e171359bc0266822c6441 (patch)
tree102a7e13b2e4c11af54e14a9ab0b3be216ce6013 /lib/pleroma/web/common_api/utils.ex
parent9a27cb4f9d314fe1066f566de71357f55926116e (diff)
parentb5266097a1e73bd749d8176e327c14fcb9735f95 (diff)
downloadpleroma-c80096522cad1255f53e171359bc0266822c6441.tar.gz
Merge branch 'develop' into 'from/develop/tusooa/emit-move'
# Conflicts: # CHANGELOG.md # test/pleroma/user_test.exs
Diffstat (limited to 'lib/pleroma/web/common_api/utils.ex')
-rw-r--r--lib/pleroma/web/common_api/utils.ex17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex
index b6feaf32a..ce850b038 100644
--- a/lib/pleroma/web/common_api/utils.ex
+++ b/lib/pleroma/web/common_api/utils.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.CommonAPI.Utils do
@@ -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