fetchMessages: Add searchOption.messageId and utilize it in _getMessageById (#105)

This fixes issue #104

Co-authored-by: nir <nir@severin>
This commit is contained in:
Nir 2026-03-08 19:40:16 +02:00 • committed by GitHub
commit 073eff93a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View file

@ -15,8 +15,8 @@ const { sendErrorResponse, decodeBase64 } = require('../utils')
*/
const _getMessageById = async (client, messageId, chatId) => {
const chat = await client.getChatById(chatId)
const messages = await chat.fetchMessages({ limit: 100 })
return messages.find((message) => { return message.id.id === messageId })
const messages = await chat.fetchMessages({ messageId: messageId, limit: 1 })
return messages[0]
}
/**

View file

@ -98,6 +98,9 @@ const patchWWebLibrary = async (client) => {
if (searchOptions && searchOptions.since !== undefined && Number.isFinite(searchOptions.since) && m.t < searchOptions.since) {
return false
}
if (searchOptions && searchOptions.messageId !== undefined && m.id.id != searchOptions.messageId) {
return false
}
return true
}