Bypass chat cap when backfilling
This commit is contained in:
parent
ecb04fc2f5
commit
7a78d6ba25
|
@ -588,13 +588,23 @@ export default class PeerClient {
|
||||||
* @param {string} req.mxid
|
* @param {string} req.mxid
|
||||||
* @param {ChannelProps} req.channel_props
|
* @param {ChannelProps} req.channel_props
|
||||||
* @param {?Long} req.sync_from
|
* @param {?Long} req.sync_from
|
||||||
* @param {?Number} req.limit
|
* @param {?number} req.limit
|
||||||
*/
|
*/
|
||||||
getChats = async (req) => {
|
getChats = async (req) => {
|
||||||
const talkChannel = await this.#getUserChannel(req.mxid, req.channel_props)
|
const talkChannel = await this.#getUserChannel(req.mxid, req.channel_props)
|
||||||
|
|
||||||
const res = await talkChannel.getChatListFrom(req.sync_from)
|
const res = await talkChannel.getChatListFrom(req.sync_from)
|
||||||
if (res.success && 0 < req.limit && req.limit < res.result.length) {
|
if (!res.success) return res
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
const nextRes = await talkChannel.getChatListFrom(
|
||||||
|
res.result[res.result.length - 1].logId
|
||||||
|
)
|
||||||
|
if (!nextRes.success) return nextRes
|
||||||
|
if (!nextRes.result.length) break
|
||||||
|
res.result.push(...nextRes.result)
|
||||||
|
}
|
||||||
|
if (0 < req.limit && req.limit < res.result.length) {
|
||||||
res.result.splice(0, res.result.length - req.limit)
|
res.result.splice(0, res.result.length - req.limit)
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
|
Loading…
Reference in New Issue