aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHaelwenn <contact+git.pleroma.social@hacktivis.me>2021-06-03 15:52:16 +0000
committerHaelwenn <contact+git.pleroma.social@hacktivis.me>2021-06-03 15:52:16 +0000
commita5dce42c85de2d8316541348335d1dd49c2c3d89 (patch)
treebcf672834f483bcde205c1e1487d09f46c759588 /lib
parent194a41611beac74502723b440e2ffff4231b238a (diff)
parentdcf84ac12e830ebc17f63e2fea0bd47c75e9f981 (diff)
downloadpleroma-a5dce42c85de2d8316541348335d1dd49c2c3d89.tar.gz
Merge branch 'chore/rename-chat' into 'develop'
Rename the non-federating Chat feature to Shout See merge request pleroma/pleroma!2842
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/application.ex10
-rw-r--r--lib/pleroma/config/transfer_task.ex2
-rw-r--r--lib/pleroma/web/channels/user_socket.ex4
-rw-r--r--lib/pleroma/web/mastodon_api/views/instance_view.ex8
-rw-r--r--lib/pleroma/web/shout_channel.ex (renamed from lib/pleroma/web/chat_channel.ex)12
5 files changed, 20 insertions, 16 deletions
diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex
index f4d22373a..9824e0a4a 100644
--- a/lib/pleroma/application.ex
+++ b/lib/pleroma/application.ex
@@ -102,7 +102,7 @@ defmodule Pleroma.Application do
] ++
task_children(@mix_env) ++
dont_run_in_test(@mix_env) ++
- chat_child(chat_enabled?()) ++
+ shout_child(shout_enabled?()) ++
[Pleroma.Gopher.Server]
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
@@ -216,7 +216,7 @@ defmodule Pleroma.Application do
type: :worker
}
- defp chat_enabled?, do: Config.get([:chat, :enabled])
+ defp shout_enabled?, do: Config.get([:shout, :enabled])
defp dont_run_in_test(env) when env in [:test, :benchmark], do: []
@@ -237,14 +237,14 @@ defmodule Pleroma.Application do
]
end
- defp chat_child(true) do
+ defp shout_child(true) do
[
- Pleroma.Web.ChatChannel.ChatChannelState,
+ Pleroma.Web.ShoutChannel.ShoutChannelState,
{Phoenix.PubSub, [name: Pleroma.PubSub, adapter: Phoenix.PubSub.PG2]}
]
end
- defp chat_child(_), do: []
+ defp shout_child(_), do: []
defp task_children(:test) do
[
diff --git a/lib/pleroma/config/transfer_task.ex b/lib/pleroma/config/transfer_task.ex
index 1e3ae82d0..d5c6081a2 100644
--- a/lib/pleroma/config/transfer_task.ex
+++ b/lib/pleroma/config/transfer_task.ex
@@ -16,7 +16,7 @@ defmodule Pleroma.Config.TransferTask do
defp reboot_time_keys,
do: [
{:pleroma, :hackney_pools},
- {:pleroma, :chat},
+ {:pleroma, :shout},
{:pleroma, Oban},
{:pleroma, :rate_limit},
{:pleroma, :markup},
diff --git a/lib/pleroma/web/channels/user_socket.ex b/lib/pleroma/web/channels/user_socket.ex
index 1c09b6768..043206835 100644
--- a/lib/pleroma/web/channels/user_socket.ex
+++ b/lib/pleroma/web/channels/user_socket.ex
@@ -8,7 +8,7 @@ defmodule Pleroma.Web.UserSocket do
## Channels
# channel "room:*", Pleroma.Web.RoomChannel
- channel("chat:*", Pleroma.Web.ChatChannel)
+ channel("chat:*", Pleroma.Web.ShoutChannel)
# Socket params are passed from the client and can
# be used to verify and authenticate a user. After
@@ -22,7 +22,7 @@ defmodule Pleroma.Web.UserSocket do
# See `Phoenix.Token` documentation for examples in
# performing token verification on connect.
def connect(%{"token" => token}, socket) do
- with true <- Pleroma.Config.get([:chat, :enabled]),
+ with true <- Pleroma.Config.get([:shout, :enabled]),
{:ok, user_id} <- Phoenix.Token.verify(socket, "user socket", token, max_age: 84_600),
%User{} = user <- Pleroma.User.get_cached_by_id(user_id) do
{:ok, assign(socket, :user_name, user.nickname)}
diff --git a/lib/pleroma/web/mastodon_api/views/instance_view.ex b/lib/pleroma/web/mastodon_api/views/instance_view.ex
index 005705d97..3528185d5 100644
--- a/lib/pleroma/web/mastodon_api/views/instance_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/instance_view.ex
@@ -37,7 +37,7 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do
background_upload_limit: Keyword.get(instance, :background_upload_limit),
banner_upload_limit: Keyword.get(instance, :banner_upload_limit),
background_image: Pleroma.Web.Endpoint.url() <> Keyword.get(instance, :background_image),
- chat_limit: Keyword.get(instance, :chat_limit),
+ shout_limit: Config.get([:shout, :limit]),
description_limit: Keyword.get(instance, :description_limit),
pleroma: %{
metadata: %{
@@ -69,9 +69,13 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do
if Config.get([:gopher, :enabled]) do
"gopher"
end,
- if Config.get([:chat, :enabled]) do
+ # backwards compat
+ if Config.get([:shout, :enabled]) do
"chat"
end,
+ if Config.get([:shout, :enabled]) do
+ "shout"
+ end,
if Config.get([:instance, :allow_relay]) do
"relay"
end,
diff --git a/lib/pleroma/web/chat_channel.ex b/lib/pleroma/web/shout_channel.ex
index 4008129e9..17caecb1a 100644
--- a/lib/pleroma/web/chat_channel.ex
+++ b/lib/pleroma/web/shout_channel.ex
@@ -2,12 +2,12 @@
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
-defmodule Pleroma.Web.ChatChannel do
+defmodule Pleroma.Web.ShoutChannel do
use Phoenix.Channel
alias Pleroma.User
- alias Pleroma.Web.ChatChannel.ChatChannelState
alias Pleroma.Web.MastodonAPI.AccountView
+ alias Pleroma.Web.ShoutChannel.ShoutChannelState
def join("chat:public", _message, socket) do
send(self(), :after_join)
@@ -15,18 +15,18 @@ defmodule Pleroma.Web.ChatChannel do
end
def handle_info(:after_join, socket) do
- push(socket, "messages", %{messages: ChatChannelState.messages()})
+ push(socket, "messages", %{messages: ShoutChannelState.messages()})
{:noreply, socket}
end
def handle_in("new_msg", %{"text" => text}, %{assigns: %{user_name: user_name}} = socket) do
text = String.trim(text)
- if String.length(text) in 1..Pleroma.Config.get([:instance, :chat_limit]) do
+ if String.length(text) in 1..Pleroma.Config.get([:shout, :limit]) do
author = User.get_cached_by_nickname(user_name)
author_json = AccountView.render("show.json", user: author, skip_visibility_check: true)
- message = ChatChannelState.add_message(%{text: text, author: author_json})
+ message = ShoutChannelState.add_message(%{text: text, author: author_json})
broadcast!(socket, "new_msg", message)
end
@@ -35,7 +35,7 @@ defmodule Pleroma.Web.ChatChannel do
end
end
-defmodule Pleroma.Web.ChatChannel.ChatChannelState do
+defmodule Pleroma.Web.ShoutChannel.ShoutChannelState do
use Agent
@max_messages 20