Update announcements.go
Cette révision appartient à :
Parent
b8987829e1
révision
0e1a907a9a
1 fichiers modifiés avec 6 ajouts et 5 suppressions
|
@ -59,15 +59,15 @@ func addAnnouncement(c *gin.Context) {
|
|||
c.AbortWithStatus(http.StatusNotFound)
|
||||
}
|
||||
}
|
||||
delay := int(math.Ceil(math.Max(1, float64(announcement.Expire.Sub(time.Now())/(24*time.Hour)))))
|
||||
duration := int(math.Ceil(math.Max(1, float64(announcement.Expire.Sub(time.Now())/(24*time.Hour)))))
|
||||
form := &announcementValidator.CreateForm{
|
||||
ID: announcement.ID,
|
||||
Message: announcement.Content,
|
||||
Delay: delay,
|
||||
Duration: duration,
|
||||
}
|
||||
c.Bind(form)
|
||||
if form.Delay == 0 {
|
||||
form.Delay = delay
|
||||
if form.Duration == 0 {
|
||||
form.Duration = duration
|
||||
}
|
||||
templates.Form(c, "admin/announcement_form.jet.html", form)
|
||||
}
|
||||
|
@ -102,7 +102,8 @@ func postAnnouncement(c *gin.Context) {
|
|||
}
|
||||
} else { // announcement doesn't exist, we create it
|
||||
var err error
|
||||
announcement, err := notifications.NotifyAll(form.Message, time.Now().AddDate(0, 0, form.Delay))
|
||||
currentTime := time.Now()
|
||||
announcement, err := notifications.NotifyAll(form.Message, currentTime.Add(time.Hour * time.Duration(form.Duration)))
|
||||
if err != nil {
|
||||
// Error, we add it as a message
|
||||
messages.AddErrorT("errors", "create_failed")
|
||||
|
|
Référencer dans un nouveau ticket