aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/common_api/common_api.ex
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2019-06-18 05:05:05 +0300
committerrinpatch <rinpatch@sdf.org>2019-06-18 05:05:05 +0300
commitc4e4f7d0e48ca09003984fb75166ec3cca0b8634 (patch)
treed551cdc5964ba2c4d80a11b8995444a744c91fd5 /lib/pleroma/web/common_api/common_api.ex
parentdce27de7337214618559d96093e0aa3068874f4a (diff)
downloadpleroma-c4e4f7d0e48ca09003984fb75166ec3cca0b8634.tar.gz
Add proper error handling for when the post exceeds character limits
Diffstat (limited to 'lib/pleroma/web/common_api/common_api.ex')
-rw-r--r--lib/pleroma/web/common_api/common_api.ex3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex
index f5193512e..42b78494d 100644
--- a/lib/pleroma/web/common_api/common_api.ex
+++ b/lib/pleroma/web/common_api/common_api.ex
@@ -212,7 +212,7 @@ defmodule Pleroma.Web.CommonAPI do
cw <- data["spoiler_text"] || "",
sensitive <- data["sensitive"] || Enum.member?(tags, {"#nsfw", "nsfw"}),
full_payload <- String.trim(status <> cw),
- length when length in 1..limit <- String.length(full_payload),
+ :ok <- validate_character_limit(full_payload, attachments, limit),
object <-
make_note_data(
user.ap_id,
@@ -247,6 +247,7 @@ defmodule Pleroma.Web.CommonAPI do
res
else
+ {:error, _} = e -> e
e -> {:error, e}
end
end