Skip to content

Commit 2f90b55

Browse files
authored
feat: Stock string for joining a channel (#7480)
Add a stock string `%1$s invited you to join this channel.\n\nWaiting for the device of %2$s to reply…`, which is shown when a user starts to join a channel. I did _not_ add an equivalent to `%1$s replied, waiting for being added to the group…`, which is shown when vg-auth-required was received. I don't think that this would add any information that's interesting to the user, other than 'something is happening, hang on'. And the more text on the screen, the less likely that anyone reads it. But if others think differently, we can also add it. With this PR, joining a channel looks like this: ``` Msg#2003: info (Contact#Contact#Info): Messages are end-to-end encrypted. [NOTICED][INFO] Msg#2004: info (Contact#Contact#Info): Alice invited you to join this channel. Waiting for the device of Alice to reply… [NOTICED][INFO] Msg#2007🔒: (Contact#Contact#2001): You joined the channel. [FRESH][INFO] ```
1 parent be3e202 commit 2f90b55

File tree

7 files changed

+40
-8
lines changed

7 files changed

+40
-8
lines changed

deltachat-ffi/deltachat.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7756,7 +7756,17 @@ void dc_event_unref(dc_event_t* event);
77567756
/// Subtitle for channel join qrcode svg image generated by the core.
77577757
///
77587758
/// `%1$s` will be replaced with the channel name.
7759-
#define DC_STR_SECURE_JOIN_CHANNEL_QR_DESC 201
7759+
#define DC_STR_SECURE_JOIN_CHANNEL_QR_DESC 201
7760+
7761+
/// "You joined the channel."
7762+
#define DC_STR_MSG_YOU_JOINED_CHANNEL 202
7763+
7764+
/// "%1$s invited you to join this channel. Waiting for the device of %2$s to reply…"
7765+
///
7766+
/// Added as an info-message directly after scanning a QR code for joining a broadcast channel.
7767+
///
7768+
/// `%1$s` and `%2$s` will both be replaced by the name of the inviter.
7769+
#define DC_STR_SECURE_JOIN_CHANNEL_STARTED 203
77607770

77617771
/// "Proxy Enabled"
77627772
///

deltachat-rpc-client/tests/test_securejoin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def check_account(ac, contact, inviter_side, please_wait_info_msg=False):
164164

165165
if please_wait_info_msg:
166166
first_msg = chat_msgs.pop(0).get_snapshot()
167-
assert first_msg.text == "Establishing connection, please wait…"
167+
assert "invited you to join this channel" in first_msg.text
168168
assert first_msg.is_info
169169

170170
member_added_msg = chat_msgs.pop(0).get_snapshot()

deltachat-rpc-client/tests/test_something.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ def check_account(ac, contact, inviter_side, please_wait_info_msg=False):
874874

875875
if please_wait_info_msg:
876876
first_msg = chat_msgs.pop(0).get_snapshot()
877-
assert first_msg.text == "Establishing connection, please wait…"
877+
assert "invited you to join this channel" in first_msg.text
878878
assert first_msg.is_info
879879

880880
member_added_msg = chat_msgs.pop(0).get_snapshot()

src/securejoin/bob.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,9 @@ pub(super) async fn start_protocol(context: &Context, invite: QrInvite) -> Resul
144144
}
145145

146146
// If we were not in the broadcast channel before, show a 'please wait' info message.
147-
// Since we don't have any specific stock string for this,
148-
// use the generic `Establishing connection, please wait…`
149147
if !is_contact_in_chat(context, joining_chat_id, ContactId::SELF).await? {
150-
let msg = stock_str::securejoin_wait(context).await;
148+
let msg =
149+
stock_str::secure_join_broadcast_started(context, invite.contact_id()).await;
151150
chat::add_info_msg(context, joining_chat_id, &msg).await?;
152151
}
153152
Ok(joining_chat_id)

src/stock_str.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,10 @@ https://delta.chat/donate"))]
429429
#[strum(props(fallback = "You joined the channel."))]
430430
MsgYouJoinedBroadcast = 202,
431431

432+
#[strum(props(fallback = "%1$s invited you to join this channel.\n\n\
433+
Waiting for the device of %2$s to reply…"))]
434+
SecureJoinBroadcastStarted = 203,
435+
432436
#[strum(props(
433437
fallback = "The attachment contains anonymous usage statistics, which helps us improve Delta Chat. Thank you!"
434438
))]
@@ -737,6 +741,21 @@ pub(crate) async fn msg_you_joined_broadcast(context: &Context) -> String {
737741
translated(context, StockMessage::MsgYouJoinedBroadcast).await
738742
}
739743

744+
/// Stock string: `%1$s invited you to join this channel. Waiting for the device of %2$s to reply…`.
745+
pub(crate) async fn secure_join_broadcast_started(
746+
context: &Context,
747+
inviter_contact_id: ContactId,
748+
) -> String {
749+
if let Ok(contact) = Contact::get_by_id(context, inviter_contact_id).await {
750+
translated(context, StockMessage::SecureJoinBroadcastStarted)
751+
.await
752+
.replace1(contact.get_display_name())
753+
.replace2(contact.get_display_name())
754+
} else {
755+
format!("secure_join_started: unknown contact {inviter_contact_id}")
756+
}
757+
}
758+
740759
/// Stock string: `You reacted %1$s to "%2$s"` or `%1$s reacted %2$s to "%3$s"`.
741760
pub(crate) async fn msg_reacted(
742761
context: &Context,
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
InBroadcast#Chat#2002: My Channel [2 member(s)] Icon: e9b6c7a78aa2e4f415644f55a553e73.png
22
--------------------------------------------------------------------------------
33
Msg#2003: info (Contact#Contact#Info): Messages are end-to-end encrypted. [NOTICED][INFO]
4-
Msg#2004: info (Contact#Contact#Info): Establishing connection, please wait… [NOTICED][INFO]
4+
Msg#2004: info (Contact#Contact#Info): Alice invited you to join this channel.
5+
6+
Waiting for the device of Alice to reply… [NOTICED][INFO]
57
Msg#2007🔒: (Contact#Contact#2001): You joined the channel. [FRESH][INFO]
68
--------------------------------------------------------------------------------

test-data/golden/test_sync_broadcast_bob

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
InBroadcast#Chat#2002: Channel [1 member(s)]
22
--------------------------------------------------------------------------------
33
Msg#2003: info (Contact#Contact#Info): Messages are end-to-end encrypted. [NOTICED][INFO]
4-
Msg#2004: info (Contact#Contact#Info): Establishing connection, please wait… [NOTICED][INFO]
4+
Msg#2004: info (Contact#Contact#Info): alice@example.org invited you to join this channel.
5+
6+
Waiting for the device of alice@example.org to reply… [NOTICED][INFO]
57
Msg#2008🔒: (Contact#Contact#2001): You joined the channel. [FRESH][INFO]
68
Msg#2010🔒: (Contact#Contact#2001): hi [FRESH]
79
Msg#2011🔒: (Contact#Contact#2001): Member Me removed by alice@example.org. [FRESH][INFO]

0 commit comments

Comments
 (0)