[deploy] Change from presence to private pusher channels (#9401)

This commit is contained in:
Ben Halpern 2020-07-20 12:59:26 -04:00 committed by GitHub
parent 7c22026d30
commit 1b22cdd1c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 8 deletions

View file

@ -10,17 +10,17 @@ class PusherController < ApplicationController
end
def valid_channel
valid_private_channel || valid_presence_channel
valid_private_dm_channel || valid_private_group_channel
end
def valid_private_channel
def valid_private_dm_channel
current_user && params[:channel_name] == "private-message-notifications-#{current_user.id}"
end
def valid_presence_channel
return false unless params[:channel_name].include?("presence-channel-")
def valid_private_group_channel
return false unless params[:channel_name].include?("private-channel-")
id = params[:channel_name].split("presence-channel-")[1].split("-")[0]
id = params[:channel_name].split("private-channel-")[1].split("-")[0]
channel = ChatChannel.find(id)
channel.has_member?(current_user)
end

View file

@ -273,7 +273,7 @@ export default class Chat extends Component {
);
this.subscribeChannelsToPusher(
channels.filter(this.channelTypeFilterFn('invite_only')),
(channel) => `presence-channel-${channel.chat_channel_id}`,
(channel) => `private-channel-${channel.chat_channel_id}`,
);
const chatChannelsList = document.getElementById(
'chatchannels__channelslist',
@ -352,7 +352,7 @@ export default class Chat extends Component {
if (activeChannel.channel_type === 'open')
this.subscribePusher(`open-channel-${channelId}`);
}
this.subscribePusher(`presence-channel-${channelId}`);
this.subscribePusher(`private-channel-${channelId}`);
};
setOpenChannelUsers = (res) => {

View file

@ -155,7 +155,7 @@ class ChatChannel < ApplicationRecord
def pusher_channels
if invite_only?
"presence-channel-#{id}"
"private-channel-#{id}"
elsif open?
"open-channel-#{id}"
else