Skip to content

Commit

Permalink
feat: Add "send copy to self" banner
Browse files Browse the repository at this point in the history
  • Loading branch information
JadedBlueEyes committed Aug 17, 2024
1 parent 1347597 commit ec8c56c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
3 changes: 2 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"title": "You've received a new message from {from_name}",
"top": "MusicBrainz user ''{from_name}'' has sent you the following message:",
"reply_link": "To reply, click here to send {from_name} an email.",
"reply_email": "Alternatively, please reply to this message."
"reply_email": "Alternatively, please reply to this message.",
"message_copy": "You sent this message to {to_name}"
},
"verify_email": {
"title": "Verify your email",
Expand Down
27 changes: 25 additions & 2 deletions src/templates/editor_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,29 @@ struct EditorMessage {
subject: String,
message: String,
contact_url: String,
/// If the sender has shared their email address.
///
/// If this is true, the user should be able to
/// reply to the email to reply to the message.
revealed_address: bool,
/// If this is a copy for the message sender.
///
/// If this is true, a banner should be added
/// to the email
#[serde(default)]
is_self_copy: bool,
}

pub(crate) fn editor_message(params: Value, l: Locale) -> Result<Mjml, TemplateError> {
let ctx: Option<EditorMessage> = serde_json::from_value(params)?;
let EditorMessage {
to_name,
ref to_name,
ref from_name,
subject: _,
message,
contact_url,
revealed_address,
is_self_copy,
} = ctx.unwrap_or_default();
// Reply via email is optional
Ok(view! {
Expand Down Expand Up @@ -59,6 +70,18 @@ pub(crate) fn editor_message(params: Value, l: Locale) -> Result<Mjml, TemplateE
<mj-section padding="20px 0">
<mj-column padding="0">
{ header().into() }
{ if is_self_copy {
view!{
<mj-wrapper
border="1px solid #E5E5E5"
background-color="#F5F5F5"
padding="5px 15px" >
<mj-text>
<p>{ Text::from(tl!(l, editor_message.message_copy, to_name )).into() }</p>
</mj-text>
</mj-wrapper>
}.into()
} else { view!(<></>).into() }}

<mj-text>
<p>{ Text::from(tl!(l, greeting_line, name = to_name)).into() }</p>
Expand Down Expand Up @@ -86,7 +109,7 @@ pub(crate) fn editor_message(params: Value, l: Locale) -> Result<Mjml, TemplateE
// <p>"Do not reply to this message. If you need help, please "<a href="https://metabrainz.org/contact">contact us</a>.</p>
</mj-text>
</mj-column>
</mj-section>
</mj-section>
</mj-body>
</mjml>

Expand Down

0 comments on commit ec8c56c

Please sign in to comment.