MSC1915. Add unbind email notification.
This commit is contained in:
@@ -31,7 +31,6 @@ public class EmailTemplateConfig extends GenericTemplateConfig {
|
|||||||
setInvite("classpath:/threepids/email/invite-template.eml");
|
setInvite("classpath:/threepids/email/invite-template.eml");
|
||||||
getGeneric().put("matrixId", "classpath:/threepids/email/mxid-template.eml");
|
getGeneric().put("matrixId", "classpath:/threepids/email/mxid-template.eml");
|
||||||
getSession().setValidation("classpath:/threepids/email/validate-template.eml");
|
getSession().setValidation("classpath:/threepids/email/validate-template.eml");
|
||||||
getSession().getUnbind().setValidation("classpath:/threepids/email/unbind-template.eml");
|
|
||||||
getSession().getUnbind().setNotification("classpath:/threepids/email/unbind-notification.eml");
|
getSession().getUnbind().setNotification("classpath:/threepids/email/unbind-notification.eml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +40,6 @@ public class EmailTemplateConfig extends GenericTemplateConfig {
|
|||||||
log.info("Session:");
|
log.info("Session:");
|
||||||
log.info(" Validation: {}", getSession().getValidation());
|
log.info(" Validation: {}", getSession().getValidation());
|
||||||
log.info(" Unbind:");
|
log.info(" Unbind:");
|
||||||
log.info(" Validation: {}", getSession().getUnbind().getValidation());
|
|
||||||
log.info(" Notification: {}", getSession().getUnbind().getNotification());
|
log.info(" Notification: {}", getSession().getUnbind().getNotification());
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
@@ -212,6 +212,10 @@ public class SessionManager {
|
|||||||
String secret = GsonUtil.getStringOrNull(reqData, "client_secret");
|
String secret = GsonUtil.getStringOrNull(reqData, "client_secret");
|
||||||
ThreePid tpid = GsonUtil.get().fromJson(GsonUtil.getObj(reqData, "threepid"), ThreePid.class);
|
ThreePid tpid = GsonUtil.get().fromJson(GsonUtil.getObj(reqData, "threepid"), ThreePid.class);
|
||||||
|
|
||||||
|
if (tpid == null || StringUtils.isBlank(tpid.getAddress()) || StringUtils.isBlank(tpid.getMedium())) {
|
||||||
|
throw new BadRequestException("Missing required 3PID");
|
||||||
|
}
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(sid) && StringUtils.isNotBlank(secret)) {
|
if (StringUtils.isNotBlank(sid) && StringUtils.isNotBlank(secret)) {
|
||||||
checkSession(sid, secret, tpid, mxid);
|
checkSession(sid, secret, tpid, mxid);
|
||||||
} else if (StringUtils.isNotBlank(auth)) {
|
} else if (StringUtils.isNotBlank(auth)) {
|
||||||
@@ -220,7 +224,8 @@ public class SessionManager {
|
|||||||
throw new NotAllowedException("Unable to validate request");
|
throw new NotAllowedException("Unable to validate request");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO make invalid all 3PID with specified medium and address.
|
log.info("Unbinding of {} {} to {} is accepted", tpid.getMedium(), tpid.getAddress(), mxid.getId());
|
||||||
|
notifMgr.sendForUnbind(tpid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkAuthorization(String auth, JsonObject reqData) {
|
private void checkAuthorization(String auth, JsonObject reqData) {
|
||||||
|
@@ -115,7 +115,7 @@ public class EmailSmtpConnector implements EmailConnector {
|
|||||||
msg.setRecipients(Message.RecipientType.TO, recipient);
|
msg.setRecipients(Message.RecipientType.TO, recipient);
|
||||||
msg.saveChanges();
|
msg.saveChanges();
|
||||||
|
|
||||||
log.info("Sending invite to {} via SMTP using {}:{}", recipient, cfg.getHost(), cfg.getPort());
|
log.info("Sending email to {} via SMTP using {}:{}", recipient, cfg.getHost(), cfg.getPort());
|
||||||
SMTPTransport transport = (SMTPTransport) session.getTransport("smtp");
|
SMTPTransport transport = (SMTPTransport) session.getTransport("smtp");
|
||||||
|
|
||||||
if (cfg.getTls() < 3) {
|
if (cfg.getTls() < 3) {
|
||||||
@@ -134,12 +134,12 @@ public class EmailSmtpConnector implements EmailConnector {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
transport.sendMessage(msg, InternetAddress.parse(recipient));
|
transport.sendMessage(msg, InternetAddress.parse(recipient));
|
||||||
log.info("Invite to {} was sent", recipient);
|
log.info("Email to {} was sent", recipient);
|
||||||
} finally {
|
} finally {
|
||||||
transport.close();
|
transport.close();
|
||||||
}
|
}
|
||||||
} catch (UnsupportedEncodingException | MessagingException e) {
|
} catch (UnsupportedEncodingException | MessagingException e) {
|
||||||
throw new RuntimeException("Unable to send e-mail invite to " + recipient, e);
|
throw new RuntimeException("Unable to send e-mail to " + recipient, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,14 +9,9 @@ Content-Disposition: inline
|
|||||||
|
|
||||||
Hello there!
|
Hello there!
|
||||||
|
|
||||||
You or a server on your behalf requested to unbind your email.
|
You or a server on your behalf unbinded your email.
|
||||||
|
|
||||||
If it was really you who made this request, you can click on the following link to
|
If you didn't make this request, please contact the system administrator.
|
||||||
complete the unbinding your email address:
|
|
||||||
|
|
||||||
%VALIDATION_LINK%
|
|
||||||
|
|
||||||
If you didn't make this request, you can safely disregard this email.
|
|
||||||
|
|
||||||
%DOMAIN_PRETTY% Admins
|
%DOMAIN_PRETTY% Admins
|
||||||
|
|
||||||
@@ -66,14 +61,9 @@ Content-Disposition: inline
|
|||||||
<td id="inner">
|
<td id="inner">
|
||||||
<p>Hello there!</p>
|
<p>Hello there!</p>
|
||||||
|
|
||||||
<p>You or a server on your behalf requested to unbind your email.</p>
|
<p>You or a server on your behalf unbinded your email.</p>
|
||||||
|
|
||||||
<p>If it was really you who made this request, you can click on the following link to
|
<p>If you didn't make this request, please contact the system administrator.</p>
|
||||||
complete the unbinding your email address:</p>
|
|
||||||
|
|
||||||
<p><a href="%VALIDATION_LINK%">Complete email unbinding</a></p>
|
|
||||||
|
|
||||||
<p>If you didn't make this request, you can safely disregard this email.</p>
|
|
||||||
|
|
||||||
<p>%DOMAIN_PRETTY% Admins</p>
|
<p>%DOMAIN_PRETTY% Admins</p>
|
||||||
</td>
|
</td>
|
||||||
|
@@ -1,87 +0,0 @@
|
|||||||
Subject: Your Matrix Unbinding Token
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Type: multipart/alternative;
|
|
||||||
boundary="7REaIwWQCioQ6NaBlAQlg8ztbUQj6PKJ"
|
|
||||||
|
|
||||||
--7REaIwWQCioQ6NaBlAQlg8ztbUQj6PKJ
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
|
||||||
Content-Disposition: inline
|
|
||||||
|
|
||||||
Hello there!
|
|
||||||
|
|
||||||
You or a server on your behalf requested to unbind your email.
|
|
||||||
|
|
||||||
If it was really you who made this request, you can click on the following link to
|
|
||||||
complete the unbinding your email address:
|
|
||||||
|
|
||||||
%VALIDATION_LINK%
|
|
||||||
|
|
||||||
If you didn't make this request, you can safely disregard this email.
|
|
||||||
|
|
||||||
%DOMAIN_PRETTY% Admins
|
|
||||||
|
|
||||||
--7REaIwWQCioQ6NaBlAQlg8ztbUQj6PKJ
|
|
||||||
Content-Type: multipart/related;
|
|
||||||
boundary="M3yzHl5YZehm9v4bAM8sKEdcOoVnRnKR";
|
|
||||||
type="text/html"
|
|
||||||
|
|
||||||
--M3yzHl5YZehm9v4bAM8sKEdcOoVnRnKR
|
|
||||||
Content-Type: text/html; charset=UTF-8
|
|
||||||
Content-Disposition: inline
|
|
||||||
|
|
||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<style type="text/css">
|
|
||||||
body {
|
|
||||||
margin: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
pre, code {
|
|
||||||
word-break: break-word;
|
|
||||||
white-space: pre-wrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
#page {
|
|
||||||
font-family: 'Open Sans', Helvetica, Arial, Sans-Serif;
|
|
||||||
font-color: #454545;
|
|
||||||
font-size: 12pt;
|
|
||||||
width: 100%%;
|
|
||||||
padding: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#inner {
|
|
||||||
width: 640px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.notif_link a, .footer a {
|
|
||||||
color: #76CFA6 ! important;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<table id="page">
|
|
||||||
<tr>
|
|
||||||
<td></td>
|
|
||||||
<td id="inner">
|
|
||||||
<p>Hello there!</p>
|
|
||||||
|
|
||||||
<p>You or a server on your behalf requested to unbind your email.</p>
|
|
||||||
|
|
||||||
<p>If it was really you who made this request, you can click on the following link to
|
|
||||||
complete the unbinding your email address:</p>
|
|
||||||
|
|
||||||
<p><a href="%VALIDATION_LINK%">Complete email verification</a></p>
|
|
||||||
|
|
||||||
<p>If you didn't make this request, you can safely disregard this email.</p>
|
|
||||||
|
|
||||||
<p>%DOMAIN_PRETTY% Admins</p>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
--M3yzHl5YZehm9v4bAM8sKEdcOoVnRnKR--
|
|
||||||
|
|
||||||
--7REaIwWQCioQ6NaBlAQlg8ztbUQj6PKJ--
|
|
@@ -1 +1 @@
|
|||||||
Your Matrix 3PID was unbinding.
|
Your Matrix 3PID was unbinded.
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
Your Matrix token is %VALIDATION_TOKEN%
|
|
Reference in New Issue
Block a user