Merge branch 'feature/1455-chat-character-limit' into 'develop'

Feature/1455 chat character limit

Closes #1455

See merge request pleroma/pleroma!2034
This commit is contained in:
rinpatch 2019-12-06 15:36:30 +00:00
commit 6cb31edd76
7 changed files with 42 additions and 3 deletions

View file

@ -147,8 +147,6 @@ defmodule Pleroma.Application do
defp oauth_cleanup_child(_), do: []
defp chat_child(:test, _), do: []
defp chat_child(_env, true) do
[Pleroma.Web.ChatChannel.ChatChannelState]
end

View file

@ -20,7 +20,7 @@ defmodule Pleroma.Web.ChatChannel do
def handle_in("new_msg", %{"text" => text}, %{assigns: %{user_name: user_name}} = socket) do
text = String.trim(text)
if String.length(text) > 0 do
if String.length(text) in 1..Pleroma.Config.get([:instance, :chat_limit]) do
author = User.get_cached_by_nickname(user_name)
author = Pleroma.Web.MastodonAPI.AccountView.render("show.json", user: author)
message = ChatChannelState.add_message(%{text: text, author: author})