diff --git a/src/tasks/remind.ts b/src/tasks/remind.ts index 70b7d45f..295553a7 100644 --- a/src/tasks/remind.ts +++ b/src/tasks/remind.ts @@ -10,7 +10,7 @@ import { } from '@openstapps/gitlab-api/lib/types'; import {WebClient} from '@slack/client'; import {logger} from '../common'; -import {GROUPS, NOTE_PREFIX} from '../configuration'; +import {GROUPS, NOTE_PREFIX, SLACK_CHANNEL} from '../configuration'; export async function remind(api: Api): Promise { // get list of open merge requests @@ -58,18 +58,18 @@ export async function remind(api: Api): Promise { }); if (hasUnresolvedDiscussions) { - // send message to slack - await client.chat.postMessage({ - channel: 'C762UG76Z', - text: `Merge request '${mergeRequest.title}' has unresolved discussions! See ${mergeRequest.web_url}!`, - }); + let recipient = mergeRequest.author.username; + + if (typeof mergeRequest.assignee !== 'undefined') { + recipient = mergeRequest.assignee.username; + } // create note in merge request await api.createNote( mergeRequest.project_id, Scope.MERGE_REQUESTS, mergeRequest.iid, - `${NOTE_PREFIX} Please resolve pending discussions, @${mergeRequest.author.username}!`, + `${NOTE_PREFIX} Please resolve pending discussions, @${recipient}!`, ); return; @@ -95,7 +95,7 @@ export async function remind(api: Api): Promise { // send message to slack await client.chat.postMessage({ - channel: 'C762UG76Z', + channel: SLACK_CHANNEL, text: `Merge request '${mergeRequest.title}' needs more approvals! See ${mergeRequest.web_url}!`, }); @@ -111,7 +111,7 @@ export async function remind(api: Api): Promise { // send message to slack await client.chat.postMessage({ - channel: 'C762UG76Z', + channel: SLACK_CHANNEL, text: `Merge request '${mergeRequest.title}' is ready to be merged! See ${mergeRequest.web_url}!`, });