i18n: streamline upload errors

This commit is contained in:
Vincent Breitmoser 2019-11-02 13:00:45 +01:00
parent f38f5ced40
commit 4934d15165
No known key found for this signature in database
GPG Key ID: 7BD18320DEADFA11
7 changed files with 97 additions and 122 deletions

5
dist/templates/400.html.hbs vendored Normal file
View File

@ -0,0 +1,5 @@
{{#> layout }}
<h3>{{ text "There was an error with your request:" }}</h3>
<p>{{ page/error }}</p>
{{/layout}}

View File

@ -1,5 +0,0 @@
{{#> layout }}
{{#with page}}
<p>{{ text "This address has already been verified." }}</p>
{{/with}}
{{/layout}}

View File

@ -1,18 +1,9 @@
{{#> layout}}
{{#with page}}
<div id="verification-result">
{{#if verified}}
<p>
{{ text "Your key <span class=\"fingerprint\">{{ key_fpr }}</span> is now published for the identity <a href=\"{{userid_link}}\" target=\"_blank\"><span class=\"email\">{{ userid }}</span></a>." rerender }}
</p>
{{else}}
<p>
{{ text "Verification failed! Perhaps the link you used was expired?" }}
</p>
<p>
{{ text "You can <a href=\"/upload\">try uploading again</a>." }}
</p>
{{/if}}
</div>
{{/with}}
{{/layout}}

View File

@ -40,302 +40,294 @@ msgid "<strong>Error:</strong> {{ internal_error }}"
msgstr ""
#: src/gettext_strings.rs:7
msgid "We found an entry for <span class=\"email\">{{ query }}</span>:"
msgid "There was an error with your request:"
msgstr ""
#: src/gettext_strings.rs:8
msgid "<strong>Hint:</strong> It's more convenient to use <span class=\"brand\">keys.openpgp.org</span> from your OpenPGP software.<br /> Take a look at our <a href=\"/about/usage\">usage guide</a> for details."
msgid "We found an entry for <span class=\"email\">{{ query }}</span>:"
msgstr ""
#: src/gettext_strings.rs:9
msgid "debug info"
msgid "<strong>Hint:</strong> It's more convenient to use <span class=\"brand\">keys.openpgp.org</span> from your OpenPGP software.<br /> Take a look at our <a href=\"/about/usage\">usage guide</a> for details."
msgstr ""
#: src/gettext_strings.rs:10
msgid "Search by Email Address / Key ID / Fingerprint"
msgid "debug info"
msgstr ""
#: src/gettext_strings.rs:11
msgid "Search"
msgid "Search by Email Address / Key ID / Fingerprint"
msgstr ""
#: src/gettext_strings.rs:12
msgid "You can also <a href=\"/upload\">upload</a> or <a href=\"/manage\">manage</a> your key."
msgid "Search"
msgstr ""
#: src/gettext_strings.rs:13
msgid "Find out more <a href=\"/about\">about this service</a>."
msgid "You can also <a href=\"/upload\">upload</a> or <a href=\"/manage\">manage</a> your key."
msgstr ""
#: src/gettext_strings.rs:14
msgid "News:"
msgid "Find out more <a href=\"/about\">about this service</a>."
msgstr ""
#: src/gettext_strings.rs:15
msgid "<a href=\"/about/news#2019-09-12-three-months-later\">Three months after launch ✨</a> (2019-09-12)"
msgid "News:"
msgstr ""
#: src/gettext_strings.rs:16
msgid "v{{ version }} built from"
msgid "<a href=\"/about/news#2019-09-12-three-months-later\">Three months after launch ✨</a> (2019-09-12)"
msgstr ""
#: src/gettext_strings.rs:17
msgid "Powered by <a href=\"https://sequoia-pgp.org\">Sequoia-PGP</a>"
msgid "v{{ version }} built from"
msgstr ""
#: src/gettext_strings.rs:18
msgid "Background image retrieved from <a href=\"https://www.toptal.com/designers/subtlepatterns/subtle-grey/\">Subtle Patterns</a> under CC BY-SA 3.0"
msgid "Powered by <a href=\"https://sequoia-pgp.org\">Sequoia-PGP</a>"
msgstr ""
#: src/gettext_strings.rs:19
msgid "Maintenance Mode"
msgid "Background image retrieved from <a href=\"https://www.toptal.com/designers/subtlepatterns/subtle-grey/\">Subtle Patterns</a> under CC BY-SA 3.0"
msgstr ""
#: src/gettext_strings.rs:20
msgid "Manage your key"
msgid "Maintenance Mode"
msgstr ""
#: src/gettext_strings.rs:21
msgid "Enter any verified email address for your key"
msgid "Manage your key"
msgstr ""
#: src/gettext_strings.rs:22
msgid "Send link"
msgid "Enter any verified email address for your key"
msgstr ""
#: src/gettext_strings.rs:23
msgid "We will send you an email with a link you can use to remove any of your email addresses from search."
msgid "Send link"
msgstr ""
#: src/gettext_strings.rs:24
msgid "Managing the key <span class=\"fingerprint\"><a href=\"{{ key_link }}\" target=\"_blank\">{{ key_fpr }}</a></span>."
msgid "We will send you an email with a link you can use to remove any of your email addresses from search."
msgstr ""
#: src/gettext_strings.rs:25
msgid "Your key is published with the following identity information:"
msgid "Managing the key <span class=\"fingerprint\"><a href=\"{{ key_link }}\" target=\"_blank\">{{ key_fpr }}</a></span>."
msgstr ""
#: src/gettext_strings.rs:26
msgid "Delete"
msgid "Your key is published with the following identity information:"
msgstr ""
#: src/gettext_strings.rs:27
msgid "Clicking \"delete\" on any address will remove it from this key. It will no longer appear in a search.<br /> To add another address, <a href=\"/upload\">upload</a> the key again."
msgid "Delete"
msgstr ""
#: src/gettext_strings.rs:28
msgid "Your key is published as only non-identity information. (<a href=\"/about\" target=\"_blank\">What does this mean?</a>)"
msgid "Clicking \"delete\" on any address will remove it from this key. It will no longer appear in a search.<br /> To add another address, <a href=\"/upload\">upload</a> the key again."
msgstr ""
#: src/gettext_strings.rs:29
msgid "To add an address, <a href=\"/upload\">upload</a> the key again."
msgid "Your key is published as only non-identity information. (<a href=\"/about\" target=\"_blank\">What does this mean?</a>)"
msgstr ""
#: src/gettext_strings.rs:30
msgid "We have sent an email with further instructions to <span class=\"email\">{{ address }}</span>."
msgid "To add an address, <a href=\"/upload\">upload</a> the key again."
msgstr ""
#: src/gettext_strings.rs:31
msgid "This address has already been verified."
msgid "We have sent an email with further instructions to <span class=\"email\">{{ address }}</span>."
msgstr ""
#: src/gettext_strings.rs:32
msgid "Your key <span class=\"fingerprint\">{{ key_fpr }}</span> is now published for the identity <a href=\"{{userid_link}}\" target=\"_blank\"><span class=\"email\">{{ userid }}</span></a>."
msgid "This address has already been verified."
msgstr ""
#: src/gettext_strings.rs:33
msgid "Verification failed! Perhaps the link you used was expired?"
msgid "Your key <span class=\"fingerprint\">{{ key_fpr }}</span> is now published for the identity <a href=\"{{userid_link}}\" target=\"_blank\"><span class=\"email\">{{ userid }}</span></a>."
msgstr ""
#: src/gettext_strings.rs:34
msgid "You can <a href=\"/upload\">try uploading again</a>."
msgstr ""
#: src/gettext_strings.rs:35
msgid "Upload your key"
msgstr ""
#: src/gettext_strings.rs:36
msgid "Your public key"
msgstr ""
#: src/gettext_strings.rs:37
#: src/gettext_strings.rs:35
msgid "Upload"
msgstr ""
#: src/gettext_strings.rs:38
#: src/gettext_strings.rs:36
msgid "Need more info? Check our <a target=\"_blank\" href=\"/about\">intro</a> and <a target=\"_blank\" href=\"/about/usage\">usage guide</a>."
msgstr ""
#: src/gettext_strings.rs:39
#: src/gettext_strings.rs:37
msgid "You uploaded the key <span class=\"fingerprint\"><a href=\"{{ key_link }}\" target=\"_blank\">{{ key_fpr }}</a></span>."
msgstr ""
#: src/gettext_strings.rs:40
#: src/gettext_strings.rs:38
msgid "This key is revoked."
msgstr ""
#: src/gettext_strings.rs:41
#: src/gettext_strings.rs:39
msgid "It is published without identity information and can't be made available for search by email address (<a href=\"/about\" target=\"_blank\">what does this mean?</a>)."
msgstr ""
#: src/gettext_strings.rs:42
#: src/gettext_strings.rs:40
msgid "This key is now published with the following identity information (<a href=\"/about\" target=\"_blank\">what does this mean?</a>):"
msgstr ""
#: src/gettext_strings.rs:43
#: src/gettext_strings.rs:41
msgid "Published"
msgstr ""
#: src/gettext_strings.rs:44
msgid "This key is now published with only non-identity information (<a href=\"/about\" target=\"_blank\">what does this mean?</a>)"
#: src/gettext_strings.rs:42
msgid "This key is now published with only non-identity information. (<a href=\"/about\" target=\"_blank\">What does this mean?</a>)"
msgstr ""
#: src/gettext_strings.rs:45
#: src/gettext_strings.rs:43
msgid "To make the key available for search by email address, you can verify it belongs to you:"
msgstr ""
#: src/gettext_strings.rs:46
#: src/gettext_strings.rs:44
msgid "Verification Pending"
msgstr ""
#: src/gettext_strings.rs:47
#: src/gettext_strings.rs:45
msgid "<strong>Note:</strong> Some providers delay emails for up to 15 minutes to prevent spam. Please be patient."
msgstr ""
#: src/gettext_strings.rs:48
#: src/gettext_strings.rs:46
msgid "Send Verification Email"
msgstr ""
#: src/gettext_strings.rs:49
#: src/gettext_strings.rs:47
msgid "This key contains one identity that could not be parsed as an email address.<br /> This identity can't be published on <span class=\"brand\">keys.openpgp.org</span>. (<a href=\"/about/faq#non-email-uids\" target=\"_blank\">Why?</a>)"
msgstr ""
#: src/gettext_strings.rs:50
#: src/gettext_strings.rs:48
msgid "This key contains {{ count_unparsed }} identities that could not be parsed as an email address.<br /> These identities can't be published on <span class=\"brand\">keys.openpgp.org</span>. (<a href=\"/about/faq#non-email-uids\" target=\"_blank\">Why?</a>)"
msgstr ""
#: src/gettext_strings.rs:51
#: src/gettext_strings.rs:49
msgid "This key contains one revoked identity, which is not published. (<a href=\"/about/faq#revoked-uids\" target=\"_blank\">Why?</a>)"
msgstr ""
#: src/gettext_strings.rs:52
#: src/gettext_strings.rs:50
msgid "This key contains {{ count_revoked }} revoked identities, which are not published. (<a href=\"/about/faq#revoked-uids\" target=\"_blank\">Why?</a>)"
msgstr ""
#: src/gettext_strings.rs:53
#: src/gettext_strings.rs:51
msgid "Your keys have been successfully uploaded:"
msgstr ""
#: src/gettext_strings.rs:54
#: src/gettext_strings.rs:52
msgid "<strong>Note:</strong> To make keys searchable by email address, you must upload them individually."
msgstr ""
#: src/gettext_strings.rs:55
#: src/gettext_strings.rs:53
msgid "Verifying your email address…"
msgstr ""
#: src/gettext_strings.rs:56
#: src/gettext_strings.rs:54
msgid "If the process doesn't complete after a few seconds, please <input type=\"submit\" class=\"textbutton\" value=\"click here\" />."
msgstr ""
#: src/gettext_strings.rs:58
#: src/gettext_strings.rs:56
msgid "Manage your key on {{domain}}"
msgstr ""
#: src/gettext_strings.rs:60
#: src/gettext_strings.rs:58
msgid "Hi,"
msgstr ""
#: src/gettext_strings.rs:61
#: src/gettext_strings.rs:59
msgid "this is an automated message from <a rel=\"nofollow\" href=\"{{ base_uri }}\" style=\"text-decoration:none; color: #333\"><tt>{{ domain }}</tt></a>."
msgstr ""
#: src/gettext_strings.rs:62
#: src/gettext_strings.rs:60
msgid "If you didn't request this message, please ignore it."
msgstr ""
#: src/gettext_strings.rs:63
#: src/gettext_strings.rs:61
msgid "OpenPGP key: <tt>{{ primary_fp }}</tt>"
msgstr ""
#: src/gettext_strings.rs:64
#: src/gettext_strings.rs:62
msgid "To manage and delete listed addresses on this key, please follow the link below:"
msgstr ""
#: src/gettext_strings.rs:65
#: src/gettext_strings.rs:63
msgid "You can find more info at <a href=\"{{ base_uri }}/about\">{{ domain }}/about</a>."
msgstr ""
#: src/gettext_strings.rs:66
#: src/gettext_strings.rs:64
msgid "Greetings from the <a rel=\"nofollow\" href=\"{{ base_uri }}\" style=\"text-decoration:none; color: #333\"><tt>keys.openpgp.org</tt></a> team"
msgstr ""
#: src/gettext_strings.rs:69
#: src/gettext_strings.rs:67
msgid "this is an automated message from {{domain}}. If you didn't\nrequest this message, please ignore it."
msgstr ""
#: src/gettext_strings.rs:70
#: src/gettext_strings.rs:68
msgid "OpenPGP key: {{primary_fp}}"
msgstr ""
#: src/gettext_strings.rs:71
#: src/gettext_strings.rs:69
msgid "To manage and delete listed addresses on this key, please follow\nthe link below:"
msgstr ""
#: src/gettext_strings.rs:72
#: src/gettext_strings.rs:70
msgid "You can find more info at {{base_uri}}/about"
msgstr ""
#: src/gettext_strings.rs:73
#: src/gettext_strings.rs:71
msgid "Greetings from the keys.openpgp.org team"
msgstr ""
#: src/gettext_strings.rs:75
#: src/gettext_strings.rs:73
msgid "Verify {{userid}} for your key on {{domain}}"
msgstr ""
#: src/gettext_strings.rs:78
#: src/gettext_strings.rs:76
msgid "this is an automated message from <a rel=\"nofollow\" href=\"{{base_uri}}\" style=\"text-decoration:none; color: #333\"><tt>{{domain}}</tt></a>. If you didn't request this message, please ignore it."
msgstr ""
#: src/gettext_strings.rs:79
#: src/gettext_strings.rs:77
msgid "OpenPGP key: <tt>{{primary_fp}}</tt>"
msgstr ""
#: src/gettext_strings.rs:80
#: src/gettext_strings.rs:78
msgid "To let others find this key from your email address \"<a rel=\"nofollow\" href=\"#\" style=\"text-decoration:none; color: #333\">{{userid}}</a>\", please click the link below:"
msgstr ""
#: src/gettext_strings.rs:81
#: src/gettext_strings.rs:79
msgid "You can find more info at <a href=\"{{base_uri}}/about\">{{domain}}/about</a>."
msgstr ""
#: src/gettext_strings.rs:82
#: src/gettext_strings.rs:80
msgid "Greetings from the <a rel=\"nofollow\" href=\"{{base_uri}}\" style=\"text-decoration:none; color: #333\"><tt>keys.openpgp.org</tt></a> team"
msgstr ""
#: src/gettext_strings.rs:87
#: src/gettext_strings.rs:85
msgid "To let others find this key from your email address \"{{userid}}\",\nplease follow the link below:"
msgstr ""
#: src/gettext_strings.rs:91
#: src/gettext_strings.rs:89
msgid "Your key upload on {{domain}}"
msgstr ""
#: src/gettext_strings.rs:94
#: src/gettext_strings.rs:92
msgid "this is an automated message from <a rel=\"nofollow\" href=\"{{base_uri}}\" style=\"text-decoration:none; color: #333\"><tt>{{domain}}</tt></a>. If you didn't upload your key there, please ignore this message."
msgstr ""
#: src/gettext_strings.rs:96
#: src/gettext_strings.rs:94
msgid "This key was just uploaded for the first time, and is now published without identity information. If you want to allow others to find this key by email address, please follow this link:"
msgstr ""
#: src/gettext_strings.rs:101
#: src/gettext_strings.rs:99
msgid "this is an automated message from {{domain}}. If you didn't upload your key\nthere, please ignore this message."
msgstr ""
#: src/gettext_strings.rs:103
#: src/gettext_strings.rs:101
msgid "This key was just uploaded for the first time, and is now published without\nidentity information. If you want to allow others to find this key by email\naddress, please follow this link:"
msgstr ""
@ -363,18 +355,18 @@ msgstr ""
msgid "Whoops, please don't upload secret keys!"
msgstr ""
#: src/web/vks.rs:129
#: src/web/vks.rs:134
msgid "No key uploaded."
msgstr ""
#: src/web/vks.rs:181
msgid "Something went wrong processing key {}"
#: src/web/vks.rs:178
msgid "Error processing uploaded key"
msgstr ""
#: src/web/vks.rs:252
#: src/web/vks.rs:248
msgid "Upload session expired. Please try again."
msgstr ""
#: src/web/vks.rs:289
msgid "Invalid verification token!"
#: src/web/vks.rs:285
msgid "Invalid verification link."
msgstr ""

View File

@ -4,6 +4,7 @@ fn _dummy() {
t!("Error");
t!("Looks like something went wrong :(");
t!("<strong>Error:</strong> {{ internal_error }}");
t!("There was an error with your request:");
t!("We found an entry for <span class=\"email\">{{ query }}</span>:");
t!("<strong>Hint:</strong> It's more convenient to use <span class=\"brand\">keys.openpgp.org</span> from your OpenPGP software.<br /> Take a look at our <a href=\"/about/usage\">usage guide</a> for details.");
t!("debug info");
@ -30,10 +31,7 @@ fn _dummy() {
t!("We have sent an email with further instructions to <span class=\"email\">{{ address }}</span>.");
t!("This address has already been verified.");
t!("Your key <span class=\"fingerprint\">{{ key_fpr }}</span> is now published for the identity <a href=\"{{userid_link}}\" target=\"_blank\"><span class=\"email\">{{ userid }}</span></a>.");
t!("Verification failed! Perhaps the link you used was expired?");
t!("You can <a href=\"/upload\">try uploading again</a>.");
t!("Upload your key");
t!("Your public key");
t!("Upload");
t!("Need more info? Check our <a target=\"_blank\" href=\"/about\">intro</a> and <a target=\"_blank\" href=\"/about/usage\">usage guide</a>.");
t!("You uploaded the key <span class=\"fingerprint\"><a href=\"{{ key_link }}\" target=\"_blank\">{{ key_fpr }}</a></span>.");
@ -41,7 +39,7 @@ fn _dummy() {
t!("It is published without identity information and can't be made available for search by email address (<a href=\"/about\" target=\"_blank\">what does this mean?</a>).");
t!("This key is now published with the following identity information (<a href=\"/about\" target=\"_blank\">what does this mean?</a>):");
t!("Published");
t!("This key is now published with only non-identity information (<a href=\"/about\" target=\"_blank\">what does this mean?</a>)");
t!("This key is now published with only non-identity information. (<a href=\"/about\" target=\"_blank\">What does this mean?</a>)");
t!("To make the key available for search by email address, you can verify it belongs to you:");
t!("Verification Pending");
t!("<strong>Note:</strong> Some providers delay emails for up to 15 minutes to prevent spam. Please be patient.");

View File

@ -75,8 +75,8 @@ pub mod response {
}
impl PublishResponse {
pub fn err(err: &str) -> Self {
PublishResponse::Error(err.to_owned())
pub fn err(err: impl Into<String>) -> Self {
PublishResponse::Error(err.into())
}
}
}
@ -125,10 +125,7 @@ pub fn process_key(
t
},
Err(_) => {
return UploadResponse::err(i18n!(
i18n.catalog,
"No key uploaded."
));
return UploadResponse::err(i18n!(i18n.catalog, "Parsing of key data failed."));
}
});
}
@ -178,8 +175,7 @@ fn process_key_single(
Ok(ImportResult::New(tpk_status)) => (tpk_status, true),
Ok(ImportResult::Updated(tpk_status)) => (tpk_status, false),
Ok(ImportResult::Unchanged(tpk_status)) => (tpk_status, false),
Err(_) => return UploadResponse::err(&i18n!(i18n.catalog,
"Something went wrong processing key {}"; fp)),
Err(_) => return UploadResponse::err(i18n!(i18n.catalog, "Error processing uploaded key")),
};
let verify_state = {
@ -286,7 +282,7 @@ pub fn verify_confirm(
let (fingerprint, email) = match check_publish_token(&db, &token_service, token) {
Ok(x) => x,
Err(_) => return PublishResponse::err(
&i18n!(i18n.catalog, "Invalid verification token!")),
i18n!(i18n.catalog, "Invalid verification link.")),
};
response::PublishResponse::Ok {

View File

@ -9,6 +9,7 @@ use rocket::http::ContentType;
use rocket::request::Form;
use rocket::Data;
use rocket_i18n::I18n;
use gettext_macros::i18n;
use crate::database::{KeyDatabase, StatefulTokens, Query, Database};
use crate::mail;
@ -45,7 +46,6 @@ mod template {
#[derive(Serialize)]
pub struct Verify {
pub verified: bool,
pub key_fpr: String,
pub userid: String,
pub userid_link: String,
@ -442,7 +442,6 @@ pub fn verify_confirm(
rate_limiter.action_perform(rate_limit_id);
let userid_link = uri!(search: &email).to_string();
let context = template::Verify {
verified: true,
userid: email,
key_fpr: fingerprint,
userid_link,
@ -451,13 +450,12 @@ pub fn verify_confirm(
MyResponse::ok("upload/publish-result", context)
},
PublishResponse::Error(error) => {
if rate_limiter.action_check(rate_limit_id) {
MyResponse::bad_request(
"400-plain", failure::err_msg(error))
let error_msg = if rate_limiter.action_check(rate_limit_id) {
failure::err_msg(error)
} else {
MyResponse::bad_request(
"upload/already-verified", failure::err_msg(""))
}
failure::err_msg(i18n!(i18n.catalog, "This address has already been verified."))
};
MyResponse::bad_request("400", error_msg)
}
}
}