mirror of
https://codeberg.org/scip/ephemerup.git
synced 2025-12-18 21:11:04 +01:00
Added mail notification support
This commit is contained in:
@@ -24,6 +24,7 @@ import (
|
||||
"github.com/tlinden/cenophane/cfg"
|
||||
"github.com/tlinden/cenophane/common"
|
||||
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -122,7 +123,7 @@ func UploadPost(c *fiber.Ctx, cfg *cfg.Config, db *Db) error {
|
||||
|
||||
// ok, check if we need to remove a form, if so we do it in the
|
||||
// background. delete error doesn't lead to upload failure, we
|
||||
// only log it.
|
||||
// only log it. same applies to mail notification.
|
||||
formid, _ := SessionGetFormId(c)
|
||||
if formid != "" {
|
||||
go func() {
|
||||
@@ -132,6 +133,16 @@ func UploadPost(c *fiber.Ctx, cfg *cfg.Config, db *Db) error {
|
||||
if r.Forms[0].Expire == "asap" {
|
||||
db.Delete(apicontext, formid)
|
||||
}
|
||||
|
||||
// email notification to form creator
|
||||
if r.Forms[0].Notify != "" {
|
||||
body := fmt.Sprintf("Upload is available under: %s", returnUrl)
|
||||
subject := fmt.Sprintf("Upload form %s has been used", formid)
|
||||
err := Sendmail(cfg, r.Forms[0].Notify, body, subject)
|
||||
if err != nil {
|
||||
Log("Failed to send mail: %s", err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user