Bladeren bron

Use part of the session hash as collapse key

This allows the push server to collapse all pushes from the same
session since the device is only interested in the most recent push.
Lennart Grahl 6 jaren geleden
bovenliggende
commit
671105c2c9
1 gewijzigde bestanden met toevoegingen van 2 en 3 verwijderingen
  1. 2 3
      src/services/push.ts

+ 2 - 3
src/services/push.ts

@@ -48,7 +48,6 @@ export class PushSession {
     private readonly service: PushService;
     private readonly service: PushService;
     private readonly session: Uint8Array;
     private readonly session: Uint8Array;
     private readonly config: threema.PushSessionConfig;
     private readonly config: threema.PushSessionConfig;
-    private readonly collapseKey: string = randomString(6);
     private readonly doneFuture: Future<any> = new Future();
     private readonly doneFuture: Future<any> = new Future();
     private logTag: string = '[Push]';
     private logTag: string = '[Push]';
     private running: boolean = false;
     private running: boolean = false;
@@ -150,7 +149,7 @@ export class PushSession {
     private async run(): Promise<void> {
     private async run(): Promise<void> {
         // Calculate session hash
         // Calculate session hash
         const sessionHash = await sha256(this.session.buffer);
         const sessionHash = await sha256(this.session.buffer);
-        this.logTag = `[Push.${sessionHash}.${this.collapseKey}]`;
+        this.logTag = `[Push.${sessionHash}]`;
 
 
         // Prepare data
         // Prepare data
         const data = new URLSearchParams();
         const data = new URLSearchParams();
@@ -184,7 +183,7 @@ export class PushSession {
             if (timeToLive === 0) {
             if (timeToLive === 0) {
                 data.delete(PushService.ARG_COLLAPSE_KEY);
                 data.delete(PushService.ARG_COLLAPSE_KEY);
             } else {
             } else {
-                data.set(PushService.ARG_COLLAPSE_KEY, this.collapseKey);
+                data.set(PushService.ARG_COLLAPSE_KEY, sessionHash.slice(0, 6));
             }
             }
 
 
             // Modify data
             // Modify data