Messages from external users in shared workspaces causes a crash
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:
https://github.com/ekmartin/slack-irc/blob/e5cb8c6e83a18b706bd69cef96c5af067a31604a/lib/bot.js#L204-L205
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?