From a7b4eec1fe6240265b737a269882d28aaf1dbe9a Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Mon, 19 Apr 2021 18:37:49 +0200 Subject: [PATCH] hkp: drop "upload" mails --- dist/email-templates/upload.htm.hbs | 26 -------------------------- dist/email-templates/upload.txt.hbs | 18 ------------------ src/mail.rs | 26 -------------------------- src/web/hkp.rs | 27 --------------------------- 4 files changed, 97 deletions(-) delete mode 100644 dist/email-templates/upload.htm.hbs delete mode 100644 dist/email-templates/upload.txt.hbs diff --git a/dist/email-templates/upload.htm.hbs b/dist/email-templates/upload.htm.hbs deleted file mode 100644 index 582d7d8..0000000 --- a/dist/email-templates/upload.htm.hbs +++ /dev/null @@ -1,26 +0,0 @@ - - - - - Your key upload on {{domain}} - - -

- Hi, -

- This is an automated message from {{domain}}. - If you didn't upload your key there, please ignore this message. -

- OpenPGP key: {{primary_fp}} -

- This key was just uploaded to keys.openpgp.org. If you want to allow others to find this key by e-mail address, please follow this link: -

- {{uri}} -

- You can find more info at {{domain}}/about. -

- {{base_uri}}
- distributing OpenPGP keys since 2019 - - - diff --git a/dist/email-templates/upload.txt.hbs b/dist/email-templates/upload.txt.hbs deleted file mode 100644 index bbbfcad..0000000 --- a/dist/email-templates/upload.txt.hbs +++ /dev/null @@ -1,18 +0,0 @@ -Hi, - -This is an automated message from {{domain}}. -If you didn't upload your key, please ignore this message. - -OpenPGP key: {{primary_fp}} - -This key was just uploaded to keys.openpgp.org. If you want to allow -others to find this key by e-mail address, please follow this link: - - {{uri}} - -You can find more info at {{base_uri}}/about - --- - -{{ base_uri }} -distributing OpenPGP keys since 2019 diff --git a/src/mail.rs b/src/mail.rs index ff042cb..88ddf06 100644 --- a/src/mail.rs +++ b/src/mail.rs @@ -148,32 +148,6 @@ impl Service { ) } - pub fn send_upload( - &self, - base_uri: &str, - tpk_name: String, - userid: &Email, - token: &str - ) -> Result<()> { - let ctx = context::Welcome { - lang: "en".to_owned(), - primary_fp: tpk_name, - uri: format!("{}/upload/{}", base_uri, token), - base_uri: base_uri.to_owned(), - domain: self.domain.clone(), - }; - - counters::inc_mail_sent("upload", userid); - - self.send( - &vec![userid], - &format!("Your key upload on {domain}", domain = self.domain), - "upload", - "en", - ctx, - ) - } - pub fn send_welcome( &self, base_uri: &str, diff --git a/src/web/hkp.rs b/src/web/hkp.rs index 84bca03..b5ea7d1 100644 --- a/src/web/hkp.rs +++ b/src/web/hkp.rs @@ -183,26 +183,9 @@ fn pks_add_ok( return format!("Upload successful."); } - // We send this out on the *second* time the key is uploaded (within one ratelimit period). - let uploaded_repeatedly = !rate_limiter.action_perform(format!("hkp-upload-{}", &key_fpr)); - if uploaded_repeatedly && rate_limiter.action_perform(format!("hkp-sent-{}", &primary_uid)) { - if send_upload_mail(&request_origin, &mail_service, key_fpr, &primary_uid, token) { - return format!("Upload successful. An upload information email has been sent."); - } - } return format!("Upload successful. Please note that identity information will only be published after verification. See {baseuri}/about/usage#gnupg-upload", baseuri = request_origin.get_base_uri()) } -fn send_upload_mail( - request_origin: &RequestOrigin, - mail_service: &mail::Service, - fpr: String, - primary_uid: &Email, - token: String, -) -> bool { - mail_service.send_upload(request_origin.get_base_uri(), fpr, primary_uid, &token).is_ok() -} - fn send_welcome_mail( request_origin: &RequestOrigin, mail_service: &mail::Service, @@ -460,16 +443,6 @@ mod tests { let upload_mail_1 = pop_mail(filemail_into.as_path()).unwrap(); assert!(upload_mail_1.is_none()); - // Add the first again a second time - we should get an upload mail - let response = client.post("/pks/add") - .body(post_data_first.as_bytes()) - .header(ContentType::Form) - .dispatch(); - assert_eq!(response.status(), Status::Ok); - - let upload_mail_2 = pop_mail(filemail_into.as_path()).unwrap(); - assert!(upload_mail_2.is_some()); - check_mr_responses_by_fingerprint(&client, &tpk_0, 0); check_mr_responses_by_fingerprint(&client, &tpk_1, 0); check_hr_responses_by_fingerprint(&client, &tpk_0, 0);