mirror of
https://github.com/chatmail/core.git
synced 2026-04-18 05:56:31 +03:00
api: Put the chattype into the SecurejoinInviterProgress event (#7181)
Quoting @adbenitez: > I have been using the SecurejoinInviterProgress event to show a welcome message when user scan the QR/link of the bot (== starts a chat with the bot) > but this have a big problem: in that event all you know is that a contact completed the secure-join process, you don't know if it was via certain 1:1 invite link or a group invitation, then a group-invite bot would send you a help message in 1:1 every time you join a group with it Since it's easy enough to add this information to the SecurejoinInviterProgress event, I wrote a PR to do so.
This commit is contained in:
@@ -365,6 +365,29 @@ async fn test_setup_contact_bob_knows_alice() -> Result<()> {
|
||||
alice.recv_msg_trash(&sent).await;
|
||||
assert_eq!(contact_bob.is_verified(alice).await?, true);
|
||||
|
||||
// Check Alice signalled success via the SecurejoinInviterProgress event.
|
||||
let event = alice
|
||||
.evtracker
|
||||
.get_matching(|evt| {
|
||||
matches!(
|
||||
evt,
|
||||
EventType::SecurejoinInviterProgress { progress: 1000, .. }
|
||||
)
|
||||
})
|
||||
.await;
|
||||
match event {
|
||||
EventType::SecurejoinInviterProgress {
|
||||
contact_id,
|
||||
chat_type,
|
||||
progress,
|
||||
} => {
|
||||
assert_eq!(contact_id, contact_bob.id);
|
||||
assert_eq!(chat_type, Chattype::Single);
|
||||
assert_eq!(progress, 1000);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
let sent = alice.pop_sent_msg().await;
|
||||
let msg = bob.parse_msg(&sent).await;
|
||||
assert!(msg.was_encrypted());
|
||||
@@ -515,6 +538,29 @@ async fn test_secure_join() -> Result<()> {
|
||||
alice.recv_msg_trash(&sent).await;
|
||||
assert_eq!(contact_bob.is_verified(&alice).await?, true);
|
||||
|
||||
// Check Alice signalled success via the SecurejoinInviterProgress event.
|
||||
let event = alice
|
||||
.evtracker
|
||||
.get_matching(|evt| {
|
||||
matches!(
|
||||
evt,
|
||||
EventType::SecurejoinInviterProgress { progress: 1000, .. }
|
||||
)
|
||||
})
|
||||
.await;
|
||||
match event {
|
||||
EventType::SecurejoinInviterProgress {
|
||||
contact_id,
|
||||
chat_type,
|
||||
progress,
|
||||
} => {
|
||||
assert_eq!(contact_id, contact_bob.id);
|
||||
assert_eq!(chat_type, Chattype::Group);
|
||||
assert_eq!(progress, 1000);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
let sent = alice.pop_sent_msg().await;
|
||||
let msg = bob.parse_msg(&sent).await;
|
||||
assert!(msg.was_encrypted());
|
||||
|
||||
Reference in New Issue
Block a user