diff options
author | Roman Chvanikov <chvanikoff@pm.me> | 2019-06-29 00:52:50 +0300 |
---|---|---|
committer | Roman Chvanikov <chvanikoff@pm.me> | 2019-06-29 00:52:50 +0300 |
commit | 657277ffc0d3d25be4376ed629057a2d2cefb2e1 (patch) | |
tree | 3fdd4ca236669df9b2afc5bfcd0e5d6002e23666 /lib/pleroma/web/common_api/utils.ex | |
parent | c0fa0001476a8a45878a0c75125627164497eddf (diff) | |
parent | c6668c2e7b9908e479527914ca7eb2c838aaab06 (diff) | |
download | pleroma-657277ffc0d3d25be4376ed629057a2d2cefb2e1.tar.gz |
Resolve conflicts
Diffstat (limited to 'lib/pleroma/web/common_api/utils.ex')
-rw-r--r-- | lib/pleroma/web/common_api/utils.ex | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index 6d82c0bd2..8b9477927 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -504,4 +504,18 @@ defmodule Pleroma.Web.CommonAPI.Utils do "inReplyTo" => object.data["id"] } end + + def validate_character_limit(full_payload, attachments, limit) do + length = String.length(full_payload) + + if length < limit do + if length > 0 or Enum.count(attachments) > 0 do + :ok + else + {:error, "Cannot post an empty status without attachments"} + end + else + {:error, "The status is over the character limit"} + end + end end |