@wireapp/core 27.1.0 → 27.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/package.json +3 -3
- package/src/main/Account.d.ts +9 -1
- package/src/main/Account.js +2 -2
- package/src/main/notification/NotificationBackendRepository.d.ts +4 -1
- package/src/main/notification/NotificationService.d.ts +1 -1
- package/src/main/notification/NotificationService.js +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [27.2.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@27.1.0...@wireapp/core@27.2.0) (2022-05-30)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add missed notifications hook ([#4275](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4275)) ([f81217b](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/f81217bad53fed2e4fb163c6ae871b39ca16cf58))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [27.1.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@27.0.5...@wireapp/core@27.1.0) (2022-05-30)
|
|
7
18
|
|
|
8
19
|
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@types/long": "4.0.1",
|
|
7
7
|
"@types/node": "~14",
|
|
8
|
-
"@wireapp/api-client": "19.
|
|
8
|
+
"@wireapp/api-client": "19.3.0",
|
|
9
9
|
"@wireapp/cryptobox": "12.8.0",
|
|
10
10
|
"bazinga64": "5.10.0",
|
|
11
11
|
"hash.js": "1.1.7",
|
|
@@ -69,6 +69,6 @@
|
|
|
69
69
|
"test:project": "yarn dist && yarn test",
|
|
70
70
|
"test:node": "nyc jasmine --config=jasmine.json"
|
|
71
71
|
},
|
|
72
|
-
"version": "27.
|
|
73
|
-
"gitHead": "
|
|
72
|
+
"version": "27.2.0",
|
|
73
|
+
"gitHead": "6d388436ccb83857b1466312af6ba5541b583bef"
|
|
74
74
|
}
|
package/src/main/Account.d.ts
CHANGED
|
@@ -150,7 +150,7 @@ export declare class Account extends EventEmitter {
|
|
|
150
150
|
* @param callbacks callbacks that will be called to handle different events
|
|
151
151
|
* @returns close a function that will disconnect from the websocket
|
|
152
152
|
*/
|
|
153
|
-
listen({ onEvent, onConnected, onConnectionStateChanged, onNotificationStreamProgress, }?: {
|
|
153
|
+
listen({ onEvent, onConnected, onConnectionStateChanged, onNotificationStreamProgress, onMissedNotifications, }?: {
|
|
154
154
|
/**
|
|
155
155
|
* Called when a new event arrives from backend
|
|
156
156
|
* @param payload the payload of the event. Contains the raw event received and the decrypted data (if event was encrypted)
|
|
@@ -172,6 +172,14 @@ export declare class Account extends EventEmitter {
|
|
|
172
172
|
* called when the connection stateh with the backend has changed
|
|
173
173
|
*/
|
|
174
174
|
onConnectionStateChanged?: (state: WEBSOCKET_STATE) => void;
|
|
175
|
+
/**
|
|
176
|
+
* called when we detect lost notification from backend.
|
|
177
|
+
* When a client doesn't log in for a while (28 days, as of now) notifications that are older than 28 days will be deleted from backend.
|
|
178
|
+
* If the client query the backend for the notifications since a particular notification ID and this ID doesn't exist anymore on the backend, we deduce that some messages were not sync before they were removed from backend.
|
|
179
|
+
* We can then detect that something was wrong and warn the consumer that there might be some missing old messages
|
|
180
|
+
* @param {string} notificationId
|
|
181
|
+
*/
|
|
182
|
+
onMissedNotifications?: (notificationId: string) => void;
|
|
175
183
|
}): Promise<() => void>;
|
|
176
184
|
private initEngine;
|
|
177
185
|
}
|
package/src/main/Account.js
CHANGED
|
@@ -284,7 +284,7 @@ class Account extends events_1.EventEmitter {
|
|
|
284
284
|
* @param callbacks callbacks that will be called to handle different events
|
|
285
285
|
* @returns close a function that will disconnect from the websocket
|
|
286
286
|
*/
|
|
287
|
-
async listen({ onEvent = () => { }, onConnected = () => { }, onConnectionStateChanged = () => { }, onNotificationStreamProgress = () => { }, } = {}) {
|
|
287
|
+
async listen({ onEvent = () => { }, onConnected = () => { }, onConnectionStateChanged = () => { }, onNotificationStreamProgress = () => { }, onMissedNotifications = () => { }, } = {}) {
|
|
288
288
|
if (!this.apiClient.context) {
|
|
289
289
|
throw new Error('Context is not set - please login first');
|
|
290
290
|
}
|
|
@@ -332,7 +332,7 @@ class Account extends events_1.EventEmitter {
|
|
|
332
332
|
await this.service.notification.handleNotificationStream(async (notification, source, progress) => {
|
|
333
333
|
await handleNotification(notification, source);
|
|
334
334
|
onNotificationStreamProgress(progress);
|
|
335
|
-
});
|
|
335
|
+
}, onMissedNotifications);
|
|
336
336
|
onConnected();
|
|
337
337
|
};
|
|
338
338
|
await this.apiClient.connect(onBeforeConnect);
|
|
@@ -3,6 +3,9 @@ import type { Notification } from '@wireapp/api-client/src/notification/';
|
|
|
3
3
|
export declare class NotificationBackendRepository {
|
|
4
4
|
private readonly apiClient;
|
|
5
5
|
constructor(apiClient: APIClient);
|
|
6
|
-
getAllNotifications(clientId?: string, lastNotificationId?: string): Promise<
|
|
6
|
+
getAllNotifications(clientId?: string, lastNotificationId?: string): Promise<{
|
|
7
|
+
notifications: Notification[];
|
|
8
|
+
missedNotification?: string | undefined;
|
|
9
|
+
}>;
|
|
7
10
|
getLastNotification(clientId?: string): Promise<Notification>;
|
|
8
11
|
}
|
|
@@ -42,7 +42,7 @@ export declare class NotificationService extends EventEmitter {
|
|
|
42
42
|
getNotificationEventList(): Promise<Events.BackendEvent[]>;
|
|
43
43
|
setLastEventDate(eventDate: Date): Promise<Date>;
|
|
44
44
|
setLastNotificationId(lastNotification: Notification): Promise<string>;
|
|
45
|
-
handleNotificationStream(notificationHandler: NotificationHandler): Promise<void>;
|
|
45
|
+
handleNotificationStream(notificationHandler: NotificationHandler, onMissedNotifications: (notificationId: string) => void): Promise<void>;
|
|
46
46
|
handleNotification(notification: Notification, source: PayloadBundleSource): AsyncGenerator<HandledEventPayload>;
|
|
47
47
|
private cleanupPayloadBundle;
|
|
48
48
|
private handleEvent;
|
|
@@ -118,8 +118,11 @@ class NotificationService extends events_1.EventEmitter {
|
|
|
118
118
|
async setLastNotificationId(lastNotification) {
|
|
119
119
|
return this.database.updateLastNotificationId(lastNotification);
|
|
120
120
|
}
|
|
121
|
-
async handleNotificationStream(notificationHandler) {
|
|
122
|
-
const notifications = await this.getAllNotifications();
|
|
121
|
+
async handleNotificationStream(notificationHandler, onMissedNotifications) {
|
|
122
|
+
const { notifications, missedNotification } = await this.getAllNotifications();
|
|
123
|
+
if (missedNotification) {
|
|
124
|
+
onMissedNotifications(missedNotification);
|
|
125
|
+
}
|
|
123
126
|
for (const [index, notification] of notifications.entries()) {
|
|
124
127
|
await notificationHandler(notification, conversation_1.PayloadBundleSource.NOTIFICATION_STREAM, {
|
|
125
128
|
done: index + 1,
|