From 429d9fb947c50cc08f8dbf9acc3d37dc85637c6b Mon Sep 17 00:00:00 2001 From: Vaidehi Joshi Date: Thu, 22 Oct 2020 16:22:19 -0700 Subject: [PATCH] Use APP_NAME rather than APP_DOMAIN in chat channels (#11029) * Use APP_NAME rather than APP_DOMAIN in chat channels APP_NAME may not always be set (it is not "required" per se), which can cause issues while deriving the pusher_channels. We should use APP_DOMAIN, which is more common and always has a default value. * Add TODO to make pusher channels more unique --- .env_sample | 1 - app/models/chat_channel.rb | 7 ++++--- app/views/shell/_top.html.erb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.env_sample b/.env_sample index d409b7b41..bfdbefa8a 100644 --- a/.env_sample +++ b/.env_sample @@ -4,7 +4,6 @@ export SKIP_SERVICEWORKERS="true" # App core values export APP_DOMAIN="localhost:3000" export APP_PROTOCOL="http://" -export APP_NAME="forem_local" export FOREM_OWNER_SECRET="secret" # Openresty domain + Protocol setting for development diff --git a/app/models/chat_channel.rb b/app/models/chat_channel.rb index 1d3d18a01..28ba24b37 100644 --- a/app/models/chat_channel.rb +++ b/app/models/chat_channel.rb @@ -112,10 +112,11 @@ class ChatChannel < ApplicationRecord end def pusher_channels + # TODO: use something more unique here (uuid?) rather than just id. if invite_only? - "private-channel--#{ApplicationConfig['APP_NAME']}-#{id}" + "private-channel--#{ApplicationConfig['APP_DOMAIN']}-#{id}" elsif open? - "open-channel--#{ApplicationConfig['APP_NAME']}-#{id}" + "open-channel--#{ApplicationConfig['APP_DOMAIN']}-#{id}" else chat_channel_memberships.pluck(:user_id).map { |id| ChatChannel.pm_notifications_channel(id) } end @@ -165,7 +166,7 @@ class ChatChannel < ApplicationRecord end def self.pm_notifications_channel(user_id) - "private-message-notifications--#{ApplicationConfig['APP_NAME']}-#{user_id}" + "private-message-notifications--#{ApplicationConfig['APP_DOMAIN']}-#{user_id}" end private diff --git a/app/views/shell/_top.html.erb b/app/views/shell/_top.html.erb index c853bc115..115f0996e 100644 --- a/app/views/shell/_top.html.erb +++ b/app/views/shell/_top.html.erb @@ -58,7 +58,7 @@ data-user-status="<%= user_logged_in_status %>" class="<%= SiteConfig.default_font.tr("_", "-") %>-article-body default-header" data-pusher-key="<%= ApplicationConfig["PUSHER_KEY"] %>" - data-app-name="<%= ApplicationConfig["APP_NAME"] %>" + data-app-name="<%= ApplicationConfig["APP_DOMAIN"] %>" data-honeybadger-key="<%= ApplicationConfig["HONEYBADGER_JS_API_KEY"] %>" data-release-footprint="<%= ApplicationConfig["RELEASE_FOOTPRINT"] %>" data-ga-tracking="<%= SiteConfig.ga_tracking_id %>">