@wireapp/core 27.3.4 → 27.3.5
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
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.3.5](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@27.3.4...@wireapp/core@27.3.5) (2022-06-09)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Do not process outdated events ([#4289](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4289)) ([e817f8f](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/e817f8f3351d8b9c016bf94a2668278d9dc14514))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [27.3.4](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@27.3.3...@wireapp/core@27.3.4) (2022-06-08)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @wireapp/core
|
package/package.json
CHANGED
|
@@ -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.3.
|
|
73
|
-
"gitHead": "
|
|
72
|
+
"version": "27.3.5",
|
|
73
|
+
"gitHead": "2ef677ae91a6350051dc3c2c24bd1b20f60a9f2e"
|
|
74
74
|
}
|
package/src/main/Account.js
CHANGED
|
@@ -306,7 +306,7 @@ class Account extends events_1.EventEmitter {
|
|
|
306
306
|
const handleNotification = async (notification, source) => {
|
|
307
307
|
var e_1, _a;
|
|
308
308
|
try {
|
|
309
|
-
const messages = this.service.notification.handleNotification(notification,
|
|
309
|
+
const messages = this.service.notification.handleNotification(notification, source, dryRun);
|
|
310
310
|
try {
|
|
311
311
|
for (var messages_1 = __asyncValues(messages), messages_1_1; messages_1_1 = await messages_1.next(), !messages_1_1.done;) {
|
|
312
312
|
const message = messages_1_1.value;
|
|
@@ -44,6 +44,15 @@ export declare class NotificationService extends EventEmitter {
|
|
|
44
44
|
setLastEventDate(eventDate: Date): Promise<Date>;
|
|
45
45
|
setLastNotificationId(lastNotification: Notification): Promise<string>;
|
|
46
46
|
handleNotificationStream(notificationHandler: NotificationHandler, onMissedNotifications: (notificationId: string) => void, abortHandler: AbortHandler): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Checks if an event should be ignored.
|
|
49
|
+
* An event that has a date prior to that last event that we have parsed should be ignored
|
|
50
|
+
*
|
|
51
|
+
* @param event
|
|
52
|
+
* @param source
|
|
53
|
+
* @param lastEventDate?
|
|
54
|
+
*/
|
|
55
|
+
private isOutdatedEvent;
|
|
47
56
|
handleNotification(notification: Notification, source: PayloadBundleSource, dryRun?: boolean): AsyncGenerator<HandledEventPayload>;
|
|
48
57
|
private cleanupPayloadBundle;
|
|
49
58
|
private handleEvent;
|
|
@@ -136,10 +136,37 @@ class NotificationService extends events_1.EventEmitter {
|
|
|
136
136
|
}).catch(error => this.logger.error(error));
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Checks if an event should be ignored.
|
|
141
|
+
* An event that has a date prior to that last event that we have parsed should be ignored
|
|
142
|
+
*
|
|
143
|
+
* @param event
|
|
144
|
+
* @param source
|
|
145
|
+
* @param lastEventDate?
|
|
146
|
+
*/
|
|
147
|
+
isOutdatedEvent(event, source, lastEventDate) {
|
|
148
|
+
const isFromNotificationStream = source === conversation_1.PayloadBundleSource.NOTIFICATION_STREAM;
|
|
149
|
+
const shouldCheckEventDate = !!event.time && isFromNotificationStream && lastEventDate;
|
|
150
|
+
if (shouldCheckEventDate) {
|
|
151
|
+
/** This check prevents duplicated "You joined" system messages. */
|
|
152
|
+
const isOutdated = lastEventDate.getTime() >= new Date(event.time).getTime();
|
|
153
|
+
return isOutdated;
|
|
154
|
+
}
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
139
157
|
handleNotification(notification, source, dryRun = false) {
|
|
140
158
|
return __asyncGenerator(this, arguments, function* handleNotification_1() {
|
|
141
159
|
for (const event of notification.payload) {
|
|
142
160
|
this.logger.log(`Handling event of type "${event.type}" for notification with ID "${notification.id}"`, event);
|
|
161
|
+
let lastEventDate = undefined;
|
|
162
|
+
try {
|
|
163
|
+
lastEventDate = yield __await(this.database.getLastEventDate());
|
|
164
|
+
}
|
|
165
|
+
catch (_a) { }
|
|
166
|
+
if ('time' in event && this.isOutdatedEvent(event, source, lastEventDate)) {
|
|
167
|
+
this.logger.info(`Ignored outdated event type: '${event.type}'`);
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
143
170
|
try {
|
|
144
171
|
const data = yield __await(this.handleEvent(event, source, dryRun));
|
|
145
172
|
yield yield __await(Object.assign(Object.assign({}, data), { mappedEvent: data.mappedEvent ? this.cleanupPayloadBundle(data.mappedEvent) : undefined }));
|