Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
JaseFace opened this issue Sep 24, 2018 · 0 comments
Open

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

JaseFace opened this issue Sep 24, 2018 · 0 comments

Comments

@JaseFace
Copy link

JaseFace commented Sep 24, 2018

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant