WIP: api!: add LIMIT arg to get_chat_media

In Delta Chat desktop we show the 3 recently used WebXDC apps,
which relies on `get_chat_media`, which is quite expensive.
Hopefully adding `LIMIT 3` makes it faster.

Marking this as a breaking change
because it's breaking TypeScript-wise,
but shouldn't be breaking behavior-wise,
because not providing the argument in JSON-RPC
should be equivalent to providing `null`
(which gets converted to `None`).

TODO:
- [ ] Add to CFFI?
- [ ] Docs. Both the core fn and the JSON-RPC.
This commit is contained in:
WofWca
2025-10-20 19:05:52 +04:00
parent fc81cef113
commit 781de46e26
5 changed files with 64 additions and 5 deletions

View File

@@ -1734,6 +1734,7 @@ impl CommandApi {
message_type: MessageViewtype,
or_message_type2: Option<MessageViewtype>,
or_message_type3: Option<MessageViewtype>,
limit: Option<u32>,
) -> Result<Vec<u32>> {
let ctx = self.get_context(account_id).await?;
@@ -1745,7 +1746,8 @@ impl CommandApi {
let or_msg_type2 = or_message_type2.map_or(Viewtype::Unknown, |v| v.into());
let or_msg_type3 = or_message_type3.map_or(Viewtype::Unknown, |v| v.into());
let media = get_chat_media(&ctx, chat_id, msg_type, or_msg_type2, or_msg_type3).await?;
let media =
get_chat_media(&ctx, chat_id, msg_type, or_msg_type2, or_msg_type3, limit).await?;
Ok(media.iter().map(|msg_id| msg_id.to_u32()).collect())
}