fix: do not throw error on conditions not matching in lastMessage check

This commit is contained in:
Adhiraj Singh
2022-04-28 15:24:10 +05:30
parent 13ca4c5917
commit dba6d2e0cb
2 changed files with 4 additions and 12 deletions

View File

@@ -447,18 +447,10 @@ export const chatModificationToAppPatch = (
) => {
const OP = proto.SyncdMutation.SyncdMutationSyncdOperation
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]
if(lastMsg.key.fromMe) {
throw new Boom('Expected last message in array to be not from me', { statusCode: 400 })
}
const messageRange: proto.ISyncActionMessageRange = {
lastMessageTimestamp: lastMsg?.messageTimestamp,
messages: lastMessages.map(
messages: lastMessages?.length ? lastMessages.map(
m => {
if(m.key.participant) {
m.key = { ...m.key }
@@ -467,7 +459,7 @@ export const chatModificationToAppPatch = (
return m
}
)
) : undefined
}
return messageRange
}