Skip to content

Commit

Permalink
feat: Add "no vote" email
Browse files Browse the repository at this point in the history
  • Loading branch information
JadedBlueEyes committed Aug 22, 2024
1 parent be3b8f7 commit e349549
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
utoipa = { version = "4.2.3", features = ["axum_extras"] }
utoipa-swagger-ui = { version = "7.1.0", features = ["axum"] }
serde = { version = "1.0.203", features = ["derive"] }
mf1 = "0.1.4"
mf1 = "0.1.5"
sentry = { version = "0.34.0", features = ["tracing", "tower", "tower-http"] }
futures-util = "0.3.30"
futures = "0.3.30"
Expand Down
7 changes: 7 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,12 @@
"username_is": "Your MusicBrainz username is: { user_name }",
"reset_password": "If you have also forgotten your password, use this username and your email address to reset your password here:",
"in_error": "If you didn't initiate this request and feel that you've received this email in error, don't worry, you don't need to take any further action and can safely disregard this email."
},
"no_vote": {
"title": "Someone has voted against your edit #{ edit_id }",
"top": "MusicBrainz user ''{voter_name}'' has voted against your edit #{ edit_id }",
"reply": "To respond, please add your note at:",
"single_email": "Please note that this email will not be sent for every vote against an edit.",
"close_time": "To ensure time for you and other editors to respond, the soonest this edit will be rejected, if applicable, is {close_time}, 72 hours from the time of this email."
}
}
2 changes: 2 additions & 0 deletions src/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod edit_note;
mod editor_message;
mod email_in_use;
mod lost_username;
mod no_vote;
mod reset_password;
mod subscription;
mod verify_email;
Expand All @@ -29,6 +30,7 @@ pub fn get(template_id: &str) -> Option<Template> {
"email-in-use" => Some(email_in_use::email_in_use),
"reset-password" => Some(reset_password::reset_password),
"lost-username" => Some(lost_username::lost_username),
"no-vote" => Some(no_vote::no_vote),
_ => None,
}
}
85 changes: 85 additions & 0 deletions src/templates/no_vote.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
use std::borrow::Borrow;

use mf1::t_l_string as tl;
use mrml::{mjml::Mjml, text::Text};
use mrmx::WithAttribute;
use mrmx_macros::view;
use serde::Deserialize;
use serde_json::Value;

use crate::{components::*, Locale};

use super::TemplateError;

#[derive(Deserialize, Debug, Default)]
#[serde(default)]
struct NoVote {
to_name: String,
response_url: String,
prefs_url: String,
edit_id: u32,
voter_name: String,
close_time: String,
}

pub(crate) fn no_vote(params: Value, l: Locale) -> Result<Mjml, TemplateError> {
let ctx: Option<NoVote> = serde_json::from_value(params)?;
let NoVote {
to_name,
ref response_url,
prefs_url,
edit_id,
ref voter_name,
ref close_time,
} = ctx.unwrap_or_default();
Ok(view! {
<mjml>
<mj-head>
{ head().into() }
<mj-title>{ tl!(l, no_vote.title, edit_id = edit_id.to_string() ).borrow() }</mj-title>
</mj-head>
<mj-body width="500px" padding="0">
<mj-section padding="20px 0">
<mj-column padding="0">
{ header().into() }

<mj-text>
<p>{ Text::from(tl!(l, greeting_line, name = to_name)).into() }</p>
<p>{ Text::from(tl!(l, no_vote.top, voter_name, edit_id = edit_id.to_string() )).into() }</p>
<p>{ Text::from(tl!(l, no_vote.reply )).into() }</p>
</mj-text>

<mj-wrapper mj-class="wrapper">
<mj-text>
<p>
<a href={response_url}>{ Text::from(response_url).into()}</a>
</p>
</mj-text>
</mj-wrapper>


<mj-text>
<p>{ Text::from(tl!(l, link_copy_info)).into() }</p>
<p>{ Text::from(tl!(l, no_vote.single_email)).into() }</p>
<p>{ Text::from(tl!(l, no_vote.close_time, close_time)).into() }</p>
</mj-text>
<mj-text>
<p><em>{ Text::from(tl!(l, metabrainz_signoff)).into() }</em></p>
</mj-text>
<mj-divider padding="10px 15px" border-color="#F5F5F5" border-width="3px" />
<mj-text font-size="12px" color="#8D8D8D">
<p>
<a href={prefs_url}>{ Text::from(tl!(l, change_subscription_settings)).into() }</a>
</p>
<p>{ Text::from(tl!(l, do_not_reply)).into() }</p>
// <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-body>
</mjml>

})
}

0 comments on commit e349549

Please sign in to comment.