From b24f03a32e093fe8d55e23cfd0bb314069633b2f Mon Sep 17 00:00:00 2001
From: 839 <8398a7@gmail.com>
Date: Fri, 27 Dec 2019 12:49:16 +0900
Subject: [PATCH] [#19] support for multiple user mentions
---
README.md | 24 ++++++++++++------------
src/client.ts | 7 ++++++-
2 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/README.md b/README.md
index c329b9b..9d8182a 100644
--- a/README.md
+++ b/README.md
@@ -13,18 +13,18 @@ See [action.yml](action.yml), [checkin.yml](.github/workflows/checkin.yml)
### with Parameters
-| key | value | default | description |
-| ----------------- | ------------------------------------------------------------------------------------------------------ | --------------------- | ----------------------------------------------------------------------------------------------------------- |
-| status | 'success' or 'failure' or 'cancelled' or 'custom' | '' | Recommend
`${{ job.status }}`. |
-| text | any string | '' | You can add to text by specifying it. |
-| author_name | any string | '8398a7@action-slack' | It can be overwritten by specifying. The job name is recommend. |
-| mention | 'here' or 'channel' or [user_id](https://api.slack.com/reference/surfaces/formatting#mentioning-users) | '' | Always mention when specified. |
-| only_mention_fail | 'here' or 'channel' or [user_id](https://api.slack.com/reference/surfaces/formatting#mentioning-users) | '' | If specified, mention only on failure. |
-| payload | e.g. `{"text": "Custom Field Check", obj: 'LOWER CASE'.toLowerCase()}` | '' | Only available when status: custom. The payload format can pass javascript object. |
-| username | Only legacy incoming webhook supported. | '' | override the legacy integration's default name. |
-| icon_emoji | Only legacy incoming webhook supported. | '' | an [emoji code](https://www.webfx.com/tools/emoji-cheat-sheet/) string to use in place of the default icon. |
-| icon_url | Only legacy incoming webhook supported. | '' | an icon image URL string to use in place of the default icon. |
-| channel | Only legacy incoming webhook supported. | '' | override the legacy integration's default channel. This should be an ID, such as `C8UJ12P4P`. |
+| key | value | default | description |
+| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ----------------------------------------------------------------------------------------------------------- |
+| status | 'success' or 'failure' or 'cancelled' or 'custom' | '' | Recommend
`${{ job.status }}`. |
+| text | any string | '' | You can add to text by specifying it. |
+| author_name | any string | '8398a7@action-slack' | It can be overwritten by specifying. The job name is recommend. |
+| mention | 'here' or 'channel' or [user_id](https://api.slack.com/reference/surfaces/formatting#mentioning-users) (e.g. `mention: user_id,user_id2`) | '' | Always mention when specified. |
+| only_mention_fail | 'here' or 'channel' or [user_id](https://api.slack.com/reference/surfaces/formatting#mentioning-users) (e.g. `mention: user_id,user_id2`) | '' | If specified, mention only on failure. |
+| payload | e.g. `{"text": "Custom Field Check", obj: 'LOWER CASE'.toLowerCase()}` | '' | Only available when status: custom. The payload format can pass javascript object. |
+| username | Only legacy incoming webhook supported. | '' | override the legacy integration's default name. |
+| icon_emoji | Only legacy incoming webhook supported. | '' | an [emoji code](https://www.webfx.com/tools/emoji-cheat-sheet/) string to use in place of the default icon. |
+| icon_url | Only legacy incoming webhook supported. | '' | an icon image URL string to use in place of the default icon. |
+| channel | Only legacy incoming webhook supported. | '' | override the legacy integration's default channel. This should be an ID, such as `C8UJ12P4P`. |
See here for `payload` reference or [Custom Notification](https://github.com/8398a7/action-slack#custom-notification).
diff --git a/src/client.ts b/src/client.ts
index 7fde539..3eee716 100644
--- a/src/client.ts
+++ b/src/client.ts
@@ -170,7 +170,12 @@ export class Client {
if (groupMention.includes(mention)) {
return ` `;
} else if (mention !== '') {
- return `<@${mention}> `;
+ return (
+ mention
+ .split(',')
+ .map(userId => `<@${userId}>`)
+ .join(' ') + ' '
+ );
}
return '';
}