mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-22 17:10:10 +00:00
use goroutines for (most) emails
invite emails have been left alone so that email success message is shown on web ui
This commit is contained in:
parent
699489e435
commit
f0be006e16
6
api.go
6
api.go
@ -92,6 +92,7 @@ func (ctx *appContext) checkInvites() {
|
||||
ctx.debug.Printf("%s: Expiry notification", code)
|
||||
for address, settings := range notify {
|
||||
if settings["notify-expiry"] {
|
||||
go func() {
|
||||
if ctx.email.constructExpiry(code, data, ctx) != nil {
|
||||
ctx.err.Printf("%s: Failed to construct expiry notification", code)
|
||||
} else if ctx.email.send(address, ctx) != nil {
|
||||
@ -99,6 +100,7 @@ func (ctx *appContext) checkInvites() {
|
||||
} else {
|
||||
ctx.info.Printf("Sent expiry notification to %s", address)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -124,6 +126,7 @@ func (ctx *appContext) checkInvite(code string, used bool, username string) bool
|
||||
ctx.debug.Printf("%s: Expiry notification", code)
|
||||
for address, settings := range notify {
|
||||
if settings["notify-expiry"] {
|
||||
go func() {
|
||||
if ctx.email.constructExpiry(code, inv, ctx) != nil {
|
||||
ctx.err.Printf("%s: Failed to construct expiry notification", code)
|
||||
} else if ctx.email.send(address, ctx) != nil {
|
||||
@ -131,6 +134,7 @@ func (ctx *appContext) checkInvite(code string, used bool, username string) bool
|
||||
} else {
|
||||
ctx.info.Printf("Sent expiry notification to %s", address)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -212,6 +216,7 @@ func (ctx *appContext) NewUser(gc *gin.Context) {
|
||||
if ctx.config.Section("notifications").Key("enabled").MustBool(false) {
|
||||
for address, settings := range invite.Notify {
|
||||
if settings["notify-creation"] {
|
||||
go func() {
|
||||
if ctx.email.constructCreated(req.Code, req.Username, req.Email, invite, ctx) != nil {
|
||||
ctx.err.Printf("%s: Failed to construct user creation notification", req.Code)
|
||||
ctx.debug.Printf("%s: Error: %s", req.Code, err)
|
||||
@ -221,6 +226,7 @@ func (ctx *appContext) NewUser(gc *gin.Context) {
|
||||
} else {
|
||||
ctx.info.Printf("%s: Sent user creation notification to %s", req.Code, address)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user