Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/domain/blurting/blurting.service.ts
Original file line numberDiff line numberDiff 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 DownExpand 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff line change
Expand Up@@ -187,6 +187,7 @@ export class HotTopicRepository {
'핫 토픽 답변에 답글이 달렸습니다.',
'hotTopicAnswer',
);
this.fcmService.addHistory(p.userId, '핫 토픽 답변에 답글이 달렸습니다.')
}
});
}
Expand DownExpand 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 numberDiff line numberDiff 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