From 294fc8ac3dcc2bd9a823adab29c43658e8866a7b Mon Sep 17 00:00:00 2001 From: valentinkolb Date: Thu, 20 Jun 2024 19:44:17 +0200 Subject: [PATCH] fix(messages): send all email for a notifications sequentially to avoid to many connections bugs --- main/main.go | 7 ++++--- messages/main.go | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/main/main.go b/main/main.go index 2b2e544..a6d7ba7 100644 --- a/main/main.go +++ b/main/main.go @@ -2,6 +2,7 @@ package main import ( "git.stuve.uni-ulm.de/stuve-it/stuve-it-backend/ldapApi" + "git.stuve.uni-ulm.de/stuve-it/stuve-it-backend/ldapSync" "git.stuve.uni-ulm.de/stuve-it/stuve-it-backend/logger" "git.stuve.uni-ulm.de/stuve-it/stuve-it-backend/messages" "git.stuve.uni-ulm.de/stuve-it/stuve-it-backend/qrApi" @@ -23,9 +24,9 @@ func main() { app := pocketbase.New() // setup ldap sync - //app.OnBeforeServe().Add(func(e *core.ServeEvent) error { - // return ldapSync.InitLdapSync(app) - //}) + app.OnBeforeServe().Add(func(e *core.ServeEvent) error { + return ldapSync.InitLdapSync(app) + }) // setup ldap login app.OnBeforeServe().Add(func(e *core.ServeEvent) error { diff --git a/messages/main.go b/messages/main.go index e947c54..674b7ec 100644 --- a/messages/main.go +++ b/messages/main.go @@ -96,7 +96,7 @@ func InitMessages(app *pocketbase.PocketBase, e *core.ServeEvent) error { } recipients := createdMessageRecord.ExpandedAll("recipients") for _, recipient := range recipients { - go sendEmailNotification(app, registry, recipient, createdMessageRecord) + sendEmailNotification(app, registry, recipient, createdMessageRecord) } // get eventList entries to notify and event admins @@ -122,7 +122,7 @@ func InitMessages(app *pocketbase.PocketBase, e *core.ServeEvent) error { if errs := app.Dao().ExpandRecord(record, []string{"user"}, nil); len(errs) > 0 { logger.LogErrorF("Error expanding user for EmailNotifier: %v", errs) } - go sendEmailNotification(app, registry, record.ExpandedOne("user"), createdMessageRecord) + sendEmailNotification(app, registry, record.ExpandedOne("user"), createdMessageRecord) } // get event and eventAdmins @@ -137,7 +137,7 @@ func InitMessages(app *pocketbase.PocketBase, e *core.ServeEvent) error { // send messages to all eventAdmins for _, record := range eventAdmins { - go sendEmailNotification(app, registry, record, createdMessageRecord) + sendEmailNotification(app, registry, record, createdMessageRecord) } }