Skip to content
This repository has been archived by the owner on Apr 17, 2024. It is now read-only.

Hotfix: Fix channel mentions with Slack forced IDs #52

Merged
merged 3 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/CodeReviews.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CodeReviews
if matches
@github_url = matches[0]
@pr_url_regex = ///
^(https?:\/\/#{@github_url}\/([^\/]+)\/([^\/]+)\/pull\/(\d+))(?:\/files)?\/?(\s+[#|@]?[0-9a-z_-]+)?\s*$
^(https?:\/\/#{@github_url}\/([^\/]+)\/([^\/]+)\/pull\/(\d+))(?:\/files)?\/?(?:\s+<?([#|@]?[0-9a-z_-]+)(?:\|>)?)?\s*$
///i
@room_queues = {}
@current_timeout = null
Expand Down Expand Up @@ -477,8 +477,12 @@ class CodeReviews

# If our submitter provided a notification individual/channel, say so.
if (notify_name)?
if notify_name.match(/^#/) # It's a channel, wrap as a link
notify_link = "<#{notify_name}|>"

msg.send "*#{cr.slug}* is now in the code review queue," +
" and #{notify_name} has been notified."
" and #{notify_link || notify_name} has been notified."

else
msg.send "*#{cr.slug}* is now in the code review queue." +
" Let me know if anyone starts reviewing this."
Expand Down
10 changes: 6 additions & 4 deletions src/lib/sendFancyMessage.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,24 @@ module.exports = (robot, room, attachments, text) ->
fallback_text += "\n#{attachment.fallback}"
robot.messageRoom room, fallback_text.replace(/\n$/, "")
else
# Strip any preceeding # from room name
room_name = room.replace /^#/g, ""
# Working around a Slack for Android bug 2016-08-30 by supplying
# text attribute outside of attachment array to allow previews
if text?
try
robot.send { room: room },
robot.send { room: room_name },
as_user: true
channel: room
channel: room_name
text: text
attachments: attachments
catch sendErr
robot.logger.error "Unable to send message to room: #{room}: ", sendErr, attachments
else
try
robot.send { room: room },
robot.send { room: room_name },
as_user: true
channel: room
channel: room_name
attachments: attachments
catch sendErr
robot.logger.error "Unable to send message to room: #{room}: ", sendErr, attachments