소스 검색

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 년 전
부모
커밋
671105c2c9
1개의 변경된 파일2개의 추가작업 그리고 3개의 파일을 삭제
  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 session: Uint8Array;
     private readonly config: threema.PushSessionConfig;
-    private readonly collapseKey: string = randomString(6);
     private readonly doneFuture: Future<any> = new Future();
     private logTag: string = '[Push]';
     private running: boolean = false;
@@ -150,7 +149,7 @@ export class PushSession {
     private async run(): Promise<void> {
         // Calculate session hash
         const sessionHash = await sha256(this.session.buffer);
-        this.logTag = `[Push.${sessionHash}.${this.collapseKey}]`;
+        this.logTag = `[Push.${sessionHash}]`;
 
         // Prepare data
         const data = new URLSearchParams();
@@ -184,7 +183,7 @@ export class PushSession {
             if (timeToLive === 0) {
                 data.delete(PushService.ARG_COLLAPSE_KEY);
             } else {
-                data.set(PushService.ARG_COLLAPSE_KEY, this.collapseKey);
+                data.set(PushService.ARG_COLLAPSE_KEY, sessionHash.slice(0, 6));
             }
 
             // Modify data