Skip to content

Commit

Permalink
Fix SlackBridge private channels
Browse files Browse the repository at this point in the history
  • Loading branch information
nylen committed Jan 25, 2019
1 parent 1c1ac5e commit 4efa23a
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions packages/rocketchat-slackbridge/server/RocketAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,19 @@ export default class RocketAdapter {
addChannel(slackChannelID, hasRetried = false) {
logger.rocket.debug('Adding Rocket.Chat channel from Slack', slackChannelID);
let slackResults = null;
let isGroup = false;
if (slackChannelID.charAt(0) === 'C') {
slackResults = HTTP.get('https://slack.com/api/channels.info', { params: { token: this.slackBridge.apiToken, channel: slackChannelID } });
} else if (slackChannelID.charAt(0) === 'G') {
slackResults = HTTP.get('https://slack.com/api/groups.info', { params: { token: this.slackBridge.apiToken, channel: slackChannelID } });
isGroup = true;
let slackMembers = null;

slackResults = HTTP.get('https://slack.com/api/conversations.info', { params: { token: this.slackBridge.apiToken, channel: slackChannelID } });
if (slackResults && slackResults.data && slackResults.data.ok === true) {
slackMembers = HTTP.get('https://slack.com/api/conversations.members', { params: { token: this.slackBridge.apiToken, channel: slackChannelID } });
if (slackMembers && slackMembers.data && slackMembers.data.ok === true) {
slackResults.data.channel.members = slackMembers.data.members;
} else {
slackResults = null;
logger.rocket.error('Could not fetch room members');
}
}

if (slackResults && slackResults.data && slackResults.data.ok === true) {
const rocketChannelData = isGroup ? slackResults.data.group : slackResults.data.channel;
const existingRocketRoom = RocketChat.models.Rooms.findOneByName(rocketChannelData.name);
Expand Down

0 comments on commit 4efa23a

Please sign in to comment.