From 0944509feca8ffe50a7f601617433869817e4fef Mon Sep 17 00:00:00 2001 From: Eduard Kuzmenko Date: Fri, 18 Jun 2021 18:51:02 +0300 Subject: [PATCH] Pass navigator.userAgent to MTProto worker Update langPackVersion --- src/config/app.ts | 2 +- src/lib/mtproto/mtproto.worker.ts | 4 ++++ src/lib/mtproto/mtprotoworker.ts | 1 + src/lib/mtproto/networker.ts | 2 +- src/lib/mtproto/networkerFactory.ts | 1 + 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/config/app.ts b/src/config/app.ts index a5cf0e99..446d892c 100644 --- a/src/config/app.ts +++ b/src/config/app.ts @@ -13,7 +13,7 @@ const App = { id: 1025907, hash: '452b0359b988148995f22ff0f4229750', version: '0.5.6', - langPackVersion: '0.2.2', + langPackVersion: '0.2.3', langPack: 'macos', langPackCode: 'en', domains: [] as string[], diff --git a/src/lib/mtproto/mtproto.worker.ts b/src/lib/mtproto/mtproto.worker.ts index 036d2daf..9a6bd2c5 100644 --- a/src/lib/mtproto/mtproto.worker.ts +++ b/src/lib/mtproto/mtproto.worker.ts @@ -82,6 +82,10 @@ const taskListeners = { localStorageProxy: (task: LocalStorageProxyTask) => { sessionStorage.finishTask(task.id, task.payload); + }, + + userAgent: (task: any) => { + networkerFactory.userAgent = task.payload; } }; diff --git a/src/lib/mtproto/mtprotoworker.ts b/src/lib/mtproto/mtprotoworker.ts index 16d2bbbb..d0d60b96 100644 --- a/src/lib/mtproto/mtprotoworker.ts +++ b/src/lib/mtproto/mtprotoworker.ts @@ -265,6 +265,7 @@ export class ApiManagerProxy extends CryptoWorkerMethods { const isWebpSupported = webpWorkerController.isWebpSupported(); this.log('WebP supported:', isWebpSupported); this.postMessage({type: 'webpSupport', payload: isWebpSupported}); + this.postMessage({type: 'userAgent', payload: navigator.userAgent}); this.releasePending(); } diff --git a/src/lib/mtproto/networker.ts b/src/lib/mtproto/networker.ts index 825707f8..b1b55a2f 100644 --- a/src/lib/mtproto/networker.ts +++ b/src/lib/mtproto/networker.ts @@ -302,7 +302,7 @@ export default class MTPNetworker { serializer.storeInt(+initConnection.id >>> 0, 'initConnection'); serializer.storeInt(0x0, 'flags'); serializer.storeInt(App.id, 'api_id'); - serializer.storeString(navigator.userAgent || 'Unknown UserAgent', 'device_model'); + serializer.storeString(networkerFactory.userAgent || 'Unknown UserAgent', 'device_model'); serializer.storeString(navigator.platform || 'Unknown Platform', 'system_version'); serializer.storeString(App.version + (App.isMainDomain ? ' ' + App.suffix : ''), 'app_version'); serializer.storeString(navigator.language || 'en', 'system_lang_code'); diff --git a/src/lib/mtproto/networkerFactory.ts b/src/lib/mtproto/networkerFactory.ts index dc4fd5a0..8c8a0c31 100644 --- a/src/lib/mtproto/networkerFactory.ts +++ b/src/lib/mtproto/networkerFactory.ts @@ -21,6 +21,7 @@ export class NetworkerFactory { public updatesProcessor: (obj: any) => void = null; public onConnectionStatusChange: (info: ConnectionStatusChange) => void = null; public akStopped = false; + public userAgent = navigator.userAgent; public setUpdatesProcessor(callback: (obj: any) => void) { this.updatesProcessor = callback;