Sanitize notification before processing it

This commit is contained in:
eikendev 2022-02-13 16:57:07 +01:00
parent 21afef0128
commit e676b723e9
No known key found for this signature in database
GPG key ID: A1BDB1B28C8EF694
2 changed files with 18 additions and 12 deletions

View file

@ -1,6 +1,7 @@
package model
import (
"strings"
"time"
)
@ -16,6 +17,17 @@ type Notification struct {
Date time.Time `json:"date"`
}
// Sanitize sets explicit defaults for a notification.
func (n *Notification) Sanitize(application *Application) {
n.ID = ""
n.UrlEncodedID = ""
n.ApplicationID = application.ID
if strings.TrimSpace(n.Title) == "" {
n.Title = application.Name
}
n.Date = time.Now()
}
// DeleteNotification holds information like the message ID of a deletion notification.
type DeleteNotification struct {
ID string `json:"id" form:"id"`