From 081b455fa513758fb06de577973179ee1c82a04a Mon Sep 17 00:00:00 2001 From: tofers Date: Fri, 19 May 2023 19:25:54 +0300 Subject: [PATCH] hotfix: newId and deviceType (#2196) * update method generate Msg id, newId to newIdV2 * replace newId and await in version WA 2.2321.6 * fix deviceType --- src/structures/Message.js | 3 +-- src/util/Injected.js | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/structures/Message.js b/src/structures/Message.js index d16e5ca..a3b3117 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -89,8 +89,7 @@ class Message extends Base { * String that represents from which device type the message was sent * @type {string} */ - this.deviceType = data.id.id.length > 21 ? 'android' : data.id.id.substring(0, 2) == '3A' ? 'ios' : 'web'; - + this.deviceType = typeof data.id.id === 'string' && data.id.id.length > 21 ? 'android' : typeof data.id.id === 'string' && data.id.id.substring(0, 2) === '3A' ? 'ios' : 'web'; /** * Indicates if the message was forwarded * @type {boolean} diff --git a/src/util/Injected.js b/src/util/Injected.js index cec3143..76d134a 100644 --- a/src/util/Injected.js +++ b/src/util/Injected.js @@ -245,11 +245,12 @@ exports.LoadUtils = () => { const meUser = window.Store.User.getMaybeMeUser(); const isMD = window.Store.MDBackend; - + const newId = await window.Store.MsgKey.newId(); + const newMsgId = new window.Store.MsgKey({ from: meUser, to: chat.id, - id: window.Store.MsgKey.newId(), + id: newId, participant: isMD && chat.id.isGroup() ? meUser : undefined, selfDir: 'out', });