Skip to content

Commit

Permalink
fix: add docs for slack arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Birkbjo committed May 23, 2023
1 parent 5102e8a commit de11f5b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class NotificationMessager {
this.type = type
}

sendNotification() {
send() {
throw new Error('Method "sendNotification" must be implemented.')
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Schmervice = require('@hapipal/schmervice')
const { SlackWebhookMessager } = require('./SlackWebHookMessager.js')
const { SlackWebhookMessager } = require('./SlackWebhookMessager.js')

class NotificationService extends Schmervice.Service {
constructor(server, schmerviceOptions, { messagers }) {
Expand Down
24 changes: 23 additions & 1 deletion server/src/services/NotificationService/SlackWebHookMessager.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,28 @@ class SlackWebhookMessager extends NotificationMessager {
this.webhook = new IncomingWebhook(slackWebhookURL)
}

/**
* @param slackWebHookSendArguments
* see https://github.com/slackapi/node-slack-sdk/blob/3498055d6c86beb82d51ddd583e123461379f5b7/packages/webhook/src/IncomingWebhook.ts#L99
* shape of {
username?: string;
icon_emoji?: string;
icon_url?: string;
channel?: string;
text?: string;
link_names?: boolean;
agent?: Agent;
timeout?: number;
attachments?: MessageAttachment[];
blocks?: (KnownBlock | Block)[];
unfurl_links?: boolean;
unfurl_media?: boolean;
metadata?: {
event_type: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
event_payload: Record<string, any>;
}
*/
async send(slackWebHookSendArguments) {
debug(
'Sending notification',
Expand Down Expand Up @@ -53,7 +75,7 @@ class SlackWebhookMessager extends NotificationMessager {
type: 'section',
text: {
type: 'mrkdwn',
text: `*Source Code*:\n <${sourceUrl}>`,
text: `*Source code*:\n <${sourceUrl}>`,
},
accessory: {
type: 'button',
Expand Down

0 comments on commit de11f5b

Please sign in to comment.