Skip to content

Commit 1f0a12a

Browse files
authored
fix: never notify SELF (#6251)
it may be handy for an xdc to have only one list of all adresses, or there may just be bugs. in any case, do not notify SELF, e.g. in a multi-device setup; we're also not doing this for other messages. this is also a preparation for having an option to notify ALL.
1 parent d06fa73 commit 1f0a12a

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

src/webxdc.rs

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ impl Context {
395395
});
396396
}
397397

398-
if notify && !notify_text.is_empty() {
398+
if notify && !notify_text.is_empty() && from_id != ContactId::SELF {
399399
self.emit_event(EventType::IncomingWebxdcNotify {
400400
contact_id: from_id,
401401
msg_id: notify_msg_id,
@@ -3037,6 +3037,47 @@ sth_for_the = "future""#
30373037
Ok(())
30383038
}
30393039

3040+
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
3041+
async fn test_webxdc_no_notify_self() -> Result<()> {
3042+
let mut tcm = TestContextManager::new();
3043+
let alice = tcm.alice().await;
3044+
let alice2 = tcm.alice().await;
3045+
3046+
let grp_id = alice
3047+
.create_group_with_members(ProtectionStatus::Unprotected, "grp", &[])
3048+
.await;
3049+
let alice_instance = send_webxdc_instance(&alice, grp_id).await?;
3050+
let sent1 = alice.pop_sent_msg().await;
3051+
let alice2_instance = alice2.recv_msg(&sent1).await;
3052+
assert_eq!(
3053+
alice_instance.get_webxdc_self_addr(&alice).await?,
3054+
alice2_instance.get_webxdc_self_addr(&alice2).await?
3055+
);
3056+
3057+
alice
3058+
.send_webxdc_status_update(
3059+
alice_instance.id,
3060+
&format!(
3061+
"{{\"payload\":7,\"info\": \"moved\", \"notify\":[\"{}\"]}}",
3062+
alice2_instance.get_webxdc_self_addr(&alice2).await?
3063+
),
3064+
"d",
3065+
)
3066+
.await?;
3067+
alice.flush_status_updates().await?;
3068+
let sent2 = alice.pop_sent_msg().await;
3069+
let info_msg = alice.get_last_msg().await;
3070+
assert!(info_msg.is_info());
3071+
assert!(!has_incoming_webxdc_event(&alice, info_msg, "moved").await);
3072+
3073+
alice2.recv_msg_trash(&sent2).await;
3074+
let info_msg = alice2.get_last_msg().await;
3075+
assert!(info_msg.is_info());
3076+
assert!(!has_incoming_webxdc_event(&alice2, info_msg, "moved").await);
3077+
3078+
Ok(())
3079+
}
3080+
30403081
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
30413082
async fn test_webxdc_notify_summary() -> Result<()> {
30423083
let mut tcm = TestContextManager::new();

0 commit comments

Comments
 (0)