mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 08:43:33 +00:00
notification service
This commit is contained in:
71
src/models/response/notificationResponse.ts
Normal file
71
src/models/response/notificationResponse.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import { NotificationType } from '../../enums/notificationType';
|
||||
|
||||
export class NotificationResponse {
|
||||
contextId: string;
|
||||
type: NotificationType;
|
||||
payload: any;
|
||||
|
||||
constructor(response: any) {
|
||||
this.contextId = response.contextId || response.ContextId;
|
||||
this.type = response.type != null ? response.type : response.Type;
|
||||
|
||||
const payload = response.payload || response.Payload;
|
||||
switch (this.type) {
|
||||
case NotificationType.SyncCipherCreate:
|
||||
case NotificationType.SyncCipherDelete:
|
||||
case NotificationType.SyncCipherUpdate:
|
||||
case NotificationType.SyncLoginDelete:
|
||||
this.payload = new SyncCipherNotification(payload);
|
||||
break;
|
||||
case NotificationType.SyncFolderCreate:
|
||||
case NotificationType.SyncFolderDelete:
|
||||
case NotificationType.SyncFolderUpdate:
|
||||
this.payload = new SyncFolderNotification(payload);
|
||||
break;
|
||||
case NotificationType.SyncVault:
|
||||
case NotificationType.SyncCiphers:
|
||||
case NotificationType.SyncOrgKeys:
|
||||
case NotificationType.SyncSettings:
|
||||
this.payload = new SyncUserNotification(payload);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class SyncCipherNotification {
|
||||
id: string;
|
||||
userId: string;
|
||||
organizationId: string;
|
||||
revisionDate: Date;
|
||||
|
||||
constructor(response: any) {
|
||||
this.id = response.Id;
|
||||
this.userId = response.UserId;
|
||||
this.organizationId = response.OrganizationId;
|
||||
this.revisionDate = new Date(response.RevisionDate);
|
||||
}
|
||||
}
|
||||
|
||||
export class SyncFolderNotification {
|
||||
id: string;
|
||||
userId: string;
|
||||
revisionDate: Date;
|
||||
|
||||
constructor(response: any) {
|
||||
this.id = response.Id;
|
||||
this.userId = response.UserId;
|
||||
this.revisionDate = new Date(response.RevisionDate);
|
||||
}
|
||||
}
|
||||
|
||||
export class SyncUserNotification {
|
||||
userId: string;
|
||||
date: Date;
|
||||
|
||||
constructor(response: any) {
|
||||
this.userId = response.UserId;
|
||||
this.date = new Date(response.Date);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user