Skip to content

Commit

Permalink
fix: handle zero interval in notification comment selection
Browse files Browse the repository at this point in the history
  • Loading branch information
revelaction committed Oct 26, 2024
1 parent 5174a9b commit d7318b1
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions ical/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d7318b1

Please sign in to comment.