summaryrefslogtreecommitdiff
path: root/internal/email
diff options
context:
space:
mode:
Diffstat (limited to 'internal/email')
-rw-r--r--internal/email/email_test.go2
-rw-r--r--internal/email/noopsender.go4
-rw-r--r--internal/email/sender.go7
-rw-r--r--internal/email/signup.go42
4 files changed, 54 insertions, 1 deletions
diff --git a/internal/email/email_test.go b/internal/email/email_test.go
index 702b62075..ee9efeef8 100644
--- a/internal/email/email_test.go
+++ b/internal/email/email_test.go
@@ -50,7 +50,7 @@ func (suite *EmailTestSuite) TestTemplateConfirm() {
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\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\nWe just need to confirm that this is your email address. To 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\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"])
+ suite.Equal("To: user@example.org\r\nFrom: test@example.org\r\nSubject: GoToSocial Email Confirmation\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\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() {
diff --git a/internal/email/noopsender.go b/internal/email/noopsender.go
index 0ed7ff747..44aa86dba 100644
--- a/internal/email/noopsender.go
+++ b/internal/email/noopsender.go
@@ -68,6 +68,10 @@ func (s *noopSender) SendReportClosedEmail(toAddress string, data ReportClosedDa
return s.sendTemplate(reportClosedTemplate, reportClosedSubject, data, toAddress)
}
+func (s *noopSender) SendNewSignupEmail(toAddresses []string, data NewSignupData) error {
+ return s.sendTemplate(newSignupTemplate, newSignupSubject, data, toAddresses...)
+}
+
func (s *noopSender) sendTemplate(template string, subject string, data any, toAddresses ...string) error {
buf := &bytes.Buffer{}
if err := s.template.ExecuteTemplate(buf, template, data); err != nil {
diff --git a/internal/email/sender.go b/internal/email/sender.go
index b0d883d9d..78338a0dd 100644
--- a/internal/email/sender.go
+++ b/internal/email/sender.go
@@ -46,6 +46,13 @@ type Sender interface {
// SendReportClosedEmail sends an email notification to the given address, letting them
// know that a report that they created has been closed / resolved by an admin.
SendReportClosedEmail(toAddress string, data ReportClosedData) error
+
+ // SendNewSignupEmail sends an email notification to the given addresses,
+ // letting them know that a new sign-up has been submitted to the instance.
+ //
+ // It is expected that the toAddresses have already been filtered to ensure
+ // that they all belong to active admins + moderators.
+ SendNewSignupEmail(toAddress []string, data NewSignupData) error
}
// NewSender returns a new email Sender interface with the given configuration, or an error if something goes wrong.
diff --git a/internal/email/signup.go b/internal/email/signup.go
new file mode 100644
index 000000000..84162c21e
--- /dev/null
+++ b/internal/email/signup.go
@@ -0,0 +1,42 @@
+// GoToSocial
+// Copyright (C) GoToSocial Authors admin@gotosocial.org
+// SPDX-License-Identifier: AGPL-3.0-or-later
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+package email
+
+var (
+ newSignupTemplate = "email_new_signup.tmpl"
+ newSignupSubject = "GoToSocial New Sign-Up"
+)
+
+type NewSignupData struct {
+ // URL of the instance to present to the receiver.
+ InstanceURL string
+ // Name of the instance to present to the receiver.
+ InstanceName string
+ // Email address sign-up was created with.
+ SignupEmail string
+ // Username submitted on the sign-up form.
+ SignupUsername string
+ // Reason given on the sign-up form.
+ SignupReason string
+ // URL to open the sign-up in the settings panel.
+ SignupURL string
+}
+
+func (s *sender) SendNewSignupEmail(toAddresses []string, data NewSignupData) error {
+ return s.sendTemplate(newSignupTemplate, newSignupSubject, data, toAddresses...)
+}