Skip to content

Commit

Permalink
dynamic url
Browse files Browse the repository at this point in the history
  • Loading branch information
fiji-flo committed May 15, 2023
1 parent a20d9ce commit 80c952c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/api/newsletter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ use crate::{
users::get_user,
Pool,
},
settings::SETTINGS,
};

const MDN_PLUS_LIST: &str = "mdnplus";
const SOURCE_URL_NEWSLETTER: &str = "https://developer.mozilla.org/en-US/newsletter";
const SOURCE_URL_SETTINGS: &str = "https://developer.mozilla.org/en-US/settings";

#[derive(Deserialize, Serialize)]
struct UserLookup {
Expand Down Expand Up @@ -60,7 +59,10 @@ pub async fn subscribe_anonymous_handler(
&subscription_req.email,
vec![MDN_PLUS_LIST.into()],
Some(SubscribeOpts {
source_url: Some(SOURCE_URL_NEWSLETTER.to_string()),
source_url: Some(format!(
"{}/en-US/newsletter",
&SETTINGS.application.document_base_url
)),
..Default::default()
}),
)
Expand All @@ -82,7 +84,10 @@ pub async fn subscribe(
vec![MDN_PLUS_LIST.into()],
Some(SubscribeOpts {
optin: Some(YesNo::Y),
source_url: Some(SOURCE_URL_SETTINGS.to_string()),
source_url: Some(format!(
"{}/en-US/settings",
&SETTINGS.application.document_base_url
)),
..Default::default()
}),
)
Expand Down

0 comments on commit 80c952c

Please sign in to comment.