Skip to content

Messages from external users in shared workspaces causes a crash #260

Description

@JaseFace

Slack has added the ability to do shared workspaces, so channels can be bridged:

https://get.slack.help/hc/en-us/articles/115004152843

When messages come in from external users, the bridge currently crashes:

TypeError: Cannot read property 'name' of undefined

I added a quick conditional before user.name is accessed:

if (typeof user === 'undefined' || user === null) {
  _winston2.default.error('Received message from Slack without local user: ' + message.user + ' "' + message.text + '"');
  return;
}

I seems dataStore.getUserById() is failing to assign user, then accesses it without validation:

slack-irc/lib/bot.js

Lines 204 to 205 in e5cb8c6

const user = dataStore.getUserById(message.user);
const username = this.ircUsernameFormat.replace(/\$username/g, user.name);

The output the new conditional picked up is (sanitized, the first user is the remote one, the 2nd is a local user addressed in the message):

error: Received message from Slack without local user: U000XXXXX "<@UX0XXX0XX> - [..message snip..]"

Someone more knowledgable than I likely knows what to do in this case. Does dataStore.getUserById() need to be modified to understand remote instances, or do we simply print the message with the raw username?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions