aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2020-04-20 12:08:47 +0200
committerlain <lain@soykaf.club>2020-04-20 12:08:47 +0200
commit5b6818b3e5dc39e328f6f8d4b8f4587e5e1cef94 (patch)
treefdda33fa406fc12e4fac23f285ed4a8af04e5083 /lib
parentce23673ca1539350802326c62d6e72bd040950f6 (diff)
downloadpleroma-5b6818b3e5dc39e328f6f8d4b8f4587e5e1cef94.tar.gz
CommonAPI: Obey local limit for chat messages.
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/common_api/common_api.ex8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex
index 2b8add2fa..fcb0af4e8 100644
--- a/lib/pleroma/web/common_api/common_api.ex
+++ b/lib/pleroma/web/common_api/common_api.ex
@@ -28,7 +28,10 @@ defmodule Pleroma.Web.CommonAPI do
def post_chat_message(%User{} = user, %User{} = recipient, content) do
transaction =
Repo.transaction(fn ->
- with {_, {:ok, chat_message_data, _meta}} <-
+ with {_, true} <-
+ {:content_length,
+ String.length(content) <= Pleroma.Config.get([:instance, :chat_limit])},
+ {_, {:ok, chat_message_data, _meta}} <-
{:build_object,
Builder.chat_message(
user,
@@ -43,6 +46,9 @@ defmodule Pleroma.Web.CommonAPI do
{_, {:ok, %Activity{} = activity, _meta}} <-
{:common_pipeline, Pipeline.common_pipeline(create_activity_data, local: true)} do
{:ok, activity}
+ else
+ {:content_length, false} -> {:error, :content_too_long}
+ e -> e
end
end)