From b75d0e582c403ee20d712150530c8c8d256ad44c Mon Sep 17 00:00:00 2001 From: binwiederhier Date: Mon, 15 Jun 2026 22:33:30 -0400 Subject: [PATCH] Rename --- mail/sender.go | 6 ++--- server/server.go | 41 +++++++++++++++-------------- server/server_account_email_test.go | 2 +- server/server_manager.go | 2 +- server/server_test.go | 2 +- 5 files changed, 27 insertions(+), 26 deletions(-) diff --git a/mail/sender.go b/mail/sender.go index 5463285f..7e0c4063 100644 --- a/mail/sender.go +++ b/mail/sender.go @@ -34,7 +34,7 @@ type Config struct { // SMTP-backed implementation; tests inject a fake. type Sender interface { SendNotification(to string, m *model.Message, senderIP string) error - Counts() (total int64, success int64, failure int64) + NotificationCounts() (total int64, success int64, failure int64) SendEmailVerification(to, link string) error SendPasswordReset(to, link string) error } @@ -67,8 +67,8 @@ func (s *realSender) SendNotification(to string, m *model.Message, senderIP stri return err } -// Counts returns the number of notification emails sent, broken down into total, success and failure -func (s *realSender) Counts() (total int64, success int64, failure int64) { +// NotificationCounts returns the number of notification emails sent, broken down into total, success and failure +func (s *realSender) NotificationCounts() (total int64, success int64, failure int64) { s.mu.Lock() defer s.mu.Unlock() return s.success + s.failure, s.success, s.failure diff --git a/server/server.go b/server/server.go index db338a22..de9c21b1 100644 --- a/server/server.go +++ b/server/server.go @@ -79,23 +79,26 @@ type handleFunc func(http.ResponseWriter, *http.Request, *visitor) error var ( // If changed, don't forget to update Android App and auth_sqlite.go - topicRegex = regexp.MustCompile(`^[-_A-Za-z0-9]{1,64}$`) // No /! - topicPathRegex = regexp.MustCompile(`^/[-_A-Za-z0-9]{1,64}$`) // Regex must match JS & Android app! - externalTopicPathRegex = regexp.MustCompile(`^/[^/]+\.[^/]+/[-_A-Za-z0-9]{1,64}$`) // Extended topic path, for web-app, e.g. /example.com/mytopic - webAppEmailVerifyRegex = regexp.MustCompile(`^/account/email/verify/[-_A-Za-z0-9]+$`) // Magic-link landing (served by the web app) - webAppPasswordResetRegex = regexp.MustCompile(`^/account/password/reset/[-_A-Za-z0-9]+$`) // Password-reset landing (served by the web app) - jsonPathRegex = regexp.MustCompile(`^/[-_A-Za-z0-9]{1,64}(,[-_A-Za-z0-9]{1,64})*/json$`) - ssePathRegex = regexp.MustCompile(`^/[-_A-Za-z0-9]{1,64}(,[-_A-Za-z0-9]{1,64})*/sse$`) - rawPathRegex = regexp.MustCompile(`^/[-_A-Za-z0-9]{1,64}(,[-_A-Za-z0-9]{1,64})*/raw$`) - wsPathRegex = regexp.MustCompile(`^/[-_A-Za-z0-9]{1,64}(,[-_A-Za-z0-9]{1,64})*/ws$`) - authPathRegex = regexp.MustCompile(`^/[-_A-Za-z0-9]{1,64}(,[-_A-Za-z0-9]{1,64})*/auth$`) - publishPathRegex = regexp.MustCompile(`^/[-_A-Za-z0-9]{1,64}/(publish|send|trigger)$`) - updatePathRegex = regexp.MustCompile(`^/[-_A-Za-z0-9]{1,64}/[-_A-Za-z0-9]{1,64}$`) - clearPathRegex = regexp.MustCompile(`^/[-_A-Za-z0-9]{1,64}/[-_A-Za-z0-9]{1,64}/(read|clear)$`) - sequenceIDRegex = topicRegex + topicRegex = regexp.MustCompile(`^[-_A-Za-z0-9]{1,64}$`) // No /! + topicPathRegex = regexp.MustCompile(`^/[-_A-Za-z0-9]{1,64}$`) // Regex must match JS & Android app! + externalTopicPathRegex = regexp.MustCompile(`^/[^/]+\.[^/]+/[-_A-Za-z0-9]{1,64}$`) // Extended topic path, for web-app, e.g. /example.com/mytopic + jsonPathRegex = regexp.MustCompile(`^/[-_A-Za-z0-9]{1,64}(,[-_A-Za-z0-9]{1,64})*/json$`) + ssePathRegex = regexp.MustCompile(`^/[-_A-Za-z0-9]{1,64}(,[-_A-Za-z0-9]{1,64})*/sse$`) + rawPathRegex = regexp.MustCompile(`^/[-_A-Za-z0-9]{1,64}(,[-_A-Za-z0-9]{1,64})*/raw$`) + wsPathRegex = regexp.MustCompile(`^/[-_A-Za-z0-9]{1,64}(,[-_A-Za-z0-9]{1,64})*/ws$`) + authPathRegex = regexp.MustCompile(`^/[-_A-Za-z0-9]{1,64}(,[-_A-Za-z0-9]{1,64})*/auth$`) + publishPathRegex = regexp.MustCompile(`^/[-_A-Za-z0-9]{1,64}/(publish|send|trigger)$`) + updatePathRegex = regexp.MustCompile(`^/[-_A-Za-z0-9]{1,64}/[-_A-Za-z0-9]{1,64}$`) + clearPathRegex = regexp.MustCompile(`^/[-_A-Za-z0-9]{1,64}/[-_A-Za-z0-9]{1,64}/(read|clear)$`) + sequenceIDRegex = topicRegex + + webAppConfigPath = "/config.js" + webAppManifestPath = "/manifest.webmanifest" + webAppEmailVerifyPathPrefix = "/account/email/verify/" // Browser landing route; raw token appended + webAppEmailVerifyRegex = regexp.MustCompile(`^/account/email/verify/[-_A-Za-z0-9]+$`) // Magic-link landing (served by the web app) + webAppPasswordResetPathPrefix = "/account/password/reset/" // Browser landing route; raw token appended + webAppPasswordResetRegex = regexp.MustCompile(`^/account/password/reset/[-_A-Za-z0-9]+$`) // Password-reset landing (served by the web app) - webConfigPath = "/config.js" - webManifestPath = "/manifest.webmanifest" accountPath = "/account" matrixPushPath = "/_matrix/push/v1/notify" metricsPath = "/metrics" @@ -121,8 +124,6 @@ var ( apiAccountEmailResendPath = "/v1/account/email/resend" apiAccountPasswordResetRequestPath = "/v1/account/password/reset/request" apiAccountPasswordResetPath = "/v1/account/password/reset" - webAppEmailVerifyPathPrefix = "/account/email/verify/" // Browser landing route; raw token appended - webAppPasswordResetPathPrefix = "/account/password/reset/" // Browser landing route; raw token appended apiAccountBillingPortalPath = "/v1/account/billing/portal" apiAccountBillingWebhookPath = "/v1/account/billing/webhook" apiAccountBillingSubscriptionPath = "/v1/account/billing/subscription" @@ -553,9 +554,9 @@ func (s *Server) handleInternal(w http.ResponseWriter, r *http.Request, v *visit return s.ensureAdmin(s.handleVersion)(w, r, v) } else if r.Method == http.MethodGet && r.URL.Path == apiConfigPath { return s.handleConfig(w, r, v) - } else if r.Method == http.MethodGet && r.URL.Path == webConfigPath { + } else if r.Method == http.MethodGet && r.URL.Path == webAppConfigPath { return s.ensureWebEnabled(s.handleWebConfig)(w, r, v) - } else if r.Method == http.MethodGet && r.URL.Path == webManifestPath { + } else if r.Method == http.MethodGet && r.URL.Path == webAppManifestPath { return s.ensureWebPushEnabled(s.handleWebManifest)(w, r, v) } else if r.Method == http.MethodGet && r.URL.Path == apiUsersPath { return s.ensureAdmin(s.handleUsersGet)(w, r, v) diff --git a/server/server_account_email_test.go b/server/server_account_email_test.go index a71d5979..e5168cfe 100644 --- a/server/server_account_email_test.go +++ b/server/server_account_email_test.go @@ -37,7 +37,7 @@ func (c *captureMailer) SendNotification(to string, m *model.Message, senderIP s return nil } -func (c *captureMailer) Counts() (total int64, success int64, failure int64) { +func (c *captureMailer) NotificationCounts() (total int64, success int64, failure int64) { return 0, 0, 0 } diff --git a/server/server_manager.go b/server/server_manager.go index 51a46078..f9334d7e 100644 --- a/server/server_manager.go +++ b/server/server_manager.go @@ -55,7 +55,7 @@ func (s *Server) execManager() { } var sentMailTotal, sentMailSuccess, sentMailFailure int64 if s.mailer != nil { - sentMailTotal, sentMailSuccess, sentMailFailure = s.mailer.Counts() + sentMailTotal, sentMailSuccess, sentMailFailure = s.mailer.NotificationCounts() } // Users diff --git a/server/server_test.go b/server/server_test.go index ea47dacb..646cd393 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -1326,7 +1326,7 @@ func (t *testMailer) SendNotification(to string, m *model.Message, senderIP stri return nil } -func (t *testMailer) Counts() (total int64, success int64, failure int64) { +func (t *testMailer) NotificationCounts() (total int64, success int64, failure int64) { return 0, 0, 0 }