@wireapp/core 27.3.4 → 27.3.7

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,33 @@
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.7](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@27.3.6...@wireapp/core@27.3.7) (2022-06-14)
7
+
8
+ **Note:** Version bump only for package @wireapp/core
9
+
10
+
11
+
12
+
13
+
14
+ ## [27.3.6](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@27.3.5...@wireapp/core@27.3.6) (2022-06-10)
15
+
16
+ **Note:** Version bump only for package @wireapp/core
17
+
18
+
19
+
20
+
21
+
22
+ ## [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)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * 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))
28
+
29
+
30
+
31
+
32
+
6
33
  ## [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
34
 
8
35
  **Note:** Version bump only for package @wireapp/core
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.6.0",
8
+ "@wireapp/api-client": "19.6.2",
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.3.4",
73
- "gitHead": "d4ad56bf0f2ca6759b2e19742de7e26388905c56"
72
+ "version": "27.3.7",
73
+ "gitHead": "d9b71b067cf68fb1fbb2c619f413bcd884bc090c"
74
74
  }
@@ -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, conversation_1.PayloadBundleSource.WEBSOCKET, dryRun);
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 }));