Skip to content

Commit

Permalink
Merge pull request #46 from overthestream/renewal
Browse files Browse the repository at this point in the history
bug fix
  • Loading branch information
overthestream authored Nov 4, 2024
2 parents 0fed101 + 46036b2 commit 5a41dbb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
4 changes: 4 additions & 0 deletions src/domain/blurting/blurting.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export class BlurtingService {
`${no}번째 질문이 등록되었습니다!`,
'blurting',
);
await this.fcmService.addHistory(userid, `${no}번째 질문이 등록되었습니다!`)
}),
);
console.log(
Expand All @@ -148,6 +149,7 @@ export class BlurtingService {
);

if (no === 9) {
// await this.blurtingPreQuestionRepository.insert({ groupId: group.id, no:10, question:''});
console.log(new Date().toString() + 'blurting end - groupId:' + group.id);
return;
}
Expand Down Expand Up @@ -495,6 +497,7 @@ export class BlurtingService {
`${question.no}번째 질문에 새로운 답변이 등록되었습니다!`,
'blurting',
);
await this.fcmService.addHistory(user.id, `${question.no}번째 질문에 새로운 답변이 등록되었습니다!`)
}
});
if (!(await this.answerRepository.existsByUser(userId, questionId))) {
Expand Down Expand Up @@ -575,6 +578,7 @@ export class BlurtingService {
`${answer.question.no}번째 나의 답변에 댓글이 달렸습니다!`,
'blurting',
);
await this.fcmService.addHistory(answer.user.id, `${answer.question.no}번째 나의 답변에 댓글이 달렸습니다!`)
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/domain/firebase/fcm.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ export class FcmService {
}
}

async addHistory(userId:number, body: string) : Promise<void>{
const newEntity = this.notificationRepository.create({
user: { id: userId },
body,
});
await this.notificationRepository.insert(newEntity);
}

async getNotificationList(userId: number): Promise<NotificationListDto[]> {
const result = await this.notificationRepository.find({
where: { user: { id: userId } },
Expand Down
2 changes: 2 additions & 0 deletions src/domain/hotTopic/hotTopic.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export class HotTopicRepository {
'핫 토픽 답변에 답글이 달렸습니다.',
'hotTopicAnswer',
);
this.fcmService.addHistory(p.userId, '핫 토픽 답변에 답글이 달렸습니다.')
}
});
}
Expand Down Expand Up @@ -233,6 +234,7 @@ export class HotTopicRepository {
'누군가가 당신의 핫 토픽 답변에 좋아요를 눌렀습니다.',
'hotTopicAnswerLike',
);
this.fcmService.addHistory(answer.userId, '누군가가 당신의 핫 토픽 답변에 좋아요를 눌렀습니다.')

return true;
}
Expand Down
24 changes: 12 additions & 12 deletions src/domain/validation/validation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,19 @@ export class ValidationService {
console.debug('Content to verify ---');
console.debug(contentToVerify);
}
const keyMap = await this.getGoogleKeyMap();

if (keyMap.get(key_id)) {
const publicKey = keyMap.get(key_id);
const verifier = crypto.createVerify('RSA-SHA256');
verifier.update(contentToVerify);
const result = verifier.verify(publicKey, signature, 'base64');
if (result) {
// const keyMap = await this.getGoogleKeyMap();
await this.pointService.giveAdPoint(parseInt(String(user_id)));
}
throw new BadRequestException('Invalid signature');
}
throw new BadRequestException('Invalid key id');

// if (keyMap.get(key_id)) {
// const publicKey = keyMap.get(key_id);
// const verifier = crypto.createVerify('RSA-SHA256');
// verifier.update(contentToVerify);
// const result = verifier.verify(publicKey, signature, 'base64');
// if (result) {
// }
// throw new BadRequestException('Invalid signature');
// }
// throw new BadRequestException('Invalid key id');
}

async validateAdMob(queryUrl: string) {
Expand Down

0 comments on commit 5a41dbb

Please sign in to comment.