mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 14:52:26 -05:00
[feature] New user sign-up via web page (#2796)
* [feature] User sign-up form and admin notifs * add chosen + filtered languages to migration * remove stray comment * chosen languages schmosen schmanguages * proper error on local account missing
This commit is contained in:
parent
a483bd9e38
commit
9fb8a78f91
68 changed files with 1456 additions and 437 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
42
internal/email/signup.go
Normal file
42
internal/email/signup.go
Normal file
|
|
@ -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...)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue