Commit d60625c4 authored by krlwlfrt's avatar krlwlfrt
Browse files

feat: notify merge request assignee instead of author

parent 57f3ad1f
Loading
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -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<void> {
  // get list of open merge requests
@@ -58,18 +58,18 @@ export async function remind(api: Api): Promise<void> {
    });

    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<void> {

        // 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<void> {

        // 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}!`,
        });