Skip to content

Commit 6f03d5b

Browse files
committed
feat: Add string 'Scan to join Channel'.
1 parent bcf4cdb commit 6f03d5b

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/qr_code_generator.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! # QR code generation module.
22
3-
use anyhow::Result;
3+
use anyhow::{Result, bail};
44
use base64::Engine as _;
55
use qrcodegen::{QrCode, QrCodeEcc};
66

@@ -108,8 +108,18 @@ async fn generate_join_group_qr_code(context: &Context, chat_id: ChatId) -> Resu
108108
None => None,
109109
};
110110

111+
let qrcode_description = match chat.typ {
112+
crate::constants::Chattype::Group => {
113+
stock_str::secure_join_group_qr_description(context, &chat).await
114+
}
115+
crate::constants::Chattype::OutBroadcast => {
116+
stock_str::secure_join_broadcast_qr_description(context, &chat).await
117+
}
118+
_ => bail!("Unexpected chat type {}", chat.typ),
119+
};
120+
111121
inner_generate_secure_join_qr_code(
112-
&stock_str::secure_join_group_qr_description(context, &chat).await,
122+
&qrcode_description,
113123
&securejoin::get_securejoin_qr(context, Some(chat_id)).await?,
114124
&color_int_to_hex_string(chat.get_color(context).await?),
115125
avatar,

src/stock_str.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,9 @@ https://delta.chat/donate"))]
442442

443443
#[strum(props(fallback = "You left the channel."))]
444444
MsgYouLeftBroadcast = 200,
445+
446+
#[strum(props(fallback = "Scan to join channel %1$s"))]
447+
SecureJoinBrodcastQRDescription = 201,
445448
}
446449

447450
impl StockMessage {
@@ -865,13 +868,20 @@ pub(crate) async fn setup_contact_qr_description(
865868
.replace1(&name)
866869
}
867870

868-
/// Stock string: `Scan to join %1$s`.
871+
/// Stock string: `Scan to join group %1$s`.
869872
pub(crate) async fn secure_join_group_qr_description(context: &Context, chat: &Chat) -> String {
870873
translated(context, StockMessage::SecureJoinGroupQRDescription)
871874
.await
872875
.replace1(chat.get_name())
873876
}
874877

878+
/// Stock string: `Scan to join channel %1$s`.
879+
pub(crate) async fn secure_join_broadcast_qr_description(context: &Context, chat: &Chat) -> String {
880+
translated(context, StockMessage::SecureJoinBrodcastQRDescription)
881+
.await
882+
.replace1(chat.get_name())
883+
}
884+
875885
/// Stock string: `%1$s verified.`.
876886
#[allow(dead_code)]
877887
pub(crate) async fn contact_verified(context: &Context, contact: &Contact) -> String {

0 commit comments

Comments
 (0)