π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[server] Update contact emails
Neeraj Gupta9c0426d71679
diff --git a/server/mail-templates/legacy/legacy_invite.html b/server/mail-templates/legacy/legacy_invite.htmlindex dc59ad1637..4f3e0eadb5 100644--- a/server/mail-templates/legacy/legacy_invite.html+++ b/server/mail-templates/legacy/legacy_invite.html@@ -6,5 +6,5 @@<p> As a trusted contact, you can recover {{.LegacyUser}}'s account in their absence. </p><p>To accept the invite, please open the Ente Photos app, and navigate to <strong>Settings -> Account -> Legacy </strong>. </p>-<p>If you need any help, please reply to this email or write to [email protected]</p>+<p>If you need any help, please reply to this email or write to [email protected].</p>{{end}}\ No newline at end of filediff --git a/server/mail-templates/legacy/legacy_invite_accepted.html b/server/mail-templates/legacy/legacy_invite_accepted.htmlindex 87cde6f366..95624b8810 100644--- a/server/mail-templates/legacy/legacy_invite_accepted.html+++ b/server/mail-templates/legacy/legacy_invite_accepted.html@@ -1,7 +1,9 @@{{define "content"}}<p>Hey {{.LegacyUser}}!</p>-<p><strong>{{.TrustedUser}}</strong> has accepted your invite to be a trusted contact.</p>+<p><strong>{{.TrustedUser}}</strong> has accepted your request to be your trusted contact. </p>-<p>If you need help with anything, please write back!</p>+<p> As a trusted contact, {{.TrustedUser}} can recover your account in your absence. </p>++<p>If you need any help, please reply to this email or write to [email protected].</p>{{end}}\ No newline at end of filediff --git a/server/mail-templates/legacy/legacy_invite_rejected.html b/server/mail-templates/legacy/legacy_invite_rejected.htmlindex d786e0ff45..971e4c853c 100644--- a/server/mail-templates/legacy/legacy_invite_rejected.html+++ b/server/mail-templates/legacy/legacy_invite_rejected.html@@ -1,7 +1,7 @@{{define "content"}}<p>Hey {{.LegacyUser}}!</p>-<p><strong>{{.TrustedUser}}</strong> has declined your invite to be a trusted contact.</p>+<p><strong>{{.TrustedUser}}</strong> has rejected your request to be your trusted contact. </p>-<p>If you need help with anything, please write back!</p>+<p>If you need any help, please reply to this email or write to [email protected].</p>{{end}}\ No newline at end of filediff --git a/server/mail-templates/legacy/legacy_left.html b/server/mail-templates/legacy/legacy_left.htmlindex fce8cecba0..72d03dd95b 100644--- a/server/mail-templates/legacy/legacy_left.html+++ b/server/mail-templates/legacy/legacy_left.html@@ -1,7 +1,7 @@{{define "content"}}<p>Hey {{.LegacyUser}}!</p>-<p><strong>{{.TrustedUser}}</strong> has stopped being your trusted contact. You can invite them back again or add more trusted contacts.</p>+<p><strong>{{.TrustedUser}}</strong> has removed themselves from being your trusted contact. </p>-<p>If you need help with anything, please write back!</p>+<p>If you need any help, please reply to this email or write to [email protected].</p>{{end}}\ No newline at end of filediff --git a/server/mail-templates/legacy/legacy_removed.html b/server/mail-templates/legacy/legacy_removed.htmlindex 4e6c5fb90f..160dba288d 100644--- a/server/mail-templates/legacy/legacy_removed.html+++ b/server/mail-templates/legacy/legacy_removed.html@@ -1,7 +1,7 @@{{define "content"}}<p>Hey {{.TrustedUser}}!</p>-<p><strong>{{.LegacyUser}}</strong> has removed you as trusted contact.</p>+<p><strong>{{.LegacyUser}}</strong> has removed you as their trusted contact. </p>-<p>If you need help with anything, please write back!</p>+<p>If you need any help, please reply to this email or write to [email protected].</p>{{end}}\ No newline at end of filediff --git a/server/pkg/controller/emergency/account_owner.go b/server/pkg/controller/emergency/account_owner.goindex a857ccd866..27a747d1c5 100644--- a/server/pkg/controller/emergency/account_owner.go+++ b/server/pkg/controller/emergency/account_owner.go@@ -27,7 +27,7 @@ func (c *Controller) AddContact(ctx *gin.Context, userID int64, request ente.Addreturn stacktrace.Propagate(err, "")}if hasUpdated {- go c.sendNotification(ctx, userID, emergencyContactID, ente.UserInvitedContact)+ go c.sendContactNotification(ctx, userID, emergencyContactID, ente.UserInvitedContact)}return nil}diff --git a/server/pkg/controller/emergency/controller.go b/server/pkg/controller/emergency/controller.goindex a29a14e575..ed7c5cb396 100644--- a/server/pkg/controller/emergency/controller.go+++ b/server/pkg/controller/emergency/controller.go@@ -28,7 +28,7 @@ func (c *Controller) UpdateContact(ctx *gin.Context,log.WithField("userID", userID).WithField("req", req).Warn("No update applied for emergency contact")} else {- go c.sendNotification(ctx, req.UserID, req.EmergencyContactID, req.State)+ go c.sendContactNotification(ctx, req.UserID, req.EmergencyContactID, req.State)}recoverStatus := getNextRecoveryStatusFromContactState(req.State)if recoverStatus != nil {diff --git a/server/pkg/controller/emergency/email.go b/server/pkg/controller/emergency/email.goindex af6a3c649a..90dd6e0442 100644--- a/server/pkg/controller/emergency/email.go+++ b/server/pkg/controller/emergency/email.go@@ -12,6 +12,7 @@ import (const (BaseTemplate string = "legacy/legacy_base.html"InviteTemplate string = "legacy/legacy_invite.html"+ InviteSentTemplate string = "legacy/legacy_invite_sent.html"RemovedTemplate string = "legacy/legacy_removed.html"LeftTemplate string = "legacy/legacy_left.html"AcceptedTemplate string = "legacy/legacy_invite_accepted.html"@@ -30,7 +31,76 @@ const (SadHeaderImage = "iVBORw0KGgoAAAANSUhEUgAAAN4AAADeCAYAAABSZ763AAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAABjjSURBVHgB7Z1bbBzXecc/7lLkcilblOXKVqGYK6OODSSxqKdcAFcrC2hefH0pnMKCKMB20db1BYH7UAmQBFh9SBBYbpIWUFyYgoLEaB58UV4SQNZaRmv7SbQco3ZdxENbjWxFEimLXFKUdp3vP5yhZod7nTkzc2bO9wNWe+Hyot3z3+96vtNHQqJ8+eWXI1euXCnhgtv5fL6Uy+VG8bV6vV7q6+sbwePuc3G/zY+z8A8/Z4afO4NrXPjnTDn3J/nnz6xatcrC4yQkRh8JsTA/P19iAYzxgi/x4t/MQhhzhUUJ4ArREeYbuM0PW0NDQxYJkSPCiwBYpmq1WubFXIb14oVdTkpgveIKkm++wZdKoVCYFOuoHhGeAnxC2wprRhkCQoRV5P9XpVgsVkSI4RHhBQSuIy/EB3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QhtTgn9ezTvRgehEwKz0Xcz3SSNbeyGZkWnou4n+nAERw2q1Yo4xghPBcRoLZYtLQ7fIIMwSjhuYgAtcEiwwTnYqTwXESAyeC4lIdNFJyL0cJzYQGWeTHslQ6YaDEphuuECM+DJwu6lcQKKgF1uFwud5gvEwMDA9qNYEgKEV4L4IbyJ/ROsYLBgHWr1+uvwp3MYh0uLCK8DjiN2Bg7eD+JFeyExZfDfJnIcg1OBSK8HsD0s/7+/nERYQMWLYmtIrFb94jwAgIRctxS5sv9prmjrhvJ16+IZQuGCE8BLLyRarVazufzZb67le+PUYZggSEp8katVqsUi8WKxGzhEeFFAIS4sLAA8aFMsZWtw1hahjQ5WcgK35zi268UCoVJEZp6RHgx4ZQqsGsCLirKFSNJCtIRmAVrxpbsXb5v8f1JcR3jQYSXMLCOc3NzJXZTRyBKCJEFMIrH+cv2xbkNSm1+zoxrmZxr3LdwnwU+xeKCyLCD2xoeHrbEiiXLnwDnkx8SBNVTNQAAAABJRU5ErkJggg==")-func (c *Controller) sendNotification(ctx context.Context, legacyUserID int64, trustedUserID int64, newStatus ente.ContactState) error {+type emailData struct {+ title string+ templateName string+ emailTo string+ templateData map[string]interface{}+ inlineImages []map[string]interface{}+}++func (c *Controller) createEmailData(legacyUser, trustedUser ente.User, newStatus ente.ContactState) ([]emailData, error) {+ templateData := map[string]interface{}{+ "LegacyUser": legacyUser.Email,+ "TrustedUser": trustedUser.Email,+ }++ var emailContent []emailData+ switch newStatus {+ case ente.UserInvitedContact:+ emailContent = append(emailContent, emailData{+ title: fmt.Sprintf("%s has added you as a Trusted Contact", legacyUser.Email),+ templateName: InviteTemplate,+ emailTo: trustedUser.Email,+ templateData: templateData,+ inlineImages: []map[string]interface{}{},+ })+ emailContent = append(emailContent, emailData{+ title: fmt.Sprintf("You have added %s as a Trusted Contact", trustedUser.Email),+ templateName: InviteSentTemplate,+ emailTo: legacyUser.Email,+ templateData: templateData,+ inlineImages: []map[string]interface{}{},+ })+ case ente.UserRevokedContact:+ emailContent = append(emailContent, emailData{+ title: fmt.Sprintf("%s has removed you as a Trusted Contact", legacyUser.Email),+ templateName: RemovedTemplate,+ emailTo: trustedUser.Email,+ templateData: templateData,+ inlineImages: []map[string]interface{}{},+ })+ case ente.ContactLeft:+ emailContent = append(emailContent, emailData{+ title: fmt.Sprintf("%s has removed themselves as a Trusted Contact", trustedUser.Email),+ templateName: LeftTemplate,+ emailTo: legacyUser.Email,+ templateData: templateData,+ inlineImages: []map[string]interface{}{},+ })+ case ente.ContactDenied:+ emailContent = append(emailContent, emailData{+ title: fmt.Sprintf("%s has rejected your request to be a Trusted Contact", trustedUser.Email),+ templateName: RejectedInviteTemplate,+ emailTo: legacyUser.Email,+ templateData: templateData,+ inlineImages: []map[string]interface{}{},+ })+ case ente.ContactAccepted:+ emailContent = append(emailContent, emailData{+ title: fmt.Sprintf("%s has accepted your request to be a Trusted Contact", trustedUser.Email),+ templateName: AcceptedTemplate,+ emailTo: legacyUser.Email,+ templateData: templateData,+ inlineImages: []map[string]interface{}{},+ })+ default:+ return nil, fmt.Errorf("unsupported status %s", newStatus)+ }+ return emailContent, nil+}++func (c *Controller) sendContactNotification(ctx context.Context, legacyUserID int64, trustedUserID int64, newStatus ente.ContactState) error {legacyUser, err := c.UserRepo.Get(legacyUserID)if err != nil {return stacktrace.Propagate(err, "")@@ -39,52 +109,26 @@ func (c *Controller) sendNotification(ctx context.Context, legacyUserID int64, tif err != nil {return stacktrace.Propagate(err, "")}- templateData := map[string]interface{}{- "LegacyUser": legacyUser.Email,- "TrustedUser": trustedUser.Email,- }- var templateName, emailTo, title string- var inlineImages []map[string]interface{}- inlineImage := make(map[string]interface{})- inlineImage["mime_type"] = "image/png"- inlineImage["cid"] = "header-image"-- if newStatus == ente.UserInvitedContact {- templateName = InviteTemplate- title = fmt.Sprintf("%s has added you as a Trusted Contact", legacyUser.Email)- emailTo = trustedUser.Email- inlineImage["content"] = HappyHeaderImage- } else if newStatus == ente.UserRevokedContact {- emailTo = trustedUser.Email- templateName = RemovedTemplate- title = "You have been removed as a trusted contact on Ente"- inlineImage["content"] = SadHeaderImage- } else if newStatus == ente.ContactLeft {- emailTo = legacyUser.Email- templateName = LeftTemplate- title = fmt.Sprintf("%s has left as trusted contact", trustedUser.Email)- inlineImage["content"] = SadHeaderImage- } else if newStatus == ente.ContactDenied {- emailTo = legacyUser.Email- templateName = RejectedInviteTemplate- title = fmt.Sprintf("%s has declined your invite for trusted contact", trustedUser.Email)- inlineImage["content"] = SadHeaderImage- } else if newStatus == ente.ContactAccepted {- emailTo = legacyUser.Email- templateName = AcceptedTemplate- title = fmt.Sprintf("%s has accepted your invitation!", trustedUser.Email)- inlineImage["content"] = HappyHeaderImage- } else {- return stacktrace.Propagate(fmt.Errorf("unsupported status %s", newStatus), "")- }- inlineImages = append(inlineImages, inlineImage)- err = emailUtil.SendTemplatedEmailV2([]string{emailTo}, "Ente", "[email protected]",- title, BaseTemplate, templateName, templateData, inlineImages)+ emailDatas, err := c.createEmailData(legacyUser, trustedUser, newStatus)if err != nil {- log.WithError(err).WithField("state", newStatus).Error("failed to send email")return stacktrace.Propagate(err, "")}++ for _, data := range emailDatas {+ content := data+ err = emailUtil.SendTemplatedEmailV2([]string{content.emailTo}, "Ente", "[email protected]",+ content.title, BaseTemplate, content.templateName, content.templateData, content.inlineImages)+ if err != nil {+ log.WithError(err).WithFields(log.Fields{+ "state": newStatus,+ "to": content.emailTo,+ "template": content.templateName,+ }).Error("failed to send email")+ return stacktrace.Propagate(err, "")+ }+ }+return nil}