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

@@ -1532,6 +1532,7 @@ pub unsafe extern "C" fn dc_get_chat_media(
msg_type: libc::c_int,
or_msg_type2: libc::c_int,
or_msg_type3: libc::c_int,
// limit: u32,
) -> *mut dc_array::dc_array_t {
if context.is_null() {
eprintln!("ignoring careless call to dc_get_chat_media()");
@@ -1551,7 +1552,7 @@ pub unsafe extern "C" fn dc_get_chat_media(
block_on(async move {
Box::into_raw(Box::new(
chat::get_chat_media(ctx, chat_id, msg_type, or_msg_type2, or_msg_type3)
chat::get_chat_media(ctx, chat_id, msg_type, or_msg_type2, or_msg_type3, None)
.await
.unwrap_or_log_default(ctx, "Failed get_chat_media")
.into(),