From bcd19e802dec1ed222ddb045341107add598ddab Mon Sep 17 00:00:00 2001 From: Benjamin Bolton <7146063+benpbolton@users.noreply.github.com> Date: Thu, 6 Oct 2022 11:41:12 -0600 Subject: [PATCH 1/3] Strip preceeding # from room names --- src/lib/sendFancyMessage.coffee | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib/sendFancyMessage.coffee b/src/lib/sendFancyMessage.coffee index 0025eeb..c8f1ecd 100644 --- a/src/lib/sendFancyMessage.coffee +++ b/src/lib/sendFancyMessage.coffee @@ -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 From bcf7e22bbb1a19dc5b35716c9222bab060cf44f5 Mon Sep 17 00:00:00 2001 From: Benjamin Bolton <7146063+benpbolton@users.noreply.github.com> Date: Thu, 6 Oct 2022 11:41:31 -0600 Subject: [PATCH 2/3] Modify regex for slack forced channel IDs --- src/CodeReviews.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CodeReviews.coffee b/src/CodeReviews.coffee index 3119042..9fe2247 100644 --- a/src/CodeReviews.coffee +++ b/src/CodeReviews.coffee @@ -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+)?)?\s*$ ///i @room_queues = {} @current_timeout = null From c8b8cccee1b576565f86f7c914a2ed2bd8215c16 Mon Sep 17 00:00:00 2001 From: Benjamin Bolton <7146063+benpbolton@users.noreply.github.com> Date: Thu, 6 Oct 2022 11:41:48 -0600 Subject: [PATCH 3/3] If notification is to channel, wrap it as a link --- src/CodeReviews.coffee | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/CodeReviews.coffee b/src/CodeReviews.coffee index 9fe2247..4874752 100644 --- a/src/CodeReviews.coffee +++ b/src/CodeReviews.coffee @@ -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."