summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/NoteReadService.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-04-03 12:11:16 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2023-04-03 12:11:16 +0900
commitb53d6c7f8ca1a712eab44967e8d05a0cc7bcc034 (patch)
tree79ea4fe1f14c0d3c47a46705345be03a2fa2fc4b /packages/backend/src/core/NoteReadService.ts
parentfix(frontend): tweak MkPagination behaviouyr (diff)
downloadsharkey-b53d6c7f8ca1a712eab44967e8d05a0cc7bcc034.tar.gz
sharkey-b53d6c7f8ca1a712eab44967e8d05a0cc7bcc034.tar.bz2
sharkey-b53d6c7f8ca1a712eab44967e8d05a0cc7bcc034.zip
perf(backend): store notes of an antenna to redis instead of postgresql
Resolve #10169
Diffstat (limited to 'packages/backend/src/core/NoteReadService.ts')
-rw-r--r--packages/backend/src/core/NoteReadService.ts43
1 files changed, 1 insertions, 42 deletions
diff --git a/packages/backend/src/core/NoteReadService.ts b/packages/backend/src/core/NoteReadService.ts
index 22d72815ec..1bf0eb918f 100644
--- a/packages/backend/src/core/NoteReadService.ts
+++ b/packages/backend/src/core/NoteReadService.ts
@@ -8,7 +8,7 @@ import type { Packed } from '@/misc/json-schema.js';
import type { Note } from '@/models/entities/Note.js';
import { IdService } from '@/core/IdService.js';
import { GlobalEventService } from '@/core/GlobalEventService.js';
-import type { UsersRepository, NoteUnreadsRepository, MutingsRepository, NoteThreadMutingsRepository, FollowingsRepository, ChannelFollowingsRepository, AntennaNotesRepository } from '@/models/index.js';
+import type { UsersRepository, NoteUnreadsRepository, MutingsRepository, NoteThreadMutingsRepository, FollowingsRepository, ChannelFollowingsRepository } from '@/models/index.js';
import { UserEntityService } from '@/core/entities/UserEntityService.js';
import { bindThis } from '@/decorators.js';
import { NotificationService } from './NotificationService.js';
@@ -38,9 +38,6 @@ export class NoteReadService implements OnApplicationShutdown {
@Inject(DI.channelFollowingsRepository)
private channelFollowingsRepository: ChannelFollowingsRepository,
- @Inject(DI.antennaNotesRepository)
- private antennaNotesRepository: AntennaNotesRepository,
-
private userEntityService: UserEntityService,
private idService: IdService,
private globalEventService: GlobalEventService,
@@ -121,7 +118,6 @@ export class NoteReadService implements OnApplicationShutdown {
const readMentions: (Note | Packed<'Note'>)[] = [];
const readSpecifiedNotes: (Note | Packed<'Note'>)[] = [];
const readChannelNotes: (Note | Packed<'Note'>)[] = [];
- const readAntennaNotes: (Note | Packed<'Note'>)[] = [];
for (const note of notes) {
if (note.mentions && note.mentions.includes(userId)) {
@@ -133,14 +129,6 @@ export class NoteReadService implements OnApplicationShutdown {
if (note.channelId && followingChannels.has(note.channelId)) {
readChannelNotes.push(note);
}
-
- if (note.user != null) { // たぶんnullになることは無いはずだけど一応
- for (const antenna of myAntennas) {
- if (await this.antennaService.checkHitAntenna(antenna, note, note.user)) {
- readAntennaNotes.push(note);
- }
- }
- }
}
if ((readMentions.length > 0) || (readSpecifiedNotes.length > 0) || (readChannelNotes.length > 0)) {
@@ -186,35 +174,6 @@ export class NoteReadService implements OnApplicationShutdown {
noteId: In([...readMentions.map(n => n.id), ...readSpecifiedNotes.map(n => n.id)]),
});
}
-
- if (readAntennaNotes.length > 0) {
- await this.antennaNotesRepository.update({
- antennaId: In(myAntennas.map(a => a.id)),
- noteId: In(readAntennaNotes.map(n => n.id)),
- }, {
- read: true,
- });
-
- // TODO: まとめてクエリしたい
- for (const antenna of myAntennas) {
- const count = await this.antennaNotesRepository.countBy({
- antennaId: antenna.id,
- read: false,
- });
-
- if (count === 0) {
- this.globalEventService.publishMainStream(userId, 'readAntenna', antenna);
- this.pushNotificationService.pushNotification(userId, 'readAntenna', { antennaId: antenna.id });
- }
- }
-
- this.userEntityService.getHasUnreadAntenna(userId).then(unread => {
- if (!unread) {
- this.globalEventService.publishMainStream(userId, 'readAllAntennas');
- this.pushNotificationService.pushNotification(userId, 'readAllAntennas', undefined);
- }
- });
- }
}
onApplicationShutdown(signal?: string | undefined): void {