refactor: introduce bindThis decorator to bind this automaticaly
This commit is contained in:
@@ -8,6 +8,7 @@ import type { Notification } from '@/models/entities/Notification.js';
|
||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||
import { GlobalEventService } from './GlobalEventService.js';
|
||||
import { PushNotificationService } from './PushNotificationService.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
|
||||
@Injectable()
|
||||
export class NotificationService {
|
||||
@@ -21,6 +22,7 @@ export class NotificationService {
|
||||
) {
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public async readNotification(
|
||||
userId: User['id'],
|
||||
notificationIds: Notification['id'][],
|
||||
@@ -42,6 +44,7 @@ export class NotificationService {
|
||||
else return this.postReadNotifications(userId, notificationIds);
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public async readNotificationByQuery(
|
||||
userId: User['id'],
|
||||
query: Record<string, any>,
|
||||
@@ -55,11 +58,13 @@ export class NotificationService {
|
||||
return this.readNotification(userId, notificationIds);
|
||||
}
|
||||
|
||||
@bindThis
|
||||
private postReadAllNotifications(userId: User['id']) {
|
||||
this.globalEventService.publishMainStream(userId, 'readAllNotifications');
|
||||
return this.pushNotificationService.pushNotification(userId, 'readAllNotifications', undefined);
|
||||
}
|
||||
|
||||
@bindThis
|
||||
private postReadNotifications(userId: User['id'], notificationIds: Notification['id'][]) {
|
||||
this.globalEventService.publishMainStream(userId, 'readNotifications', notificationIds);
|
||||
return this.pushNotificationService.pushNotification(userId, 'readNotifications', { notificationIds });
|
||||
|
Reference in New Issue
Block a user