diff --git a/src/domain/blurting/blurting.module.ts b/src/domain/blurting/blurting.module.ts index 6f9b50f..bd716de 100644 --- a/src/domain/blurting/blurting.module.ts +++ b/src/domain/blurting/blurting.module.ts @@ -32,12 +32,14 @@ import { NotificationRepository, ReportRepository, } from 'src/domain/repositories'; +import { BlurtingRConsumer } from './blurtingGroup.consumer'; @Module({ imports: [ UserModule, TypeOrmModule.forFeature([ BlurtingGroupEntity, + BlurtingQuestionEntity, BlurtingAnswerEntity, BlurtingArrowEntity, @@ -96,6 +98,7 @@ import { BlurtingArrowRepository, BlurtingGroupRepository, BlurtingPreQuestionRepository, + BlurtingRConsumer, BlurtingQuestionRepository, BlurtingReplyRepository, BlurtingLikeRepository, diff --git a/src/domain/blurting/blurting.service.ts b/src/domain/blurting/blurting.service.ts index acc4902..cdc189f 100644 --- a/src/domain/blurting/blurting.service.ts +++ b/src/domain/blurting/blurting.service.ts @@ -76,12 +76,12 @@ export class BlurtingService { new Date().getHours() + 9 >= 24 ? new Date().getHours() + 9 - 24 : new Date().getHours() + 9; - if (hour >= 1 && hour <= 8) { - const DNDEndsAt = new Date().setHours(23); - const delay = DNDEndsAt - new Date().getTime(); - await this.rQ.add({ group, no: no, users }, { delay: delay }); - return; - } + // if (hour >= 1 && hour <= 8) { + // const DNDEndsAt = new Date().setHours(23); + // const delay = DNDEndsAt - new Date().getTime(); + // await this.rQ.add({ group, no: no, users }, { delay: delay }); + // return; + // } await this.insertQuestionToGroup(questionToProcess.question, group, no); await Promise.all( users.map(async (userid) => { @@ -101,12 +101,12 @@ export class BlurtingService { const nextPartStartsAt = new Date( group.createdAt.getTime() + (no / 3) * (3 * 60 * 60 * 1000), ); - const delay = new Date().getTime() - nextPartStartsAt.getTime(); + const delay = 30000; // new Date().getTime() - nextPartStartsAt.getTime(); await this.rQ.add({ group, no: no + 1, users }, { delay: delay }); } else { await this.rQ.add( { group, no: no + 1, users }, - { delay: 60 * 60 * 1000 }, + { delay: 30000 }, //5 }, //60 * 60 * 1000 }, ); } } @@ -123,7 +123,6 @@ export class BlurtingService { no: i + 1, question: QUESTION1[rand], }); - // selected1.push(q); } const selected2: BlurtingPreQuestionEntity[] = []; @@ -137,7 +136,6 @@ export class BlurtingService { no: i + 4, question: QUESTION2[rand], }); - // selected2.push(q); } const selected3: BlurtingPreQuestionEntity[] = []; @@ -151,12 +149,7 @@ export class BlurtingService { no: i + 7, question: QUESTION3[rand], }); - // selected3.push(q); } - - // await this.blurtingPreQuestionRepository.save(selected1); - // await this.blurtingPreQuestionRepository.save(selected2); - // await this.blurtingPreQuestionRepository.save(selected3); } async createGroup(users: number[]): Promise { diff --git a/src/domain/blurting/blurtingGroup.consumer.ts b/src/domain/blurting/blurtingGroup.consumer.ts index 8db1875..475a444 100644 --- a/src/domain/blurting/blurtingGroup.consumer.ts +++ b/src/domain/blurting/blurtingGroup.consumer.ts @@ -18,9 +18,13 @@ export class BlurtingRConsumer { @InjectQueue('renewaledBlurting') private readonly queue: Queue, ) {} @Process() - async processNewBlurtingQuestion(job: Job) { - await this.blurtingService.processPreQuestions( - job.data.group, + processNewBlurtingQuestion(job: Job) { + this.blurtingService.processPreQuestions( + { + id: job.data.group.id, + createdAt: new Date(Date.parse(job.data.group.createdAt)), + questions: [], + }, job.data.no, job.data.users, ); diff --git a/src/domain/firebase/fcm.service.ts b/src/domain/firebase/fcm.service.ts index bd69786..14922db 100644 --- a/src/domain/firebase/fcm.service.ts +++ b/src/domain/firebase/fcm.service.ts @@ -58,7 +58,7 @@ export class FcmService { async sendPush(userId: number, body: string, type: string) { const socketUser = await this.socketUserModel.findOne({ userId: userId }); - if (socketUser.notificationToken) { + if (socketUser && socketUser.notificationToken) { try { await firebase.messaging().send({ notification: { diff --git a/src/domain/hotTopic/dtos/HotTopicInfoResponse.dto.ts b/src/domain/hotTopic/dtos/HotTopicInfoResponse.dto.ts index 13b931b..472acee 100644 --- a/src/domain/hotTopic/dtos/HotTopicInfoResponse.dto.ts +++ b/src/domain/hotTopic/dtos/HotTopicInfoResponse.dto.ts @@ -10,6 +10,7 @@ class __AnswerDto { this.username = entity.user.userNickname; this.userId = entity.user.id; this.id = entity.id; + this.content = entity.answer; } @ApiProperty({ description: '답변 id' }) id: number; @@ -21,6 +22,8 @@ class __AnswerDto { createdAt: number; @ApiProperty({ description: '작성자 닉네임' }) username: string; + @ApiProperty({ description: '답글 내용' }) + content: string; @ApiProperty({ description: '작성자 id' }) userId: number; } @@ -32,6 +35,7 @@ class AnswerDto { this.username = entity.user.userNickname; this.userId = entity.user.id; this.id = entity.id; + this.content = entity.answer; if (entity.childs) this.replies = entity.childs .sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime()) @@ -49,6 +53,8 @@ class AnswerDto { username: string; @ApiProperty({ description: '작성자 id' }) userId: number; + @ApiProperty({ description: '댓글 내용' }) + content: string; @ApiProperty({ description: '답글 목록', type: [__AnswerDto] }) replies: AnswerDto[]; } diff --git a/src/domain/repositories/blurtingGroup.repository.ts b/src/domain/repositories/blurtingGroup.repository.ts index f309ed8..ca07155 100644 --- a/src/domain/repositories/blurtingGroup.repository.ts +++ b/src/domain/repositories/blurtingGroup.repository.ts @@ -12,7 +12,7 @@ export class BlurtingGroupRepository { async insert(): Promise { return this.groupRepository.save({ - createdAt: new Date(new Date().getTime() + 9 * 60 * 60 * 1000), + createdAt: new Date(), }); } } diff --git a/src/domain/repositories/blurtingPreQuestion.repository.ts b/src/domain/repositories/blurtingPreQuestion.repository.ts index d820f4d..daa3a43 100644 --- a/src/domain/repositories/blurtingPreQuestion.repository.ts +++ b/src/domain/repositories/blurtingPreQuestion.repository.ts @@ -14,6 +14,10 @@ export class BlurtingPreQuestionRepository { private readonly preQuestionRepository: Repository, ) {} + async save(question: BlurtingPreQuestionEntity[]): Promise { + await this.preQuestionRepository.save(question); + } + async findOne( groupId: number, no: number, diff --git a/src/domain/validation/validation.module.ts b/src/domain/validation/validation.module.ts index a36e124..cbfd0df 100644 --- a/src/domain/validation/validation.module.ts +++ b/src/domain/validation/validation.module.ts @@ -3,9 +3,13 @@ import { TypeOrmModule } from '@nestjs/typeorm'; import { AppStoreConnectTransactionEntity } from 'src/domain/entities'; import { ValidationController } from './validation.controller'; import { ValidationService } from './validation.service'; +import { PointModule } from '../point/point.module'; @Module({ - imports: [TypeOrmModule.forFeature([AppStoreConnectTransactionEntity])], + imports: [ + TypeOrmModule.forFeature([AppStoreConnectTransactionEntity]), + PointModule, + ], controllers: [ValidationController], providers: [ValidationService], exports: [ValidationService], diff --git a/src/domain/validation/validation.service.ts b/src/domain/validation/validation.service.ts index 1f75c63..0da62e4 100644 --- a/src/domain/validation/validation.service.ts +++ b/src/domain/validation/validation.service.ts @@ -15,12 +15,14 @@ import jwt from 'jsonwebtoken'; import { AppStoreConnectTransactionEntity } from 'src/domain/entities'; import type { ProductPurchase } from 'src/interfaces/productPurchase'; import type { Repository } from 'typeorm'; +import { PointService } from '../point/point.service'; @Injectable() export class ValidationService { constructor( @InjectRepository(AppStoreConnectTransactionEntity) private readonly appStoreConnectTransactionRepository: Repository, + private readonly pointService: PointService, ) {} private GOOGLE_AD_KEY_URL = 'https://gstatic.com/admob/reward/verifier-keys.json'; @@ -116,7 +118,9 @@ export class ValidationService { const debug = false; console.log('queryUrl', queryUrl); await this.verify(queryUrl, debug); - // TODO: give reward + + //TODO: give reward + await this.pointService.giveAdPoint(1); } async signAppStoreConnectJwt() {