general: revert #1665
This commit is contained in:
@@ -368,7 +368,7 @@ export const makeCommunitiesSocket = (config: SocketConfig) => {
|
||||
// update the invite message to be expired
|
||||
if (key.id) {
|
||||
// create new invite message that is expired
|
||||
inviteMessage = proto.Message.GroupInviteMessage.create(inviteMessage)
|
||||
inviteMessage = proto.Message.GroupInviteMessage.fromObject(inviteMessage)
|
||||
inviteMessage.inviteExpiration = 0
|
||||
inviteMessage.inviteCode = ''
|
||||
ev.emit('messages.update', [
|
||||
|
||||
@@ -239,7 +239,7 @@ export const makeGroupsSocket = (config: SocketConfig) => {
|
||||
// update the invite message to be expired
|
||||
if (key.id) {
|
||||
// create new invite message that is expired
|
||||
inviteMessage = proto.Message.GroupInviteMessage.create(inviteMessage)
|
||||
inviteMessage = proto.Message.GroupInviteMessage.fromObject(inviteMessage)
|
||||
inviteMessage.inviteExpiration = 0
|
||||
inviteMessage.inviteCode = ''
|
||||
ev.emit('messages.update', [
|
||||
|
||||
+10
-10
@@ -11,6 +11,7 @@ import type {
|
||||
SocketConfig,
|
||||
WACallEvent,
|
||||
WACallUpdateType,
|
||||
WAMessage,
|
||||
WAMessageKey,
|
||||
WAPatchName
|
||||
} from '../Types'
|
||||
@@ -39,7 +40,6 @@ import {
|
||||
xmppSignedPreKey
|
||||
} from '../Utils'
|
||||
import { makeMutex } from '../Utils/make-mutex'
|
||||
import { decodeAndHydrate } from '../Utils/proto-utils'
|
||||
import {
|
||||
areJidsSameUser,
|
||||
type BinaryNode,
|
||||
@@ -294,8 +294,8 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
typeof plaintextNode.content === 'string'
|
||||
? Buffer.from(plaintextNode.content, 'binary')
|
||||
: Buffer.from(plaintextNode.content as Uint8Array)
|
||||
const messageProto = decodeAndHydrate(proto.Message, contentBuf)
|
||||
const fullMessage = proto.WebMessageInfo.create({
|
||||
const messageProto = proto.Message.decode(contentBuf).toJSON()
|
||||
const fullMessage = proto.WebMessageInfo.fromObject({
|
||||
key: {
|
||||
remoteJid: from,
|
||||
id: child.attrs.message_id || child.attrs.server_id,
|
||||
@@ -303,7 +303,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
},
|
||||
message: messageProto,
|
||||
messageTimestamp: +child.attrs.t!
|
||||
})
|
||||
}).toJSON() as WAMessage
|
||||
await upsertMessage(fullMessage, 'append')
|
||||
logger.info('Processed plaintext newsletter message')
|
||||
} catch (error) {
|
||||
@@ -546,7 +546,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
}
|
||||
}
|
||||
|
||||
const handleGroupNotification = (participant: string, child: BinaryNode, msg: Partial<proto.IWebMessageInfo>) => {
|
||||
const handleGroupNotification = (participant: string, child: BinaryNode, msg: Partial<WAMessage>) => {
|
||||
const participantJid = getBinaryNodeChild(child, 'participant')?.attrs?.jid || participant
|
||||
// TODO: Add participant LID
|
||||
switch (child?.tag) {
|
||||
@@ -658,7 +658,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
}
|
||||
|
||||
const processNotification = async (node: BinaryNode) => {
|
||||
const result: Partial<proto.IWebMessageInfo> = {}
|
||||
const result: Partial<WAMessage> = {}
|
||||
const [child] = getAllBinaryNodeChildren(node)
|
||||
const nodeType = node.attrs.type
|
||||
const from = jidNormalizedUser(node.attrs.from)
|
||||
@@ -874,7 +874,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
await msgRetryCache.set(key, newValue)
|
||||
}
|
||||
|
||||
const sendMessagesAgain = async (key: proto.IMessageKey, ids: string[], retryNode: BinaryNode) => {
|
||||
const sendMessagesAgain = async (key: WAMessageKey, ids: string[], retryNode: BinaryNode) => {
|
||||
const remoteJid = key.remoteJid!
|
||||
const participant = key.participant || remoteJid
|
||||
|
||||
@@ -1089,7 +1089,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
msg.participant ??= node.attrs.participant
|
||||
msg.messageTimestamp = +node.attrs.t!
|
||||
|
||||
const fullMsg = proto.WebMessageInfo.create(msg as proto.IWebMessageInfo)
|
||||
const fullMsg = proto.WebMessageInfo.fromObject(msg) as WAMessage
|
||||
await upsertMessage(fullMsg, 'append')
|
||||
}
|
||||
})
|
||||
@@ -1445,7 +1445,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
|
||||
// missed call + group call notification message generation
|
||||
if (call.status === 'timeout' || (call.status === 'offer' && call.isGroup)) {
|
||||
const msg: proto.IWebMessageInfo = {
|
||||
const msg: WAMessage = {
|
||||
key: {
|
||||
remoteJid: call.chatId,
|
||||
id: call.id,
|
||||
@@ -1465,7 +1465,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
msg.message = { call: { callKey: Buffer.from(call.id) } }
|
||||
}
|
||||
|
||||
const protoMsg = proto.WebMessageInfo.create(msg)
|
||||
const protoMsg = proto.WebMessageInfo.fromObject(msg) as WAMessage
|
||||
upsertMessage(protoMsg, call.offline ? 'append' : 'notify')
|
||||
}
|
||||
})
|
||||
|
||||
@@ -9,6 +9,7 @@ import type {
|
||||
MessageRelayOptions,
|
||||
MiscMessageGenerationOptions,
|
||||
SocketConfig,
|
||||
WAMessage,
|
||||
WAMessageKey
|
||||
} from '../Types'
|
||||
import {
|
||||
@@ -1018,7 +1019,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
createParticipantNodes,
|
||||
getUSyncDevices,
|
||||
messageRetryManager,
|
||||
updateMediaMessage: async (message: proto.IWebMessageInfo) => {
|
||||
updateMediaMessage: async (message: WAMessage) => {
|
||||
const content = assertMediaContent(message.message)
|
||||
const mediaKey = content.mediaKey!
|
||||
const meId = authState.creds.me!.id
|
||||
@@ -1036,15 +1037,15 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
try {
|
||||
const media = await decryptMediaRetryData(result.media!, mediaKey, result.key.id!)
|
||||
if (media.result !== proto.MediaRetryNotification.ResultType.SUCCESS) {
|
||||
const resultStr = proto.MediaRetryNotification.ResultType[media.result]
|
||||
const resultStr = proto.MediaRetryNotification.ResultType[media.result!]
|
||||
throw new Boom(`Media re-upload failed by device (${resultStr})`, {
|
||||
data: media,
|
||||
statusCode: getStatusCodeForMediaRetry(media.result) || 404
|
||||
statusCode: getStatusCodeForMediaRetry(media.result!) || 404
|
||||
})
|
||||
}
|
||||
|
||||
content.directPath = media.directPath
|
||||
content.url = getUrlFromDirectPath(content.directPath)
|
||||
content.url = getUrlFromDirectPath(content.directPath!)
|
||||
|
||||
logger.debug({ directPath: media.directPath, key: result.key }, 'media update successful')
|
||||
} catch (err: any) {
|
||||
|
||||
@@ -33,7 +33,6 @@ import {
|
||||
promiseTimeout
|
||||
} from '../Utils'
|
||||
import { getPlatformId } from '../Utils/browser-utils'
|
||||
import { decodeAndHydrate } from '../Utils/proto-utils'
|
||||
import {
|
||||
assertNodeErrorFree,
|
||||
type BinaryNode,
|
||||
@@ -366,14 +365,14 @@ export const makeSocket = (config: SocketConfig) => {
|
||||
let helloMsg: proto.IHandshakeMessage = {
|
||||
clientHello: { ephemeral: ephemeralKeyPair.public }
|
||||
}
|
||||
helloMsg = proto.HandshakeMessage.create(helloMsg)
|
||||
helloMsg = proto.HandshakeMessage.fromObject(helloMsg)
|
||||
|
||||
logger.info({ browser, helloMsg }, 'connected to WA')
|
||||
|
||||
const init = proto.HandshakeMessage.encode(helloMsg).finish()
|
||||
|
||||
const result = await awaitNextMessage<Uint8Array>(init)
|
||||
const handshake = decodeAndHydrate(proto.HandshakeMessage, result)
|
||||
const handshake = proto.HandshakeMessage.decode(result)
|
||||
|
||||
logger.trace({ handshake }, 'handshake recv from WA')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user