remove getAllUpdates() and add a typical replicatio API for the update call (#3081)

* (r10s, adb, hpk) remove getAllUpdates() and add a typical replica-API that works with increasing serials.  Streamline docs a bit.

* adapt ffi to new api

* documentation: updates serials may have gaps

* get_webxdc_status_updates() return updates larger than a given serial

* remove status_update_id from status-update-event; it is not needed (ui should update from the last known serial) and easily gets confused with last_serial

* unify wording to 'StatusUpdateSerial'

* remove legacy payload format, all known webxdc should be adapted

* add serial and max_serial to status updates

* avoid races when getting max_serial by avoiding two SQL calls

* update changelog

Co-authored-by: B. Petersen <r10s@b44t.com>
This commit is contained in:
holger krekel
2022-03-04 20:22:48 +01:00
committed by GitHub
parent ef841b1aa3
commit 63688a2f95
6 changed files with 219 additions and 179 deletions

View File

@@ -1037,14 +1037,18 @@ int dc_send_webxdc_status_update (dc_context_t* context, uint32_t msg_id, const
* @memberof dc_context_t
* @param context The context object
* @param msg_id id of the message with the webxdc instance
* @param status_update_id Can be used to filter out only a concrete status update.
* When set to 0, all known status updates are returned.
* @return JSON-array containing the requested updates,
* each element was created by dc_send_webxdc_status_update()
* on this or other devices.
* If there are no updates, an empty JSON-array is returned.
* @param serial The last known serial. Pass 0 if there are no known serials to receive all updates.
* @return JSON-array containing the requested updates.
* Each `update` comes with the following properties:
* - `update.payload`: equals the payload given to dc_send_webxdc_status_update()
* - `update.serial`: the serial number of this update. Serials are larger `0` and newer serials have higher numbers.
* - `update.max_serial`: the maximum serial currently known.
* If `max_serial` equals `serial` this update is the last update (until new network messages arrive).
* - `update.info`: optional, short, informational message.
* - `update.summary`: optional, short text, shown beside app icon.
* If there are no updates, an empty JSON-array is returned.
*/
char* dc_get_webxdc_status_updates (dc_context_t* context, uint32_t msg_id, uint32_t status_update_id);
char* dc_get_webxdc_status_updates (dc_context_t* context, uint32_t msg_id, uint32_t serial);
/**
* Save a draft for a chat in the database.
@@ -5603,15 +5607,12 @@ void dc_event_unref(dc_event_t* event);
/**
* webxdc status update received.
* To get the received status update, use dc_get_webxdc_status_updates().
* To get the received status update, use dc_get_webxdc_status_updates() with
* `serial` set to the last known update.
* To send status updates, use dc_send_webxdc_status_update().
*
* Note, that you do not get events that arrive when the app is not running;
* instead, you can use dc_get_webxdc_status_updates() to get all status updates
* and catch up that way.
*
* @param data1 (int) msg_id
* @param data2 (int) status_update_id
* @param data2 (int) 0
*/
#define DC_EVENT_WEBXDC_STATUS_UPDATE 2120