fix(messages): send all email for a notifications sequentially to avoid to many connections bugs
Build and Push Docker image / build-and-push (push) Successful in 3m4s
Details
Build and Push Docker image / build-and-push (push) Successful in 3m4s
Details
This commit is contained in:
parent
9826b53035
commit
294fc8ac3d
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.stuve.uni-ulm.de/stuve-it/stuve-it-backend/ldapApi"
|
"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/logger"
|
||||||
"git.stuve.uni-ulm.de/stuve-it/stuve-it-backend/messages"
|
"git.stuve.uni-ulm.de/stuve-it/stuve-it-backend/messages"
|
||||||
"git.stuve.uni-ulm.de/stuve-it/stuve-it-backend/qrApi"
|
"git.stuve.uni-ulm.de/stuve-it/stuve-it-backend/qrApi"
|
||||||
|
@ -23,9 +24,9 @@ func main() {
|
||||||
app := pocketbase.New()
|
app := pocketbase.New()
|
||||||
|
|
||||||
// setup ldap sync
|
// setup ldap sync
|
||||||
//app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
|
app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
|
||||||
// return ldapSync.InitLdapSync(app)
|
return ldapSync.InitLdapSync(app)
|
||||||
//})
|
})
|
||||||
|
|
||||||
// setup ldap login
|
// setup ldap login
|
||||||
app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
|
app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
|
||||||
|
|
|
@ -96,7 +96,7 @@ func InitMessages(app *pocketbase.PocketBase, e *core.ServeEvent) error {
|
||||||
}
|
}
|
||||||
recipients := createdMessageRecord.ExpandedAll("recipients")
|
recipients := createdMessageRecord.ExpandedAll("recipients")
|
||||||
for _, recipient := range recipients {
|
for _, recipient := range recipients {
|
||||||
go sendEmailNotification(app, registry, recipient, createdMessageRecord)
|
sendEmailNotification(app, registry, recipient, createdMessageRecord)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get eventList entries to notify and event admins
|
// 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 {
|
if errs := app.Dao().ExpandRecord(record, []string{"user"}, nil); len(errs) > 0 {
|
||||||
logger.LogErrorF("Error expanding user for EmailNotifier: %v", errs)
|
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
|
// get event and eventAdmins
|
||||||
|
@ -137,7 +137,7 @@ func InitMessages(app *pocketbase.PocketBase, e *core.ServeEvent) error {
|
||||||
|
|
||||||
// send messages to all eventAdmins
|
// send messages to all eventAdmins
|
||||||
for _, record := range eventAdmins {
|
for _, record := range eventAdmins {
|
||||||
go sendEmailNotification(app, registry, record, createdMessageRecord)
|
sendEmailNotification(app, registry, record, createdMessageRecord)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue