Report file uploads to IRC - #193
Conversation
ekmartin
left a comment
There was a problem hiding this comment.
Thanks! Would you mind adding a test or two as well? Could probably look quite similar to this: https://github.com/ekmartin/slack-irc/blob/master/test/bot.test.js#L241-L252
| } else if (!message.subtype) { | ||
| text = `<${user.name}> ${text}`; | ||
| } else if (message.subtype === 'file_share') { | ||
| text = `<${user.name}> File uploaded ${message.file.permalink} / ${message.file.permalink_public}`; |
There was a problem hiding this comment.
Isn't showing one of these enough? I.e. message.file.permalink_public || message.file.permalink.
There was a problem hiding this comment.
permalink_public is always generated even if file is not shared. So it's rather hard to guess which would be better to show.
There was a problem hiding this comment.
permalink_public doesn't seem to work for logged in users before it is "created". On external link creation Slack seems to send file_change event but not file_public event. Additionally file_change has just file id without any other details and slack.rtm.dataStore doesn't seem to have method for looking up file by ID. So this would need some own temporary storage for storing file id + url, then on file_change event poll URL whether it works and finally generate another line to IRC if it succeeds.
So I'd guess showing both links is somewhat reasonable.
I also added tests.
|
Sorry about the slow response. This is now published in version 3.10.0 - thank you! |
This handles file_share message subtype which is sent when e.g. screenshot is pasted to Slack channel. It shows both Slack-internal link and public link. For the public link to work Slack config "Enable public file URL creation" must be enabled and file uploader must also click "Create external link" on the file.
Looks like this in IRC channel
Fixes #22