mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
better distinguish between update-items and payloads: update-items contain a payload (and maybe more in the future)
This commit is contained in:
@@ -555,8 +555,8 @@ DO UPDATE SET rfc724_mid=excluded.rfc724_mid,
|
|||||||
r#"CREATE TABLE msgs_status_updates (
|
r#"CREATE TABLE msgs_status_updates (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
msg_id INTEGER,
|
msg_id INTEGER,
|
||||||
payload TEXT DEFAULT '',
|
update_item TEXT DEFAULT '',
|
||||||
payload_read INTEGER DEFAULT 0);
|
update_item_read INTEGER DEFAULT 0);
|
||||||
CREATE INDEX msgs_status_updates_index1 ON msgs_status_updates (msg_id);"#,
|
CREATE INDEX msgs_status_updates_index1 ON msgs_status_updates (msg_id);"#,
|
||||||
84,
|
84,
|
||||||
)
|
)
|
||||||
|
|||||||
10
src/w30.rs
10
src/w30.rs
@@ -72,7 +72,7 @@ impl Context {
|
|||||||
let rowid = self
|
let rowid = self
|
||||||
.sql
|
.sql
|
||||||
.insert(
|
.insert(
|
||||||
"INSERT INTO msgs_status_updates (msg_id, payload) VALUES(?, ?);",
|
"INSERT INTO msgs_status_updates (msg_id, update_item) VALUES(?, ?);",
|
||||||
paramsv![instance_msg_id, serde_json::to_string(&status_update_item)?],
|
paramsv![instance_msg_id, serde_json::to_string(&status_update_item)?],
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
@@ -151,7 +151,7 @@ impl Context {
|
|||||||
/// `msg_id` may be an instance (in case there are initial status updates)
|
/// `msg_id` may be an instance (in case there are initial status updates)
|
||||||
/// or a reply to an instance (for all other updates).
|
/// or a reply to an instance (for all other updates).
|
||||||
///
|
///
|
||||||
/// `json` is an array containing one or more payloads as created by send_w30_status_update(),
|
/// `json` is an array containing one or more update items as created by send_w30_status_update(),
|
||||||
/// the array is parsed using serde, the single payloads are used as is.
|
/// the array is parsed using serde, the single payloads are used as is.
|
||||||
pub(crate) async fn receive_status_update(&self, msg_id: MsgId, json: &str) -> Result<()> {
|
pub(crate) async fn receive_status_update(&self, msg_id: MsgId, json: &str) -> Result<()> {
|
||||||
let msg = Message::load_from_db(self, msg_id).await?;
|
let msg = Message::load_from_db(self, msg_id).await?;
|
||||||
@@ -197,7 +197,7 @@ impl Context {
|
|||||||
let json = self
|
let json = self
|
||||||
.sql
|
.sql
|
||||||
.query_map(
|
.query_map(
|
||||||
"SELECT payload FROM msgs_status_updates WHERE msg_id=? AND (1=? OR id=?)",
|
"SELECT update_item FROM msgs_status_updates WHERE msg_id=? AND (1=? OR id=?)",
|
||||||
paramsv![
|
paramsv![
|
||||||
instance_msg_id,
|
instance_msg_id,
|
||||||
if status_update_id.is_some() { 0 } else { 1 },
|
if status_update_id.is_some() { 0 } else { 1 },
|
||||||
@@ -207,11 +207,11 @@ impl Context {
|
|||||||
|rows| {
|
|rows| {
|
||||||
let mut json = String::default();
|
let mut json = String::default();
|
||||||
for row in rows {
|
for row in rows {
|
||||||
let payload = row?;
|
let update_item = row?;
|
||||||
if !json.is_empty() {
|
if !json.is_empty() {
|
||||||
json.push_str(",\n");
|
json.push_str(",\n");
|
||||||
}
|
}
|
||||||
json.push_str(&payload);
|
json.push_str(&update_item);
|
||||||
}
|
}
|
||||||
Ok(json)
|
Ok(json)
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user