mirror of
https://github.com/chatmail/core.git
synced 2026-05-04 22:06:29 +03:00
log to status update
& send webxdc update event
This commit is contained in:
@@ -118,16 +118,16 @@ struct StatusUpdates {
|
||||
/// Update items as sent on the wire and as stored in the database.
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub(crate) struct StatusUpdateItem {
|
||||
payload: Value,
|
||||
pub(crate) payload: Value,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
info: Option<String>,
|
||||
pub(crate) info: Option<String>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
document: Option<String>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
summary: Option<String>,
|
||||
pub(crate) summary: Option<String>,
|
||||
}
|
||||
|
||||
/// Update items as passed to the UIs.
|
||||
@@ -323,12 +323,13 @@ impl Context {
|
||||
self.emit_msgs_changed(instance.chat_id, instance.id);
|
||||
}
|
||||
|
||||
let rowid = self
|
||||
.sql
|
||||
.insert(
|
||||
"INSERT INTO msgs_status_updates (msg_id, update_item) VALUES(?, ?);",
|
||||
paramsv![instance.id, serde_json::to_string(&status_update_item)?],
|
||||
)
|
||||
let rowid = self.sql.insert(
|
||||
"INSERT INTO msgs_status_updates (msg_id, update_item) VALUES(?, ?);",
|
||||
paramsv![instance.id, serde_json::to_string(&status_update_item)?],
|
||||
).await?;
|
||||
|
||||
let status_update_serial = self
|
||||
.internal_write_status_update(&instance.id, status_update_item)
|
||||
.await?;
|
||||
|
||||
let status_update_serial = StatusUpdateSerial(u32::try_from(rowid)?);
|
||||
@@ -343,6 +344,22 @@ impl Context {
|
||||
Ok(status_update_serial)
|
||||
}
|
||||
|
||||
pub(crate) async fn internal_write_status_update(
|
||||
&self,
|
||||
instance_id: &MsgId,
|
||||
status_update_item: StatusUpdateItem,
|
||||
) -> Result<StatusUpdateSerial> {
|
||||
let rowid = self
|
||||
.sql
|
||||
.insert(
|
||||
"INSERT INTO msgs_status_updates (msg_id, update_item) VALUES(?, ?);",
|
||||
paramsv![instance_id, serde_json::to_string(&status_update_item)?],
|
||||
)
|
||||
.await?;
|
||||
let status_update_serial = StatusUpdateSerial(u32::try_from(rowid)?);
|
||||
Ok(status_update_serial)
|
||||
}
|
||||
|
||||
/// Sends a status update for an webxdc instance.
|
||||
///
|
||||
/// If the instance is a draft,
|
||||
|
||||
Reference in New Issue
Block a user