refactor(backend): 存在確認のfindOneByexistに置き換え (#11224)

* refactor(backend): 存在確認の`findOneBy`を`exist`に置き換え

* cleanup
This commit is contained in:
okayurisotto
2023-07-11 14:58:58 +09:00
committed by GitHub
parent 48d3341462
commit cf3e39178b
42 changed files with 287 additions and 200 deletions

View File

@@ -570,12 +570,14 @@ export class NoteCreateService implements OnApplicationShutdown {
if (data.reply) {
// 通知
if (data.reply.userHost === null) {
const threadMuted = await this.noteThreadMutingsRepository.findOneBy({
userId: data.reply.userId,
threadId: data.reply.threadId ?? data.reply.id,
const isThreadMuted = await this.noteThreadMutingsRepository.exist({
where: {
userId: data.reply.userId,
threadId: data.reply.threadId ?? data.reply.id,
}
});
if (!threadMuted) {
if (!isThreadMuted) {
nm.push(data.reply.userId, 'reply');
this.globalEventService.publishMainStream(data.reply.userId, 'reply', noteObj);
@@ -712,12 +714,14 @@ export class NoteCreateService implements OnApplicationShutdown {
@bindThis
private async createMentionedEvents(mentionedUsers: MinimumUser[], note: Note, nm: NotificationManager) {
for (const u of mentionedUsers.filter(u => this.userEntityService.isLocalUser(u))) {
const threadMuted = await this.noteThreadMutingsRepository.findOneBy({
userId: u.id,
threadId: note.threadId ?? note.id,
const isThreadMuted = await this.noteThreadMutingsRepository.exist({
where: {
userId: u.id,
threadId: note.threadId ?? note.id,
},
});
if (threadMuted) {
if (isThreadMuted) {
continue;
}