Browse Source

Update clientInfo format

Danilo Bargen 7 năm trước cách đây
mục cha
commit
dab54d9de0
2 tập tin đã thay đổi với 20 bổ sung7 xóa
  1. 18 7
      src/services/webclient.ts
  2. 2 0
      src/threema.d.ts

+ 18 - 7
src/services/webclient.ts

@@ -132,6 +132,9 @@ export class WebClientService {
     private static ARGUMENT_DELETE_TYPE = 'deleteType';
     private static ARGUMENT_ERROR = 'error';
     private static ARGUMENT_MAX_SIZE = 'maxSize';
+    private static ARGUMENT_USER_AGENT = 'userAgent';
+    private static ARGUMENT_BROWSER_NAME = 'browserName';
+    private static ARGUMENT_BROWSER_VERSION = 'browserVersion';
     private static DELETE_GROUP_TYPE_LEAVE = 'leave';
     private static DELETE_GROUP_TYPE_DELETE = 'delete';
     private static DATA_FIELD_BLOB_BLOB = 'blob';
@@ -733,9 +736,17 @@ export class WebClientService {
      */
     public requestClientInfo(): void {
         this.$log.debug('Sending client info request');
-        this._sendRequest(WebClientService.SUB_TYPE_CLIENT_INFO, {
-            userAgent: navigator.userAgent,
-        });
+        const browser = this.browserService.getBrowser();
+        const data: object = {
+            [WebClientService.ARGUMENT_USER_AGENT]: navigator.userAgent,
+        };
+        if (browser.name) {
+            data[WebClientService.ARGUMENT_BROWSER_NAME] = browser.name;
+        }
+        if (browser.version) {
+            data[WebClientService.ARGUMENT_BROWSER_VERSION] = browser.version;
+        }
+        this._sendRequest(WebClientService.SUB_TYPE_CLIENT_INFO, undefined, data);
     }
 
     /**
@@ -2101,13 +2112,13 @@ export class WebClientService {
      */
     private _receiveResponseClientInfo(message: threema.WireMessage): void {
         this.$log.debug('Received client info');
-        const args = message.args;
-        if (args === undefined) {
-            this.$log.warn('Invalid client info, argument field missing');
+        const data = message.data;
+        if (data === undefined) {
+            this.$log.warn('Invalid client info, data field missing');
             return;
         }
 
-        this.clientInfo = args as threema.ClientInfo;
+        this.clientInfo = data as threema.ClientInfo;
         this.$log.debug('Client device:', this.clientInfo.device);
 
         // Store push token

+ 2 - 0
src/threema.d.ts

@@ -558,6 +558,8 @@ declare namespace threema {
 
     interface ClientInfo {
         device: string;
+        os: string;
+        osVersion: string;
         isWork: boolean;
         myPushToken?: string;
         maxGroupSize?: number;