import { Mention, MentionLegacy, Message } from "../../models/message.model"; import { Conversation } from "../../models/conversation.model"; import { Service } from "../../services/service"; import { RBEvent } from "../../models/event.model"; import { Subscription } from "rxjs"; export declare const NOTIFCENTER_SVC = "NotificationCenterServiceRB"; export interface NotificationCenterService { /** Get the list of the current notifications inside the notification center */ getNotifications(): Promise; /** Mark a given notification as READ * If the notification is already marked as READ, it does nothing * On success, an event will be received NotificationCenterEvents.ON_NOTIFICATION_ACKREAD_UPDATE * @param notification - the NotificationCenterItem to READ */ markNotificationAsRead(notification: NotificationCenterItem): Promise; /** Permanently deletes a given notification * On success, an event will be received NotificationCenterEvents.ON_NOTIFICATIONS_LIST_UPDATE * @param notification - the NotificationCenterItem to DELETE */ deleteNotification(notification: NotificationCenterItem): Promise; /** * Subscribe to updates from the service (all events are of RBEvent); * @param handler - The call-back function that will be subscribed to the RxJS subject */ subscribe(handler: (event: RBEvent) => any): Subscription; } /** * @eventProperty */ export declare enum NotificationCenterEvents { /** * @eventProperty * This RBEvent is send when the list of the notifications (or the content) has been updated; * This event is also send on start / reconnection, once the list is updated from the server */ ON_NOTIFICATIONS_LIST_UPDATE = "ON_NOTIFICATIONS_LIST_UPDATE", /** * @eventProperty * This RBEvent is send when a given notification is updated * **Event Data** * - **notification** : The NotificationCenterItem that is being updated; */ ON_NOTIFICATION_UPDATE = "ON_NOTIFICATION_UPDATE" } export interface NotificationCenterItem { /** Notification unique identifier */ id?: string; /** Type of that notification (for the moment only 'mention') */ type?: string; /** Notification read status */ isRead?: boolean; /** Owner of this notification */ owner?: string; /** Creator of this notification */ sender?: string; /** Object representing notification content, Object's differ depending on notification type */ content?: { /** XMPP message id where notification owner has been mentioned */ messageId?: string; /** XMPP message body where notification owner has been mentioned (mandatory when type is mention) */ messageText?: string; /** Unique identifier of the peer of that conversation */ peer?: string; /** Peer Jid of the conversation where notification owner has been mentioned */ peerJid?: string; }; /** Creation date of the Notification (read only, set automatically on notification creation) in string format. * Can be transformed to Date with new Date(creationDate); */ creationDate?: string; } export declare class NotificationCenterServiceRB extends Service implements NotificationCenterService { private logger; private contactService; private authService; private errorHelperService; private xmppService; private bubbleService; private started; private startingPromise; private xmppSubscriptionHandlers; private subscription; private rxSubject; static getInstance(): NotificationCenterServiceRB; static build(): NotificationCenterServiceRB; private constructor(); private notifications; /********************************************************/ /** LIFE CYCLE STUFF */ /********************************************************/ private onConnectionStateChangeEvent; attachHandlers(): void; stop(): Promise; markAllMentionsRead(): void; /********************************************************/ /** PUBLIC & PRIVATE APIS */ /********************************************************/ /** Get the list of the current notifications inside the notification center */ getNotifications(): Promise; private getAllNotificationsFromServer; /** * API USED BY CONVERSATION SERVICE * When a new message contains a list of mentions, we need to create the mentions on the server via this API where we send the list of all mentionned * rainbow users, the conversation, and the message itself */ mentionUsersInConversation(mentions: (Mention | MentionLegacy)[], conversation: Conversation, message: Message): Promise; /** * API USED BY CONVERSATION SERVICE * When a message is updated / deleted, we need to also update the mentions; We can either add, remove or do both in one single update of message */ updateMentionedUserInConversation(conversation: Conversation, message: Message, oldMentions?: (Mention | MentionLegacy)[], newMentions?: (Mention | MentionLegacy)[]): Promise; /** * DELETE LIST OF MENTIONED USERS */ private deleteMentionedUsersInConversation; private innerUpdateMentionUsersInConversation; /** * Send to other services via sendEvent() * Can listen to it via notificationCenterService.subscribe() API * @param name - the name of the event * @param data -the data to be send (an object) */ sendEvent(name: NotificationCenterEvents, data?: any): void; /** * Subscribe to events send from the Notification Center Service (all events are of RBEvent type {name: string, data:any}); * @param handler - The call-back function that will be subscribed to the RxJS subject * @returns Returns RxJS Subscription */ subscribe(handler: any): Subscription; /** Mark a given notification as READ * If the notification is already marked as READ, it does nothing * On success, an event will be received NotificationCenterEvents.ON_NOTIFICATION_ACKREAD_UPDATE * @param notification - the NotificationCenterItem to READ */ markNotificationAsRead(notification: NotificationCenterItem): Promise; /** Permanently deletes a given notification * On success, an event will be received NotificationCenterEvents.ON_NOTIFICATIONS_LIST_UPDATE * @param notification - the NotificationCenterItem to DELETE */ deleteNotification(notification: NotificationCenterItem): Promise; /********************************************************/ /** EVENTS MANAGEMENT */ /********************************************************/ private onManagementMessageReceived; } //# sourceMappingURL=notificationCenter.service.d.ts.map