enhance: Push notification of Antenna note (#9338)

* wip

* wip

* wip

* fix

* fix

* 🎨
This commit is contained in:
tamaina 2022-12-18 19:50:02 +09:00 committed by GitHub
parent c5179e8f1c
commit 867e31c9ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 104 additions and 24 deletions

View file

@ -12,6 +12,7 @@ import { UserEntityService } from '@/core/entities/UserEntityService.js';
import { NotificationService } from './NotificationService.js';
import { AntennaService } from './AntennaService.js';
import { bindThis } from '@/decorators.js';
import { PushNotificationService } from './PushNotificationService.js';
@Injectable()
export class NoteReadService {
@ -42,6 +43,7 @@ export class NoteReadService {
private globalEventServie: GlobalEventService,
private notificationService: NotificationService,
private antennaService: AntennaService,
private pushNotificationService: PushNotificationService,
) {
}
@ -205,12 +207,14 @@ export class NoteReadService {
if (count === 0) {
this.globalEventServie.publishMainStream(userId, 'readAntenna', antenna);
this.pushNotificationService.pushNotification(userId, 'readAntenna', { antennaId: antenna.id });
}
}
this.userEntityService.getHasUnreadAntenna(userId).then(unread => {
if (!unread) {
this.globalEventServie.publishMainStream(userId, 'readAllAntennas');
this.pushNotificationService.pushNotification(userId, 'readAllAntennas', undefined);
}
});
}