diff options
Diffstat (limited to 'internal')
-rw-r--r-- | internal/api/client/admin/emailtest.go | 13 | ||||
-rw-r--r-- | internal/api/model/admin.go | 4 | ||||
-rw-r--r-- | internal/email/test.go | 2 | ||||
-rw-r--r-- | internal/processing/admin/email.go | 19 |
4 files changed, 31 insertions, 7 deletions
diff --git a/internal/api/client/admin/emailtest.go b/internal/api/client/admin/emailtest.go index 42b405ce7..9b214a926 100644 --- a/internal/api/client/admin/emailtest.go +++ b/internal/api/client/admin/emailtest.go @@ -54,6 +54,12 @@ import ( // in: formData // description: The email address that the test email should be sent to. // type: string +// required: true +// - +// name: message +// in: formData +// description: Optional message to include in the email. +// type: string // // security: // - OAuth2 Bearer: @@ -115,7 +121,12 @@ func (m *Module) EmailTestPOSTHandler(c *gin.Context) { return } - errWithCode := m.processor.Admin().EmailTest(c.Request.Context(), authed.Account, email.Address) + errWithCode := m.processor.Admin().EmailTest( + c.Request.Context(), + authed.Account, + email.Address, + form.Message, + ) if errWithCode != nil { apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1) return diff --git a/internal/api/model/admin.go b/internal/api/model/admin.go index 637ab0ed7..4623a720f 100644 --- a/internal/api/model/admin.go +++ b/internal/api/model/admin.go @@ -201,7 +201,9 @@ type MediaCleanupRequest struct { // AdminSendTestEmailRequest models a test email send request (woah). type AdminSendTestEmailRequest struct { // Email address to send the test email to. - Email string `form:"email" json:"email" xml:"email"` + Email string `form:"email" json:"email"` + // Optional message to include in the test email. + Message string `form:"message" json:"message"` } type AdminInstanceRule struct { diff --git a/internal/email/test.go b/internal/email/test.go index 7d6ac2b3b..762711b76 100644 --- a/internal/email/test.go +++ b/internal/email/test.go @@ -25,6 +25,8 @@ const ( type TestData struct { // Username of admin user who sent the test. SendingUsername string + // (Optional) message to include in the email. + Message string // URL of the instance to present to the receiver. InstanceURL string // Name of the instance to present to the receiver. diff --git a/internal/processing/admin/email.go b/internal/processing/admin/email.go index fb78f1fcc..fda60754c 100644 --- a/internal/processing/admin/email.go +++ b/internal/processing/admin/email.go @@ -27,11 +27,19 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" ) -// EmailTest sends a generic test email to the given toAddress (which -// should be a valid email address). To help callers differentiate between -// proper errors and the smtp errors they're likely fishing for, will return -// 422 + help text on an SMTP error, or error 500 otherwise. -func (p *Processor) EmailTest(ctx context.Context, account *gtsmodel.Account, toAddress string) gtserror.WithCode { +// EmailTest sends a generic test email to the given +// toAddress (which should be a valid email address). +// Message is optional and can be an empty string. +// +// To help callers differentiate between proper errors +// and the smtp errors they're likely fishing for, will +// return 422 + help text on an SMTP error, or 500 otherwise. +func (p *Processor) EmailTest( + ctx context.Context, + account *gtsmodel.Account, + toAddress string, + message string, +) gtserror.WithCode { // Pull our instance entry from the database, // so we can greet the email recipient nicely. instance, err := p.state.DB.GetInstance(ctx, config.GetHost()) @@ -42,6 +50,7 @@ func (p *Processor) EmailTest(ctx context.Context, account *gtsmodel.Account, to testData := email.TestData{ SendingUsername: account.Username, + Message: message, InstanceURL: instance.URI, InstanceName: instance.Title, } |