diff options
author | Till Faelligen <2353100+S7evinK@users.noreply.github.com> | 2023-04-03 15:08:33 +0200 |
---|---|---|
committer | Till Faelligen <2353100+S7evinK@users.noreply.github.com> | 2023-04-03 15:08:33 +0200 |
commit | 10ef1fb11a547778b2ebec1b5cf9c4c743c76846 (patch) | |
tree | 87d3c597ddf7f646669354ba09ff7134d291658c /clientapi | |
parent | 675926967dda51e4833749aae9d14202d6040754 (diff) |
Remove sync.Once when setting up server notice sender
Diffstat (limited to 'clientapi')
-rw-r--r-- | clientapi/routing/routing.go | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go index 6c8035d4..58bea4ac 100644 --- a/clientapi/routing/routing.go +++ b/clientapi/routing/routing.go @@ -18,7 +18,6 @@ import ( "context" "net/http" "strings" - "sync" "github.com/gorilla/mux" userapi "github.com/matrix-org/dendrite/userapi/api" @@ -198,18 +197,13 @@ func Setup( // server notifications if cfg.Matrix.ServerNotices.Enabled { logrus.Info("Enabling server notices at /_synapse/admin/v1/send_server_notice") - var serverNotificationSender *userapi.Device - var err error - notificationSenderOnce := &sync.Once{} + serverNotificationSender, err := getSenderDevice(context.Background(), rsAPI, userAPI, cfg) + if err != nil { + logrus.WithError(err).Fatal("unable to get account for sending sending server notices") + } synapseAdminRouter.Handle("/admin/v1/send_server_notice/{txnID}", httputil.MakeAuthAPI("send_server_notice", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse { - notificationSenderOnce.Do(func() { - serverNotificationSender, err = getSenderDevice(context.Background(), rsAPI, userAPI, cfg) - if err != nil { - logrus.WithError(err).Fatal("unable to get account for sending sending server notices") - } - }) // not specced, but ensure we're rate limiting requests to this endpoint if r := rateLimits.Limit(req, device); r != nil { return *r @@ -231,12 +225,6 @@ func Setup( synapseAdminRouter.Handle("/admin/v1/send_server_notice", httputil.MakeAuthAPI("send_server_notice", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse { - notificationSenderOnce.Do(func() { - serverNotificationSender, err = getSenderDevice(context.Background(), rsAPI, userAPI, cfg) - if err != nil { - logrus.WithError(err).Fatal("unable to get account for sending sending server notices") - } - }) // not specced, but ensure we're rate limiting requests to this endpoint if r := rateLimits.Limit(req, device); r != nil { return *r |