diff --git a/src/notice/notice.service.ts b/src/notice/notice.service.ts index 7ccb799..ae8628d 100644 --- a/src/notice/notice.service.ts +++ b/src/notice/notice.service.ts @@ -268,7 +268,7 @@ export class NoticeService { ); } - @Cron('*/20 * * * *') + @Cron('*/5 * * * *') async crawlAcademicNotice() { const recentNotice = await this.noticeRepository.getNoticeList({ limit: 1, @@ -295,7 +295,7 @@ export class NoticeService { const user = await this.userService.addTempUser( `${meta.author} (${meta.category})`, ); - await this.noticeRepository.createNotice( + const result = await this.noticeRepository.createNotice( { title: meta.title, body, @@ -305,6 +305,13 @@ export class NoticeService { user.uuid, dayjs(meta.createdAt).tz('Asia/Seoul').toDate(), ); + await this.fcmService.postMessage( + { title: '새 공지글', body: meta.title }, + ( + await this.noticeRepository.getAllFcmTokens() + ).map(({ token }) => token), + { path: `/root/article?id=${result.id}` }, + ); }), ); await lastValueFrom(concat($, of(null)));