|
|
|
|
@@ -13,7 +13,7 @@
|
|
|
|
|
//! - `msg_id` - ID of the message in the `msgs` table
|
|
|
|
|
//! - `first_serial` - serial number of the first status update to send
|
|
|
|
|
//! - `last_serial` - serial number of the last status update to send
|
|
|
|
|
//! - `descr` - text to send along with the updates
|
|
|
|
|
//! - `descr` - not used, set to empty string
|
|
|
|
|
|
|
|
|
|
mod integration;
|
|
|
|
|
mod maps_integration;
|
|
|
|
|
@@ -56,6 +56,9 @@ const WEBXDC_API_VERSION: u32 = 1;
|
|
|
|
|
pub const WEBXDC_SUFFIX: &str = "xdc";
|
|
|
|
|
const WEBXDC_DEFAULT_ICON: &str = "__webxdc__/default-icon.png";
|
|
|
|
|
|
|
|
|
|
/// Text shown to classic e-mail users in the visible e-mail body.
|
|
|
|
|
const BODY_DESCR: &str = "Webxdc Status Update";
|
|
|
|
|
|
|
|
|
|
/// Raw information read from manifest.toml
|
|
|
|
|
#[derive(Debug, Deserialize, Default)]
|
|
|
|
|
#[non_exhaustive]
|
|
|
|
|
@@ -483,11 +486,10 @@ impl Context {
|
|
|
|
|
&self,
|
|
|
|
|
instance_msg_id: MsgId,
|
|
|
|
|
update_str: &str,
|
|
|
|
|
descr: &str,
|
|
|
|
|
) -> Result<()> {
|
|
|
|
|
let status_update_item: StatusUpdateItem = serde_json::from_str(update_str)
|
|
|
|
|
.with_context(|| format!("Failed to parse webxdc update item from {update_str:?}"))?;
|
|
|
|
|
self.send_webxdc_status_update_struct(instance_msg_id, status_update_item, descr)
|
|
|
|
|
self.send_webxdc_status_update_struct(instance_msg_id, status_update_item)
|
|
|
|
|
.await?;
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
@@ -498,7 +500,6 @@ impl Context {
|
|
|
|
|
&self,
|
|
|
|
|
instance_msg_id: MsgId,
|
|
|
|
|
mut status_update: StatusUpdateItem,
|
|
|
|
|
descr: &str,
|
|
|
|
|
) -> Result<()> {
|
|
|
|
|
let instance = Message::load_from_db(self, instance_msg_id)
|
|
|
|
|
.await
|
|
|
|
|
@@ -546,10 +547,10 @@ impl Context {
|
|
|
|
|
|
|
|
|
|
if send_now {
|
|
|
|
|
self.sql.insert(
|
|
|
|
|
"INSERT INTO smtp_status_updates (msg_id, first_serial, last_serial, descr) VALUES(?, ?, ?, ?)
|
|
|
|
|
"INSERT INTO smtp_status_updates (msg_id, first_serial, last_serial, descr) VALUES(?, ?, ?, '')
|
|
|
|
|
ON CONFLICT(msg_id)
|
|
|
|
|
DO UPDATE SET last_serial=excluded.last_serial, descr=excluded.descr",
|
|
|
|
|
(instance.id, status_update_serial, status_update_serial, descr),
|
|
|
|
|
DO UPDATE SET last_serial=excluded.last_serial",
|
|
|
|
|
(instance.id, status_update_serial, status_update_serial),
|
|
|
|
|
).await.context("Failed to insert webxdc update into SMTP queue")?;
|
|
|
|
|
self.scheduler.interrupt_smtp().await;
|
|
|
|
|
}
|
|
|
|
|
@@ -557,21 +558,18 @@ impl Context {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Returns one record of the queued webxdc status updates.
|
|
|
|
|
async fn smtp_status_update_get(
|
|
|
|
|
&self,
|
|
|
|
|
) -> Result<Option<(MsgId, i64, StatusUpdateSerial, String)>> {
|
|
|
|
|
async fn smtp_status_update_get(&self) -> Result<Option<(MsgId, i64, StatusUpdateSerial)>> {
|
|
|
|
|
let res = self
|
|
|
|
|
.sql
|
|
|
|
|
.query_row_optional(
|
|
|
|
|
"SELECT msg_id, first_serial, last_serial, descr \
|
|
|
|
|
"SELECT msg_id, first_serial, last_serial \
|
|
|
|
|
FROM smtp_status_updates LIMIT 1",
|
|
|
|
|
(),
|
|
|
|
|
|row| {
|
|
|
|
|
let instance_id: MsgId = row.get(0)?;
|
|
|
|
|
let first_serial: i64 = row.get(1)?;
|
|
|
|
|
let last_serial: StatusUpdateSerial = row.get(2)?;
|
|
|
|
|
let descr: String = row.get(3)?;
|
|
|
|
|
Ok((instance_id, first_serial, last_serial, descr))
|
|
|
|
|
Ok((instance_id, first_serial, last_serial))
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
.await?;
|
|
|
|
|
@@ -609,7 +607,7 @@ impl Context {
|
|
|
|
|
/// Attempts to send queued webxdc status updates.
|
|
|
|
|
pub(crate) async fn flush_status_updates(&self) -> Result<()> {
|
|
|
|
|
loop {
|
|
|
|
|
let (instance_id, first, last, descr) = match self.smtp_status_update_get().await? {
|
|
|
|
|
let (instance_id, first, last) = match self.smtp_status_update_get().await? {
|
|
|
|
|
Some(res) => res,
|
|
|
|
|
None => return Ok(()),
|
|
|
|
|
};
|
|
|
|
|
@@ -626,7 +624,7 @@ impl Context {
|
|
|
|
|
let mut status_update = Message {
|
|
|
|
|
chat_id: instance.chat_id,
|
|
|
|
|
viewtype: Viewtype::Text,
|
|
|
|
|
text: descr.to_string(),
|
|
|
|
|
text: BODY_DESCR.to_string(),
|
|
|
|
|
hidden: true,
|
|
|
|
|
..Default::default()
|
|
|
|
|
};
|
|
|
|
|
@@ -1133,7 +1131,6 @@ mod tests {
|
|
|
|
|
t.send_webxdc_status_update(
|
|
|
|
|
instance.id,
|
|
|
|
|
r#"{"info": "foo", "summary":"bar", "document":"doc", "payload": 42}"#,
|
|
|
|
|
"descr",
|
|
|
|
|
)
|
|
|
|
|
.await?;
|
|
|
|
|
assert!(!instance.is_forwarded());
|
|
|
|
|
@@ -1184,7 +1181,6 @@ mod tests {
|
|
|
|
|
.send_webxdc_status_update(
|
|
|
|
|
alice_instance.id,
|
|
|
|
|
r#"{"payload":7,"info": "i","summary":"s"}"#,
|
|
|
|
|
"d",
|
|
|
|
|
)
|
|
|
|
|
.await?;
|
|
|
|
|
assert_eq!(alice_grp.get_msg_cnt(&alice).await?, 2);
|
|
|
|
|
@@ -1267,7 +1263,7 @@ mod tests {
|
|
|
|
|
.await
|
|
|
|
|
.is_ok());
|
|
|
|
|
assert!(bob
|
|
|
|
|
.send_webxdc_status_update(bob_instance.id, r#"{"payload":42}"#, "descr")
|
|
|
|
|
.send_webxdc_status_update(bob_instance.id, r#"{"payload":42}"#)
|
|
|
|
|
.await
|
|
|
|
|
.is_err());
|
|
|
|
|
assert_eq!(
|
|
|
|
|
@@ -1279,7 +1275,7 @@ mod tests {
|
|
|
|
|
// Once the contact request is accepted, Bob can send updates
|
|
|
|
|
bob_chat.id.accept(&bob).await?;
|
|
|
|
|
assert!(bob
|
|
|
|
|
.send_webxdc_status_update(bob_instance.id, r#"{"payload":42}"#, "descr")
|
|
|
|
|
.send_webxdc_status_update(bob_instance.id, r#"{"payload":42}"#)
|
|
|
|
|
.await
|
|
|
|
|
.is_ok());
|
|
|
|
|
assert_eq!(
|
|
|
|
|
@@ -1310,7 +1306,6 @@ mod tests {
|
|
|
|
|
.send_webxdc_status_update(
|
|
|
|
|
alice_instance.id,
|
|
|
|
|
r#"{"payload": 7, "summary":"sum", "document":"doc"}"#,
|
|
|
|
|
"bla",
|
|
|
|
|
)
|
|
|
|
|
.await?;
|
|
|
|
|
alice.flush_status_updates().await?;
|
|
|
|
|
@@ -1437,7 +1432,7 @@ mod tests {
|
|
|
|
|
.await?;
|
|
|
|
|
chat_id.set_draft(&t, Some(&mut instance)).await?;
|
|
|
|
|
let instance = chat_id.get_draft(&t).await?.unwrap();
|
|
|
|
|
t.send_webxdc_status_update(instance.id, r#"{"payload": 42}"#, "descr")
|
|
|
|
|
t.send_webxdc_status_update(instance.id, r#"{"payload": 42}"#)
|
|
|
|
|
.await?;
|
|
|
|
|
assert_eq!(
|
|
|
|
|
t.get_webxdc_status_updates(instance.id, StatusUpdateSerial(0))
|
|
|
|
|
@@ -1520,12 +1515,12 @@ mod tests {
|
|
|
|
|
assert_eq!(update_id1_duplicate, None);
|
|
|
|
|
|
|
|
|
|
assert!(t
|
|
|
|
|
.send_webxdc_status_update(instance.id, "\n\n\n", "")
|
|
|
|
|
.send_webxdc_status_update(instance.id, "\n\n\n")
|
|
|
|
|
.await
|
|
|
|
|
.is_err());
|
|
|
|
|
|
|
|
|
|
assert!(t
|
|
|
|
|
.send_webxdc_status_update(instance.id, "bad json", "")
|
|
|
|
|
.send_webxdc_status_update(instance.id, "bad json")
|
|
|
|
|
.await
|
|
|
|
|
.is_err());
|
|
|
|
|
|
|
|
|
|
@@ -1584,7 +1579,6 @@ mod tests {
|
|
|
|
|
t.send_webxdc_status_update(
|
|
|
|
|
instance.id,
|
|
|
|
|
r#"{"payload" : 1, "sender": "that is not used"}"#,
|
|
|
|
|
"",
|
|
|
|
|
)
|
|
|
|
|
.await?;
|
|
|
|
|
assert_eq!(
|
|
|
|
|
@@ -1719,11 +1713,7 @@ mod tests {
|
|
|
|
|
assert!(!sent1.payload().contains("report-type=status-update"));
|
|
|
|
|
|
|
|
|
|
alice
|
|
|
|
|
.send_webxdc_status_update(
|
|
|
|
|
alice_instance.id,
|
|
|
|
|
r#"{"payload" : {"foo":"bar"}}"#,
|
|
|
|
|
"descr text",
|
|
|
|
|
)
|
|
|
|
|
.send_webxdc_status_update(alice_instance.id, r#"{"payload" : {"foo":"bar"}}"#)
|
|
|
|
|
.await?;
|
|
|
|
|
alice.flush_status_updates().await?;
|
|
|
|
|
expect_status_update_event(&alice, alice_instance.id).await?;
|
|
|
|
|
@@ -1732,7 +1722,7 @@ mod tests {
|
|
|
|
|
assert!(alice_update.hidden);
|
|
|
|
|
assert_eq!(alice_update.viewtype, Viewtype::Text);
|
|
|
|
|
assert_eq!(alice_update.get_filename(), None);
|
|
|
|
|
assert_eq!(alice_update.text, "descr text".to_string());
|
|
|
|
|
assert_eq!(alice_update.text, BODY_DESCR.to_string());
|
|
|
|
|
assert_eq!(alice_update.chat_id, alice_instance.chat_id);
|
|
|
|
|
assert_eq!(
|
|
|
|
|
alice_update.parent(&alice).await?.unwrap().id,
|
|
|
|
|
@@ -1740,7 +1730,7 @@ mod tests {
|
|
|
|
|
);
|
|
|
|
|
assert_eq!(alice_chat.id.get_msg_cnt(&alice).await?, 1);
|
|
|
|
|
assert!(sent2.payload().contains("report-type=status-update"));
|
|
|
|
|
assert!(sent2.payload().contains("descr text"));
|
|
|
|
|
assert!(sent2.payload().contains(BODY_DESCR));
|
|
|
|
|
assert_eq!(
|
|
|
|
|
alice
|
|
|
|
|
.get_webxdc_status_updates(alice_instance.id, StatusUpdateSerial(0))
|
|
|
|
|
@@ -1749,11 +1739,7 @@ mod tests {
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
alice
|
|
|
|
|
.send_webxdc_status_update(
|
|
|
|
|
alice_instance.id,
|
|
|
|
|
r#"{"payload":{"snipp":"snapp"}}"#,
|
|
|
|
|
"bla text",
|
|
|
|
|
)
|
|
|
|
|
.send_webxdc_status_update(alice_instance.id, r#"{"payload":{"snipp":"snapp"}}"#)
|
|
|
|
|
.await?;
|
|
|
|
|
assert_eq!(
|
|
|
|
|
alice
|
|
|
|
|
@@ -1822,31 +1808,23 @@ mod tests {
|
|
|
|
|
+ &String::from_utf8(vec![b'a'; STATUS_UPDATE_SIZE_MAX])?
|
|
|
|
|
+ r#""}"#;
|
|
|
|
|
alice
|
|
|
|
|
.send_webxdc_status_update(alice_instance.id, &(update1_str.clone() + "}"), "descr1")
|
|
|
|
|
.send_webxdc_status_update(alice_instance.id, &(update1_str.clone() + "}"))
|
|
|
|
|
.await?;
|
|
|
|
|
alice
|
|
|
|
|
.send_webxdc_status_update(
|
|
|
|
|
alice_instance.id,
|
|
|
|
|
r#"{"payload" : {"foo":"bar2"}}"#,
|
|
|
|
|
"descr2",
|
|
|
|
|
)
|
|
|
|
|
.send_webxdc_status_update(alice_instance.id, r#"{"payload" : {"foo":"bar2"}}"#)
|
|
|
|
|
.await?;
|
|
|
|
|
alice
|
|
|
|
|
.send_webxdc_status_update(
|
|
|
|
|
alice_instance.id,
|
|
|
|
|
r#"{"payload" : {"foo":"bar3"}}"#,
|
|
|
|
|
"descr3",
|
|
|
|
|
)
|
|
|
|
|
.send_webxdc_status_update(alice_instance.id, r#"{"payload" : {"foo":"bar3"}}"#)
|
|
|
|
|
.await?;
|
|
|
|
|
alice.flush_status_updates().await?;
|
|
|
|
|
|
|
|
|
|
// There's the message stack, so we pop messages in the reverse order.
|
|
|
|
|
let sent3 = &alice.pop_sent_msg().await;
|
|
|
|
|
let alice_update = sent3.load_from_db().await;
|
|
|
|
|
assert_eq!(alice_update.text, "descr3".to_string());
|
|
|
|
|
assert_eq!(alice_update.text, BODY_DESCR.to_string());
|
|
|
|
|
let sent2 = &alice.pop_sent_msg().await;
|
|
|
|
|
let alice_update = sent2.load_from_db().await;
|
|
|
|
|
assert_eq!(alice_update.text, "descr3".to_string());
|
|
|
|
|
assert_eq!(alice_update.text, BODY_DESCR.to_string());
|
|
|
|
|
assert_eq!(alice_chat.id.get_msg_cnt(&alice).await?, 1);
|
|
|
|
|
|
|
|
|
|
// Bob receives the instance.
|
|
|
|
|
@@ -1897,7 +1875,7 @@ mod tests {
|
|
|
|
|
(None, StatusUpdateSerial(u32::MAX))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
t.send_webxdc_status_update(instance.id, r#"{"payload": 1}"#, "bla")
|
|
|
|
|
t.send_webxdc_status_update(instance.id, r#"{"payload": 1}"#)
|
|
|
|
|
.await?;
|
|
|
|
|
let (object, first_new) = t
|
|
|
|
|
.render_webxdc_status_update_object(instance.id, first, last, None)
|
|
|
|
|
@@ -1913,13 +1891,13 @@ mod tests {
|
|
|
|
|
let t = TestContext::new_alice().await;
|
|
|
|
|
let chat_id = create_group_chat(&t, ProtectionStatus::Unprotected, "a chat").await?;
|
|
|
|
|
let instance = send_webxdc_instance(&t, chat_id).await?;
|
|
|
|
|
t.send_webxdc_status_update(instance.id, r#"{"payload": 1}"#, "d")
|
|
|
|
|
t.send_webxdc_status_update(instance.id, r#"{"payload": 1}"#)
|
|
|
|
|
.await?;
|
|
|
|
|
t.send_webxdc_status_update(instance.id, r#"{"payload": 2}"#, "d")
|
|
|
|
|
t.send_webxdc_status_update(instance.id, r#"{"payload": 2}"#)
|
|
|
|
|
.await?;
|
|
|
|
|
t.send_webxdc_status_update(instance.id, r#"{"payload": 3}"#, "d")
|
|
|
|
|
t.send_webxdc_status_update(instance.id, r#"{"payload": 3}"#)
|
|
|
|
|
.await?;
|
|
|
|
|
t.send_webxdc_status_update(instance.id, r#"{"payload": 4}"#, "d")
|
|
|
|
|
t.send_webxdc_status_update(instance.id, r#"{"payload": 4}"#)
|
|
|
|
|
.await?;
|
|
|
|
|
let (json, first_new) = t
|
|
|
|
|
.render_webxdc_status_update_object(
|
|
|
|
|
@@ -1964,17 +1942,17 @@ mod tests {
|
|
|
|
|
let instance3 = send_webxdc_instance(&t, chat_id).await?;
|
|
|
|
|
assert!(t.smtp_status_update_get().await?.is_none());
|
|
|
|
|
|
|
|
|
|
t.send_webxdc_status_update(instance1.id, r#"{"payload": "1a"}"#, "descr1a")
|
|
|
|
|
t.send_webxdc_status_update(instance1.id, r#"{"payload": "1a"}"#)
|
|
|
|
|
.await?;
|
|
|
|
|
t.send_webxdc_status_update(instance2.id, r#"{"payload": "2a"}"#, "descr2a")
|
|
|
|
|
t.send_webxdc_status_update(instance2.id, r#"{"payload": "2a"}"#)
|
|
|
|
|
.await?;
|
|
|
|
|
t.send_webxdc_status_update(instance2.id, r#"{"payload": "2b"}"#, "descr2b")
|
|
|
|
|
t.send_webxdc_status_update(instance2.id, r#"{"payload": "2b"}"#)
|
|
|
|
|
.await?;
|
|
|
|
|
t.send_webxdc_status_update(instance3.id, r#"{"payload": "3a"}"#, "descr3a")
|
|
|
|
|
t.send_webxdc_status_update(instance3.id, r#"{"payload": "3a"}"#)
|
|
|
|
|
.await?;
|
|
|
|
|
t.send_webxdc_status_update(instance3.id, r#"{"payload": "3b"}"#, "descr3b")
|
|
|
|
|
t.send_webxdc_status_update(instance3.id, r#"{"payload": "3b"}"#)
|
|
|
|
|
.await?;
|
|
|
|
|
t.send_webxdc_status_update(instance3.id, r#"{"payload": "3c"}"#, "descr3c")
|
|
|
|
|
t.send_webxdc_status_update(instance3.id, r#"{"payload": "3c"}"#)
|
|
|
|
|
.await?;
|
|
|
|
|
assert_eq!(
|
|
|
|
|
t.sql
|
|
|
|
|
@@ -1986,7 +1964,7 @@ mod tests {
|
|
|
|
|
// order of smtp_status_update_get() is not defined, therefore the more complicated test
|
|
|
|
|
let mut instances_checked = 0;
|
|
|
|
|
for i in 0..3 {
|
|
|
|
|
let (instance, min_ser, max_ser, descr) = t.smtp_status_update_get().await?.unwrap();
|
|
|
|
|
let (instance, min_ser, max_ser) = t.smtp_status_update_get().await?.unwrap();
|
|
|
|
|
t.smtp_status_update_pop_serials(
|
|
|
|
|
instance,
|
|
|
|
|
min_ser,
|
|
|
|
|
@@ -1996,15 +1974,14 @@ mod tests {
|
|
|
|
|
let min_ser: u32 = min_ser.try_into()?;
|
|
|
|
|
if instance == instance1.id {
|
|
|
|
|
assert_eq!(min_ser, max_ser.to_u32());
|
|
|
|
|
assert_eq!(descr, "descr1a");
|
|
|
|
|
|
|
|
|
|
instances_checked += 1;
|
|
|
|
|
} else if instance == instance2.id {
|
|
|
|
|
assert_eq!(min_ser, max_ser.to_u32() - 1);
|
|
|
|
|
assert_eq!(descr, "descr2b");
|
|
|
|
|
|
|
|
|
|
instances_checked += 1;
|
|
|
|
|
} else if instance == instance3.id {
|
|
|
|
|
assert_eq!(min_ser, max_ser.to_u32() - 2);
|
|
|
|
|
assert_eq!(descr, "descr3c");
|
|
|
|
|
instances_checked += 1;
|
|
|
|
|
} else {
|
|
|
|
|
bail!("unexpected instance");
|
|
|
|
|
@@ -2042,11 +2019,11 @@ mod tests {
|
|
|
|
|
let mut alice_instance = alice_chat_id.get_draft(&alice).await?.unwrap();
|
|
|
|
|
|
|
|
|
|
alice
|
|
|
|
|
.send_webxdc_status_update(alice_instance.id, r#"{"payload": {"foo":"bar"}}"#, "descr")
|
|
|
|
|
.send_webxdc_status_update(alice_instance.id, r#"{"payload": {"foo":"bar"}}"#)
|
|
|
|
|
.await?;
|
|
|
|
|
expect_status_update_event(&alice, alice_instance.id).await?;
|
|
|
|
|
alice
|
|
|
|
|
.send_webxdc_status_update(alice_instance.id, r#"{"payload":42, "info":"i"}"#, "descr")
|
|
|
|
|
.send_webxdc_status_update(alice_instance.id, r#"{"payload":42, "info":"i"}"#)
|
|
|
|
|
.await?;
|
|
|
|
|
expect_status_update_event(&alice, alice_instance.id).await?;
|
|
|
|
|
assert_eq!(
|
|
|
|
|
@@ -2093,7 +2070,7 @@ mod tests {
|
|
|
|
|
let chat_id = create_group_chat(&t, ProtectionStatus::Unprotected, "foo").await?;
|
|
|
|
|
let msg_id = send_text_msg(&t, chat_id, "ho!".to_string()).await?;
|
|
|
|
|
assert!(t
|
|
|
|
|
.send_webxdc_status_update(msg_id, r#"{"foo":"bar"}"#, "descr")
|
|
|
|
|
.send_webxdc_status_update(msg_id, r#"{"foo":"bar"}"#)
|
|
|
|
|
.await
|
|
|
|
|
.is_err());
|
|
|
|
|
Ok(())
|
|
|
|
|
@@ -2387,11 +2364,7 @@ sth_for_the = "future""#
|
|
|
|
|
assert_eq!(info.summary, "".to_string());
|
|
|
|
|
|
|
|
|
|
alice
|
|
|
|
|
.send_webxdc_status_update(
|
|
|
|
|
alice_instance.id,
|
|
|
|
|
r#"{"summary":"sum: 1", "payload":1}"#,
|
|
|
|
|
"descr",
|
|
|
|
|
)
|
|
|
|
|
.send_webxdc_status_update(alice_instance.id, r#"{"summary":"sum: 1", "payload":1}"#)
|
|
|
|
|
.await?;
|
|
|
|
|
alice.flush_status_updates().await?;
|
|
|
|
|
let sent_update1 = &alice.pop_sent_msg().await;
|
|
|
|
|
@@ -2402,11 +2375,7 @@ sth_for_the = "future""#
|
|
|
|
|
assert_eq!(info.summary, "sum: 1".to_string());
|
|
|
|
|
|
|
|
|
|
alice
|
|
|
|
|
.send_webxdc_status_update(
|
|
|
|
|
alice_instance.id,
|
|
|
|
|
r#"{"summary":"sum: 2", "payload":2}"#,
|
|
|
|
|
"descr",
|
|
|
|
|
)
|
|
|
|
|
.send_webxdc_status_update(alice_instance.id, r#"{"summary":"sum: 2", "payload":2}"#)
|
|
|
|
|
.await?;
|
|
|
|
|
alice.flush_status_updates().await?;
|
|
|
|
|
let sent_update2 = &alice.pop_sent_msg().await;
|
|
|
|
|
@@ -2457,7 +2426,6 @@ sth_for_the = "future""#
|
|
|
|
|
.send_webxdc_status_update(
|
|
|
|
|
alice_instance.id,
|
|
|
|
|
r#"{"document":"my file", "payload":1337}"#,
|
|
|
|
|
"descr",
|
|
|
|
|
)
|
|
|
|
|
.await?;
|
|
|
|
|
alice.flush_status_updates().await?;
|
|
|
|
|
@@ -2497,7 +2465,6 @@ sth_for_the = "future""#
|
|
|
|
|
.send_webxdc_status_update(
|
|
|
|
|
alice_instance.id,
|
|
|
|
|
r#"{"info":"this appears in-chat", "payload":"sth. else"}"#,
|
|
|
|
|
"descr text",
|
|
|
|
|
)
|
|
|
|
|
.await?;
|
|
|
|
|
alice.flush_status_updates().await?;
|
|
|
|
|
@@ -2575,13 +2542,13 @@ sth_for_the = "future""#
|
|
|
|
|
// Alice sends two info messages in a row;
|
|
|
|
|
// the second one removes the first one as there is nothing in between
|
|
|
|
|
alice
|
|
|
|
|
.send_webxdc_status_update(alice_instance.id, r#"{"info":"i1", "payload":1}"#, "d")
|
|
|
|
|
.send_webxdc_status_update(alice_instance.id, r#"{"info":"i1", "payload":1}"#)
|
|
|
|
|
.await?;
|
|
|
|
|
alice.flush_status_updates().await?;
|
|
|
|
|
let sent2 = &alice.pop_sent_msg().await;
|
|
|
|
|
assert_eq!(alice_chat.id.get_msg_cnt(&alice).await?, 2);
|
|
|
|
|
alice
|
|
|
|
|
.send_webxdc_status_update(alice_instance.id, r#"{"info":"i2", "payload":2}"#, "d")
|
|
|
|
|
.send_webxdc_status_update(alice_instance.id, r#"{"info":"i2", "payload":2}"#)
|
|
|
|
|
.await?;
|
|
|
|
|
alice.flush_status_updates().await?;
|
|
|
|
|
let sent3 = &alice.pop_sent_msg().await;
|
|
|
|
|
@@ -2608,12 +2575,12 @@ sth_for_the = "future""#
|
|
|
|
|
let chat_id = create_group_chat(&t, ProtectionStatus::Unprotected, "c").await?;
|
|
|
|
|
let instance = send_webxdc_instance(&t, chat_id).await?;
|
|
|
|
|
|
|
|
|
|
t.send_webxdc_status_update(instance.id, r#"{"info":"i1", "payload":1}"#, "d")
|
|
|
|
|
t.send_webxdc_status_update(instance.id, r#"{"info":"i1", "payload":1}"#)
|
|
|
|
|
.await?;
|
|
|
|
|
assert_eq!(chat_id.get_msg_cnt(&t).await?, 2);
|
|
|
|
|
send_text_msg(&t, chat_id, "msg between info".to_string()).await?;
|
|
|
|
|
assert_eq!(chat_id.get_msg_cnt(&t).await?, 3);
|
|
|
|
|
t.send_webxdc_status_update(instance.id, r#"{"info":"i2", "payload":2}"#, "d")
|
|
|
|
|
t.send_webxdc_status_update(instance.id, r#"{"info":"i2", "payload":2}"#)
|
|
|
|
|
.await?;
|
|
|
|
|
assert_eq!(chat_id.get_msg_cnt(&t).await?, 4);
|
|
|
|
|
|
|
|
|
|
@@ -2642,7 +2609,7 @@ sth_for_the = "future""#
|
|
|
|
|
let alice_instance = send_webxdc_instance(&alice, alice_chat_id).await?;
|
|
|
|
|
let sent1 = &alice.pop_sent_msg().await;
|
|
|
|
|
alice
|
|
|
|
|
.send_webxdc_status_update(alice_instance.id, r#"{"payload":42}"#, "descr")
|
|
|
|
|
.send_webxdc_status_update(alice_instance.id, r#"{"payload":42}"#)
|
|
|
|
|
.await?;
|
|
|
|
|
alice.flush_status_updates().await?;
|
|
|
|
|
let sent2 = &alice.pop_sent_msg().await;
|
|
|
|
|
@@ -2662,7 +2629,7 @@ sth_for_the = "future""#
|
|
|
|
|
Contact::create(&bob, "", "claire@example.org").await?,
|
|
|
|
|
)
|
|
|
|
|
.await?;
|
|
|
|
|
bob.send_webxdc_status_update(bob_instance.id, r#"{"payload":43}"#, "descr")
|
|
|
|
|
bob.send_webxdc_status_update(bob_instance.id, r#"{"payload":43}"#)
|
|
|
|
|
.await?;
|
|
|
|
|
bob.flush_status_updates().await?;
|
|
|
|
|
let sent3 = bob.pop_sent_msg().await;
|
|
|
|
|
@@ -2700,7 +2667,6 @@ sth_for_the = "future""#
|
|
|
|
|
t.send_webxdc_status_update(
|
|
|
|
|
instance_id,
|
|
|
|
|
r#"{"summary":"real summary", "payload": 42}"#,
|
|
|
|
|
"descr",
|
|
|
|
|
)
|
|
|
|
|
.await?;
|
|
|
|
|
let instance = Message::load_from_db(&t, instance_id).await?;
|
|
|
|
|
@@ -2778,7 +2744,6 @@ sth_for_the = "future""#
|
|
|
|
|
bob.send_webxdc_status_update(
|
|
|
|
|
bob_instance.id,
|
|
|
|
|
r#"{"payload":7,"info": "i","summary":"s"}"#,
|
|
|
|
|
"",
|
|
|
|
|
)
|
|
|
|
|
.await?;
|
|
|
|
|
bob.flush_status_updates().await?;
|
|
|
|
|
@@ -2898,7 +2863,6 @@ sth_for_the = "future""#
|
|
|
|
|
.send_webxdc_status_update(
|
|
|
|
|
alice_instance.id,
|
|
|
|
|
r#"{"payload":"p","info":"i","aNewUnknownProperty":"x","max_serial":123}"#,
|
|
|
|
|
"Some description",
|
|
|
|
|
)
|
|
|
|
|
.await?;
|
|
|
|
|
alice.flush_status_updates().await?;
|
|
|
|
|
@@ -2997,7 +2961,6 @@ sth_for_the = "future""#
|
|
|
|
|
"{{\"payload\":7,\"info\": \"Alice moved\",\"notify\":[\"{}\"]}}",
|
|
|
|
|
bob_instance.get_webxdc_self_addr(&bob).await?
|
|
|
|
|
),
|
|
|
|
|
"d",
|
|
|
|
|
)
|
|
|
|
|
.await?;
|
|
|
|
|
alice.flush_status_updates().await?;
|
|
|
|
|
@@ -3042,7 +3005,7 @@ sth_for_the = "future""#
|
|
|
|
|
bob_instance.get_webxdc_self_addr(&bob).await?,
|
|
|
|
|
fiona_instance.get_webxdc_self_addr(&fiona).await?
|
|
|
|
|
),
|
|
|
|
|
"d",
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
|
.await?;
|
|
|
|
|
alice.flush_status_updates().await?;
|
|
|
|
|
@@ -3088,7 +3051,6 @@ sth_for_the = "future""#
|
|
|
|
|
"{{\"payload\":7,\"info\": \"moved\", \"notify\":[\"{}\"]}}",
|
|
|
|
|
alice2_instance.get_webxdc_self_addr(&alice2).await?
|
|
|
|
|
),
|
|
|
|
|
"d",
|
|
|
|
|
)
|
|
|
|
|
.await?;
|
|
|
|
|
alice.flush_status_updates().await?;
|
|
|
|
|
@@ -3125,7 +3087,6 @@ sth_for_the = "future""#
|
|
|
|
|
"{{\"payload\":7,\"summary\": \"4 moves done\",\"notify\":[\"{}\"]}}",
|
|
|
|
|
bob_instance.get_webxdc_self_addr(&bob).await?
|
|
|
|
|
),
|
|
|
|
|
"d",
|
|
|
|
|
)
|
|
|
|
|
.await?;
|
|
|
|
|
alice.flush_status_updates().await?;
|
|
|
|
|
@@ -3154,7 +3115,6 @@ sth_for_the = "future""#
|
|
|
|
|
.send_webxdc_status_update(
|
|
|
|
|
instance.id,
|
|
|
|
|
r##"{"payload": "my deeplink data", "info": "my move!", "href": "#foobar"}"##,
|
|
|
|
|
"d",
|
|
|
|
|
)
|
|
|
|
|
.await?;
|
|
|
|
|
alice.flush_status_updates().await?;
|
|
|
|
|
|