Email cleanup: Add RegisterNewEmailHtml.soy

Currently, we support sending emails with HTML format for all
emails, except RegisterNewEmail. This change makes it allowed
for all emails. As a follow-up change, we will be able to remove
supportsHtml() since at that point it will always return true.

Change-Id: Ic1d71d2602b7888088b9d6057e2ed8545f35848f
This commit is contained in:
Gal Paikin
2020-07-10 15:53:09 +03:00
parent 225fd6120b
commit 38b6bb2247
5 changed files with 61 additions and 3 deletions

View File

@@ -109,10 +109,10 @@ actions made by the user in the Web UI such as cherry picking a commit or
reverting a change. It is a `ChangeEmail`: see `ChangeSubject.soy` and
ChangeFooter.
=== RegisterNewEmail.soy
=== RegisterNewEmail.soy and RegisterNewEmailHtml.soy
The `RegisterNewEmail.soy` template will determine the contents of the email
related to registering new email accounts.
Those templates will determine the contents of the email related to registering
new email accounts.
=== ReplacePatchSet.soy and ReplacePatchSetHtml.soy

View File

@@ -133,6 +133,7 @@ public class SitePathInitializer {
extractMailExample("NewChange.soy");
extractMailExample("NewChangeHtml.soy");
extractMailExample("RegisterNewEmail.soy");
extractMailExample("RegisterNewEmailHtml.soy");
extractMailExample("ReplacePatchSet.soy");
extractMailExample("ReplacePatchSetHtml.soy");
extractMailExample("Restored.soy");

View File

@@ -69,6 +69,7 @@ public class MailSoySauceProvider implements Provider<SoySauce> {
"NoReplyFooterHtml.soy",
"Private.soy",
"RegisterNewEmail.soy",
"RegisterNewEmailHtml.soy",
"ReplacePatchSet.soy",
"ReplacePatchSetHtml.soy",
"Restored.soy",

View File

@@ -60,6 +60,9 @@ public class RegisterNewEmailSender extends OutgoingEmail {
@Override
protected void format() throws EmailException {
appendText(textTemplate("RegisterNewEmail"));
if (useHtml()) {
appendHtml(soyHtmlTemplate("RegisterNewEmailHtml"));
}
}
public boolean isAllowed() {
@@ -79,4 +82,9 @@ public class RegisterNewEmailSender extends OutgoingEmail {
}
return emailToken;
}
@Override
protected boolean supportsHtml() {
return true;
}
}

View File

@@ -0,0 +1,48 @@
/**
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{namespace com.google.gerrit.server.mail.template}
{template .RegisterNewEmailHtml}
{@param email: ?}
<p>
Welcome to Gerrit Code Review at {$email.gerritHost}.
To add a verified email address to your user account, please
click on the following link
</p>
{if $email.userNameEmail}
<p>
{sp}while signed in as {$email.userNameEmail}
</p>
{/if}:
<p>
{$email.gerritUrl}#/VE/{$email.emailRegistrationToken}
</p>
<p>
If you have received this mail in error, you do not need to take any
action to cancel the account. The address will not be activated, and
you will not receive any further emails.
</p>
<p>
If clicking the link above does not work, copy and paste the URL in a
new browser window instead.
This is a send-only email address. Replies to this message will not
be read or answered.
</p>
{/template}