mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
fix: correct operation type on chat patch
This commit is contained in:
@@ -17,6 +17,7 @@ export type WAPatchCreate = {
|
|||||||
index: string[]
|
index: string[]
|
||||||
type: WAPatchName
|
type: WAPatchName
|
||||||
apiVersion: number
|
apiVersion: number
|
||||||
|
operation: proto.SyncdMutation.SyncdMutationSyncdOperation
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Chat = Omit<proto.IConversation, 'messages'> & {
|
export type Chat = Omit<proto.IConversation, 'messages'> & {
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ const generatePatchMac = (snapshotMac: Uint8Array, valueMacs: Uint8Array[], vers
|
|||||||
export const newLTHashState = (): LTHashState => ({ version: 0, hash: Buffer.alloc(128), indexValueMap: {} })
|
export const newLTHashState = (): LTHashState => ({ version: 0, hash: Buffer.alloc(128), indexValueMap: {} })
|
||||||
|
|
||||||
export const encodeSyncdPatch = async(
|
export const encodeSyncdPatch = async(
|
||||||
{ type, index, syncAction, apiVersion }: WAPatchCreate,
|
{ type, index, syncAction, apiVersion, operation }: WAPatchCreate,
|
||||||
{ creds: { myAppStateKeyId }, keys }: AuthenticationState
|
{ creds: { myAppStateKeyId }, keys }: AuthenticationState
|
||||||
) => {
|
) => {
|
||||||
const key = !!myAppStateKeyId ? await keys.getAppStateSyncKey(myAppStateKeyId) : undefined
|
const key = !!myAppStateKeyId ? await keys.getAppStateSyncKey(myAppStateKeyId) : undefined
|
||||||
@@ -118,8 +118,6 @@ export const encodeSyncdPatch = async(
|
|||||||
}
|
}
|
||||||
const encKeyId = Buffer.from(myAppStateKeyId, 'base64')
|
const encKeyId = Buffer.from(myAppStateKeyId, 'base64')
|
||||||
|
|
||||||
const operation = proto.SyncdMutation.SyncdMutationSyncdOperation.SET
|
|
||||||
|
|
||||||
const state = { ...await keys.getAppStateSyncVersion(type) }
|
const state = { ...await keys.getAppStateSyncVersion(type) }
|
||||||
|
|
||||||
const indexBuffer = Buffer.from(JSON.stringify(index))
|
const indexBuffer = Buffer.from(JSON.stringify(index))
|
||||||
@@ -418,6 +416,7 @@ export const chatModificationToAppPatch = (
|
|||||||
jid: string,
|
jid: string,
|
||||||
lastMessages: Pick<proto.IWebMessageInfo, 'key' | 'messageTimestamp'>[]
|
lastMessages: Pick<proto.IWebMessageInfo, 'key' | 'messageTimestamp'>[]
|
||||||
) => {
|
) => {
|
||||||
|
const OP = proto.SyncdMutation.SyncdMutationSyncdOperation
|
||||||
const messageRange: proto.ISyncActionMessageRange = {
|
const messageRange: proto.ISyncActionMessageRange = {
|
||||||
lastMessageTimestamp: lastMessages[lastMessages.length-1].messageTimestamp,
|
lastMessageTimestamp: lastMessages[lastMessages.length-1].messageTimestamp,
|
||||||
messages: lastMessages
|
messages: lastMessages
|
||||||
@@ -435,7 +434,8 @@ export const chatModificationToAppPatch = (
|
|||||||
},
|
},
|
||||||
index: ['mute', jid],
|
index: ['mute', jid],
|
||||||
type: 'regular_high',
|
type: 'regular_high',
|
||||||
apiVersion: 2
|
apiVersion: 2,
|
||||||
|
operation: mod.mute ? OP.SET : OP.REMOVE
|
||||||
}
|
}
|
||||||
} else if('archive' in mod) {
|
} else if('archive' in mod) {
|
||||||
patch = {
|
patch = {
|
||||||
@@ -448,7 +448,8 @@ export const chatModificationToAppPatch = (
|
|||||||
},
|
},
|
||||||
index: ['archive', jid],
|
index: ['archive', jid],
|
||||||
type: 'regular_low',
|
type: 'regular_low',
|
||||||
apiVersion: 3
|
apiVersion: 3,
|
||||||
|
operation: mod.archive ? OP.SET : OP.REMOVE
|
||||||
}
|
}
|
||||||
} else if('markRead' in mod) {
|
} else if('markRead' in mod) {
|
||||||
patch = {
|
patch = {
|
||||||
@@ -461,7 +462,8 @@ export const chatModificationToAppPatch = (
|
|||||||
},
|
},
|
||||||
index: ['markChatAsRead', jid],
|
index: ['markChatAsRead', jid],
|
||||||
type: 'regular_low',
|
type: 'regular_low',
|
||||||
apiVersion: 3
|
apiVersion: 3,
|
||||||
|
operation: !mod.markRead ? OP.SET : OP.REMOVE
|
||||||
}
|
}
|
||||||
} else if('clear' in mod) {
|
} else if('clear' in mod) {
|
||||||
if(mod.clear === 'all') {
|
if(mod.clear === 'all') {
|
||||||
@@ -478,6 +480,7 @@ export const chatModificationToAppPatch = (
|
|||||||
index: ['deleteMessageForMe', jid, key.id, key.fromMe ? '1' : '0', '0'],
|
index: ['deleteMessageForMe', jid, key.id, key.fromMe ? '1' : '0', '0'],
|
||||||
type: 'regular_high',
|
type: 'regular_high',
|
||||||
apiVersion: 3,
|
apiVersion: 3,
|
||||||
|
operation: OP.SET
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user