From d7318b14436e304fda6b7ce83bf6768431e67d68 Mon Sep 17 00:00:00 2001 From: revelaction <96388231+revelaction@users.noreply.github.com> Date: Sat, 26 Oct 2024 20:50:29 +0200 Subject: [PATCH] fix: handle zero interval in notification comment selection --- ical/parse.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ical/parse.go b/ical/parse.go index cc710df..7f66bc6 100644 --- a/ical/parse.go +++ b/ical/parse.go @@ -266,10 +266,16 @@ func (p *Parser) buildNotificationCommentCategories(n notify.Notification, event } // Select one Comment using pickModuloProp - if len(comments) > 1 { - commentIndex := pickModuloProp(et.interval, len(comments), n.EventTime) - n.Comment = comments[commentIndex] - } + if len(comments) > 1 { + if et.interval == 0 { + commentIndex := rand.Intn(len(comments)) + n.Comment = comments[commentIndex] + } else { + commentIndex := pickModuloProp(et.interval, len(comments), n.EventTime) + n.Comment = comments[commentIndex] + } + } + // Assign collected categories to the Notification property n.Categories = categories