diff options
Diffstat (limited to 'internal/email')
-rw-r--r-- | internal/email/confirm.go | 15 | ||||
-rw-r--r-- | internal/email/email_test.go | 17 |
2 files changed, 27 insertions, 5 deletions
diff --git a/internal/email/confirm.go b/internal/email/confirm.go index 9f05a4f71..4fbe2a98f 100644 --- a/internal/email/confirm.go +++ b/internal/email/confirm.go @@ -26,13 +26,20 @@ const ( type ConfirmData struct { // Username to be addressed. Username string - // URL of the instance to present to the receiver. + // URL of the instance to + // present to the receiver. InstanceURL string - // Name of the instance to present to the receiver. + // Name of the instance to + // present to the receiver. InstanceName string - // Link to present to the receiver to click on and do the confirmation. - // Should be a full link with protocol eg., https://example.org/confirm_email?token=some-long-token + // Link to present to the receiver to + // click on and do the confirmation. + // Should be a full link with protocol + // eg., https://example.org/confirm_email?token=some-long-token ConfirmLink string + // Is this confirm email being sent + // because this is a new sign-up? + NewSignup bool } func (s *sender) SendConfirmEmail(toAddress string, data ConfirmData) error { diff --git a/internal/email/email_test.go b/internal/email/email_test.go index b57562cb5..aacca1b3d 100644 --- a/internal/email/email_test.go +++ b/internal/email/email_test.go @@ -40,12 +40,13 @@ func (suite *EmailTestSuite) SetupTest() { suite.sender = testrig.NewEmailSender("../../web/template/", suite.sentEmails) } -func (suite *EmailTestSuite) TestTemplateConfirm() { +func (suite *EmailTestSuite) TestTemplateConfirmNewSignup() { confirmData := email.ConfirmData{ Username: "test", InstanceURL: "https://example.org", InstanceName: "Test Instance", ConfirmLink: "https://example.org/confirm_email?token=ee24f71d-e615-43f9-afae-385c0799b7fa", + NewSignup: true, } suite.sender.SendConfirmEmail("user@example.org", confirmData) @@ -53,6 +54,20 @@ func (suite *EmailTestSuite) TestTemplateConfirm() { suite.Equal("To: user@example.org\r\nFrom: test@example.org\r\nSubject: GoToSocial Email Confirmation\r\nMIME-Version: 1.0\r\nContent-Transfer-Encoding: 8bit\r\nContent-Type: text/plain; charset=\"UTF-8\"\r\n\r\nHello test!\r\n\r\nYou are receiving this mail because you've requested an account on https://example.org.\r\n\r\nTo use your account, you must confirm that this is your email address.\r\n\r\nTo confirm your email, paste the following in your browser's address bar:\r\n\r\nhttps://example.org/confirm_email?token=ee24f71d-e615-43f9-afae-385c0799b7fa\r\n\r\n---\r\n\r\nIf you believe you've been sent this email in error, feel free to ignore it, or contact the administrator of https://example.org.\r\n\r\n", suite.sentEmails["user@example.org"]) } +func (suite *EmailTestSuite) TestTemplateConfirm() { + confirmData := email.ConfirmData{ + Username: "test", + InstanceURL: "https://example.org", + InstanceName: "Test Instance", + ConfirmLink: "https://example.org/confirm_email?token=ee24f71d-e615-43f9-afae-385c0799b7fa", + NewSignup: false, + } + + suite.sender.SendConfirmEmail("user@example.org", confirmData) + suite.Len(suite.sentEmails, 1) + suite.Equal("To: user@example.org\r\nFrom: test@example.org\r\nSubject: GoToSocial Email Confirmation\r\nMIME-Version: 1.0\r\nContent-Transfer-Encoding: 8bit\r\nContent-Type: text/plain; charset=\"UTF-8\"\r\n\r\nHello test!\r\n\r\nYou are receiving this mail because you've requested an email address change on https://example.org.\r\n\r\nTo complete the change, you must confirm that this is your email address.\r\n\r\nTo confirm your email, paste the following in your browser's address bar:\r\n\r\nhttps://example.org/confirm_email?token=ee24f71d-e615-43f9-afae-385c0799b7fa\r\n\r\n---\r\n\r\nIf you believe you've been sent this email in error, feel free to ignore it, or contact the administrator of https://example.org.\r\n\r\n", suite.sentEmails["user@example.org"]) +} + func (suite *EmailTestSuite) TestTemplateReset() { resetData := email.ResetData{ Username: "test", |