@@ -16,6 +16,8 @@ import { RotationAttendeeEntity } from './entity/rotation-attendee.entity';
16
16
import { UserService } from 'src/user/user.service' ;
17
17
import { RotationRepository } from './repository/rotations.repository' ;
18
18
import {
19
+ getFourthFridayOfMonth ,
20
+ getFourthMondayOfMonth ,
19
21
getFourthWeekdaysOfMonth ,
20
22
getNextYearAndMonth ,
21
23
getTodayDay ,
@@ -54,8 +56,8 @@ export class RotationsService {
54
56
/*
55
57
* 매일 0시 0분에 내일 사서에게 메세지를 전송하는 cron job
56
58
*/
57
- @Cron ( '* * * * * *' , {
58
- name : 'checkTomorrowLibrarian ' ,
59
+ @Cron ( '0 0 * * *' , {
60
+ name : 'sendMessageTomorrowLibrarian ' ,
59
61
timeZone : 'Asia/Seoul' ,
60
62
} )
61
63
async sendMessageTomorrowLibrarian ( ) : Promise < void > {
@@ -98,6 +100,34 @@ export class RotationsService {
98
100
}
99
101
}
100
102
103
+ /*
104
+ * 매일 0시 0분마다, 현재 날짜가 이번 달 4째주 월요일/금요일인지 확인하여, 집현전 슬랙 채널에 메세지를 보내는 cron job
105
+ */
106
+ @Cron ( '0 0 * * *' , {
107
+ name : 'sendMessageRotationDeadline' ,
108
+ timeZone : 'Asia/Seoul' ,
109
+ } )
110
+ async sendMessageRotationDeadline ( ) : Promise < void > {
111
+ let message : string ;
112
+ const today = new Date ( ) . getDate ( ) ;
113
+ if ( today === getFourthMondayOfMonth ( ) ) {
114
+ message =
115
+ '[알림] 로테이션 신청 기간이 시작되었습니다. 이번 주 금요일까지 신청해주세요!\n[신청하러 가기]: https://together.42jip.net/' ;
116
+ } else if ( today === getFourthFridayOfMonth ( ) ) {
117
+ message =
118
+ '[알림] 로테이션 신청 기간이 내일 마감됩니다. 오늘까지 신청해주세요!\n[신청하러 가기]: https://together.42jip.net/' ;
119
+ } else {
120
+ return ;
121
+ }
122
+
123
+ await this . slackService . postMessage (
124
+ Message ( {
125
+ text : message ,
126
+ channel : this . configService . get ( 'slack.jiphyeonjeonChannel' ) ,
127
+ } ) . buildToObject ( ) ,
128
+ ) ;
129
+ }
130
+
101
131
/*
102
132
* 4주차 월요일에 유저를 모두 DB에 담아놓는 작업 필요
103
133
* [update 20231219] - 매 달 1일에 유저를 모두 DB에 담아놓는 작업으로 변경
0 commit comments