Skip to content

Commit 040e893

Browse files
committed
fix: handle case if librarian is only one
1 parent faf1d07 commit 040e893

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

Diff for: src/rotation/rotations.service.ts

+13-6
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,22 @@ export class RotationsService {
6969

7070
if (tomorrowLibrarian.length === 0) {
7171
return;
72-
}
72+
} else if (tomorrowLibrarian.length === 1) {
73+
const tomorrowLibrarianOne = tomorrowLibrarian[0].user;
7374

74-
const tomorrowLibrarianOne = tomorrowLibrarian[0].user;
75-
const tomorrowLibrarianTwo = tomorrowLibrarian[1].user;
75+
const message = `[알림] 내일은 ${tomorrowLibrarianOne.nickname}님이 사서입니다!`;
7676

77-
const message = `[알림] 내일은 ${tomorrowLibrarianOne.nickname}님과 ${tomorrowLibrarianTwo.nickname}님이 사서입니다!`;
77+
await this.slackService.sendDirectMessage(tomorrowLibrarianOne.slackMemberId, message);
78+
return;
79+
} else {
80+
const tomorrowLibrarianOne = tomorrowLibrarian[0].user;
81+
const tomorrowLibrarianTwo = tomorrowLibrarian[1].user;
7882

79-
await this.slackService.sendDirectMessage(tomorrowLibrarianOne.slackMemberId, message);
80-
await this.slackService.sendDirectMessage(tomorrowLibrarianTwo.slackMemberId, message);
83+
const message = `[알림] 내일은 ${tomorrowLibrarianOne.nickname}님과 ${tomorrowLibrarianTwo.nickname}님이 사서입니다!`;
84+
85+
await this.slackService.sendDirectMessage(tomorrowLibrarianOne.slackMemberId, message);
86+
await this.slackService.sendDirectMessage(tomorrowLibrarianTwo.slackMemberId, message);
87+
}
8188
}
8289

8390
/*

Diff for: src/slack/slack.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export class SlackService {
99

1010
async sendDirectMessage(slackId: string, message: string): Promise<void> {
1111
if (slackId.length === 0 || slackId === undefined || slackId === null) {
12-
this.logger.warn('Slack ID is not defined');
12+
this.logger.warn('Slack ID is not defined or empty.');
1313
return;
1414
}
1515

0 commit comments

Comments
 (0)