Skip to content

Commit 824c9f3

Browse files
committed
fix(email): use 'PostGuard' as sender display when no name is disclosed
When the signer discloses no name, the recipient email now reads 'PostGuard sent you files' instead of showing the raw sender email. Also drop 'via PostGuard' from the subject — it would be redundant when the sender is already 'PostGuard', and is cleaner for named senders too. Renames the two tests that previously asserted the email fallback.
1 parent 7d3aac0 commit 824c9f3

1 file changed

Lines changed: 14 additions & 17 deletions

File tree

src/email.rs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ struct MailStrings<'a> {
136136
}
137137

138138
const NL_STRINGS: MailStrings = MailStrings {
139-
subject_str: "heeft je een bestand gestuurd via PostGuard",
139+
subject_str: "heeft je bestanden gestuurd",
140140
sender_str: "heeft je bestanden gestuurd",
141141
expires_str: "Verloopt op",
142142
download_str: "Download jouw bestanden",
@@ -148,7 +148,7 @@ const NL_STRINGS: MailStrings = MailStrings {
148148
};
149149

150150
const EN_STRINGS: MailStrings = MailStrings {
151-
subject_str: "sent you files via PostGuard",
151+
subject_str: "sent you files",
152152
sender_str: "sent you files",
153153
expires_str: "Expires on",
154154
download_str: "Download your files",
@@ -221,11 +221,10 @@ fn build_body(html: String, text: String) -> Result<MultiPart, Box<dyn std::erro
221221
}
222222

223223
/// Resolve the display string and remaining attribute pills for the
224-
/// sender. When the signer disclosed their full name, the name takes the
225-
/// place of the bare email everywhere it would otherwise appear in the
226-
/// body, and is removed from the attribute pill list so it doesn't render
227-
/// twice. An empty disclosed value is treated as not disclosed, so we
228-
/// fall through to the email instead of rendering a blank.
224+
/// sender. When the signer disclosed a name it is used as the display;
225+
/// the name attribute is removed from the pill list so it doesn't render
226+
/// twice. An empty disclosed value is treated as not disclosed. When no
227+
/// name is available the display falls back to "PostGuard".
229228
fn sender_display(state: &FileState) -> (String, Vec<(String, String)>) {
230229
let mut attrs = state.sender_attributes.clone();
231230

@@ -239,9 +238,7 @@ fn sender_display(state: &FileState) -> (String, Vec<(String, String)>) {
239238
// driving licence (postguard#239 follow-up).
240239
.or_else(|| take_firstname_lastname_pair(&mut attrs));
241240

242-
let display = name
243-
.or_else(|| state.sender.clone())
244-
.unwrap_or_else(|| "Someone".to_string());
241+
let display = name.unwrap_or_else(|| "PostGuard".to_string());
245242
(display, attrs)
246243
}
247244

@@ -581,14 +578,14 @@ mod tests {
581578
String::new(),
582579
)]);
583580
let (display, _) = sender_display(&state);
584-
assert_eq!(display, "sender@example.com");
581+
assert_eq!(display, "PostGuard");
585582
}
586583

587584
#[test]
588-
fn sender_display_falls_back_to_email_when_no_name_disclosed() {
585+
fn sender_display_falls_back_to_postguard_when_no_name_disclosed() {
589586
let state = filestate_with_attrs(vec![("orgName".to_owned(), "Acme".to_owned())]);
590587
let (display, remaining) = sender_display(&state);
591-
assert_eq!(display, "sender@example.com");
588+
assert_eq!(display, "PostGuard");
592589
assert_eq!(remaining, vec![("orgName".to_owned(), "Acme".to_owned())]);
593590
}
594591

@@ -686,7 +683,7 @@ mod tests {
686683
// No lastName → no concatenation; the orphan firstName stays as a
687684
// pill so the recipient at least sees it instead of having it
688685
// silently dropped.
689-
assert_eq!(display, "sender@example.com");
686+
assert_eq!(display, "PostGuard");
690687
assert_eq!(
691688
remaining,
692689
vec![(
@@ -709,15 +706,15 @@ mod tests {
709706
),
710707
]);
711708
let (display, _) = sender_display(&state);
712-
assert_eq!(display, "sender@example.com");
709+
assert_eq!(display, "PostGuard");
713710
}
714711

715712
#[test]
716-
fn sender_display_uses_someone_when_no_sender_and_no_name() {
713+
fn sender_display_uses_postguard_when_no_name_disclosed() {
717714
let mut state = filestate_with_attrs(vec![]);
718715
state.sender = None;
719716
let (display, remaining) = sender_display(&state);
720-
assert_eq!(display, "Someone");
717+
assert_eq!(display, "PostGuard");
721718
assert!(remaining.is_empty());
722719
}
723720

0 commit comments

Comments
 (0)