-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
50c9da7
commit eca8bde
Showing
3 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,29 @@ | ||
import { Processor, Process } from '@nestjs/bull'; | ||
import { Job } from 'bull'; | ||
import { BlurtingService } from './blurting.service'; | ||
import { BlurtingGroupEntity, BlurtingQuestionEntity } from 'src/entities'; | ||
import { FcmService } from 'src/firebase/fcm.service'; | ||
|
||
@Processor('blurtingQuestions') | ||
export class BlurtingConsumer { | ||
constructor( | ||
private blurtingService: BlurtingService, | ||
private fcmService: FcmService, | ||
) {} | ||
@Process() | ||
async processNewBlurtingQuestion(job: Job) { | ||
console.log(job.data.id); | ||
const question: BlurtingQuestionEntity = job.data.question; | ||
const group: BlurtingGroupEntity = job.data.group; | ||
const users: number[] = job.data.users; | ||
await this.blurtingService.insertQuestionToGroup(question, group); | ||
await Promise.all( | ||
users.map(async (userid) => { | ||
await this.fcmService.sendPush( | ||
userid, | ||
`${job.data.no}번쨰 질문이 등록되었습니다!`, | ||
`그룹 질문에 응답해주세요.`, | ||
); | ||
}), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters