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:
parent
6894b8ecd6
commit
073eff93a2
2 changed files with 5 additions and 2 deletions
|
|
@ -15,8 +15,8 @@ const { sendErrorResponse, decodeBase64 } = require('../utils')
|
||||||
*/
|
*/
|
||||||
const _getMessageById = async (client, messageId, chatId) => {
|
const _getMessageById = async (client, messageId, chatId) => {
|
||||||
const chat = await client.getChatById(chatId)
|
const chat = await client.getChatById(chatId)
|
||||||
const messages = await chat.fetchMessages({ limit: 100 })
|
const messages = await chat.fetchMessages({ messageId: messageId, limit: 1 })
|
||||||
return messages.find((message) => { return message.id.id === messageId })
|
return messages[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,9 @@ const patchWWebLibrary = async (client) => {
|
||||||
if (searchOptions && searchOptions.since !== undefined && Number.isFinite(searchOptions.since) && m.t < searchOptions.since) {
|
if (searchOptions && searchOptions.since !== undefined && Number.isFinite(searchOptions.since) && m.t < searchOptions.since) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if (searchOptions && searchOptions.messageId !== undefined && m.id.id != searchOptions.messageId) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue