Apply chat sync limit during RPC transfer
This commit is contained in:
parent
4158788496
commit
1a947a1999
@ -215,13 +215,14 @@ class Client:
|
|||||||
channel_id=channel_id.serialize()
|
channel_id=channel_id.serialize()
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get_chats(self, channel_id: Long, limit: int | None, sync_from: Long | None) -> list[Chatlog]:
|
async def get_chats(self, channel_id: Long, sync_from: Long | None, limit: int | None) -> list[Chatlog]:
|
||||||
return (await self._api_user_request_result(
|
return await self._api_user_request_result(
|
||||||
ResultListType(Chatlog),
|
ResultListType(Chatlog),
|
||||||
"get_chats",
|
"get_chats",
|
||||||
channel_id=channel_id.serialize(),
|
channel_id=channel_id.serialize(),
|
||||||
sync_from=sync_from.serialize() if sync_from else None
|
sync_from=sync_from.serialize() if sync_from else None,
|
||||||
))[-limit if limit else 0:]
|
limit=limit
|
||||||
|
)
|
||||||
|
|
||||||
async def send_message(self, channel_id: Long, text: str) -> Chatlog:
|
async def send_message(self, channel_id: Long, text: str) -> Chatlog:
|
||||||
return await self._api_user_request_result(
|
return await self._api_user_request_result(
|
||||||
|
@ -941,8 +941,8 @@ class Portal(DBPortal, BasePortal):
|
|||||||
self.log.debug(f"Fetching {f'up to {limit}' if limit else 'all'} messages through {source.ktid}")
|
self.log.debug(f"Fetching {f'up to {limit}' if limit else 'all'} messages through {source.ktid}")
|
||||||
messages = await source.client.get_chats(
|
messages = await source.client.get_chats(
|
||||||
channel_info.channelId,
|
channel_info.channelId,
|
||||||
limit,
|
after_log_id,
|
||||||
after_log_id
|
limit
|
||||||
)
|
)
|
||||||
if not messages:
|
if not messages:
|
||||||
self.log.debug("Didn't get any messages from server")
|
self.log.debug("Didn't get any messages from server")
|
||||||
|
@ -339,12 +339,17 @@ export default class PeerClient {
|
|||||||
* @param {string} req.mxid
|
* @param {string} req.mxid
|
||||||
* @param {Long} req.channel_id
|
* @param {Long} req.channel_id
|
||||||
* @param {Long?} req.sync_from
|
* @param {Long?} req.sync_from
|
||||||
|
* @param {Number?} req.limit
|
||||||
*/
|
*/
|
||||||
getChats = async (req) => {
|
getChats = async (req) => {
|
||||||
const userClient = this.#getUser(req.mxid)
|
const userClient = this.#getUser(req.mxid)
|
||||||
const talkChannel = userClient.talkClient.channelList.get(req.channel_id)
|
const talkChannel = userClient.talkClient.channelList.get(req.channel_id)
|
||||||
|
|
||||||
return 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) {
|
||||||
|
res.result.splice(0, res.result.length - req.limit)
|
||||||
|
}
|
||||||
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user