mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
fix: do not throw error on conditions not matching in lastMessage check
This commit is contained in:
@@ -33,8 +33,8 @@ export type Chat = Omit<proto.IConversation, 'messages'> & {
|
|||||||
archive?: boolean
|
archive?: boolean
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* the last messages in a chat, sorted reverse-chronologically
|
* the last messages in a chat, sorted reverse-chronologically. That is, the latest message should be first in the chat
|
||||||
* for MD modifications, the last message in the array must be the last message recv in the chat
|
* for MD modifications, the last message in the array (i.e. the earlist message) must be the last message recv in the chat
|
||||||
* */
|
* */
|
||||||
export type LastMessageList = Pick<proto.IWebMessageInfo, 'key' | 'messageTimestamp'>[]
|
export type LastMessageList = Pick<proto.IWebMessageInfo, 'key' | 'messageTimestamp'>[]
|
||||||
|
|
||||||
|
|||||||
@@ -447,18 +447,10 @@ export const chatModificationToAppPatch = (
|
|||||||
) => {
|
) => {
|
||||||
const OP = proto.SyncdMutation.SyncdMutationSyncdOperation
|
const OP = proto.SyncdMutation.SyncdMutationSyncdOperation
|
||||||
const getMessageRange = (lastMessages: LastMessageList) => {
|
const getMessageRange = (lastMessages: LastMessageList) => {
|
||||||
if(!lastMessages?.length) {
|
|
||||||
throw new Boom('Expected last message to be not from me', { statusCode: 400 })
|
|
||||||
}
|
|
||||||
|
|
||||||
const lastMsg = lastMessages[lastMessages.length - 1]
|
const lastMsg = lastMessages[lastMessages.length - 1]
|
||||||
if(lastMsg.key.fromMe) {
|
|
||||||
throw new Boom('Expected last message in array to be not from me', { statusCode: 400 })
|
|
||||||
}
|
|
||||||
|
|
||||||
const messageRange: proto.ISyncActionMessageRange = {
|
const messageRange: proto.ISyncActionMessageRange = {
|
||||||
lastMessageTimestamp: lastMsg?.messageTimestamp,
|
lastMessageTimestamp: lastMsg?.messageTimestamp,
|
||||||
messages: lastMessages.map(
|
messages: lastMessages?.length ? lastMessages.map(
|
||||||
m => {
|
m => {
|
||||||
if(m.key.participant) {
|
if(m.key.participant) {
|
||||||
m.key = { ...m.key }
|
m.key = { ...m.key }
|
||||||
@@ -467,7 +459,7 @@ export const chatModificationToAppPatch = (
|
|||||||
|
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
)
|
) : undefined
|
||||||
}
|
}
|
||||||
return messageRange
|
return messageRange
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user