Support Reminder events

Move code to schedule to have event independent from NotificationPlatform
This commit is contained in:
Mo Tarbin 2025-02-10 01:44:42 -05:00
parent 04d1894aea
commit 80afab3bc0
7 changed files with 61 additions and 28 deletions

View file

@ -87,12 +87,13 @@ func generateDueNotifications(chore *chModel.Chore, users []*cModel.UserCircleDe
CreatedAt: time.Now().UTC(),
TypeID: user.NotificationType,
UserID: user.ID,
CircleID: user.CircleID,
TargetID: user.TargetID,
Text: fmt.Sprintf("📅 Reminder: *%s* is due today and assigned to %s.", chore.Name, assignee.DisplayName),
RawEvent: map[string]interface{}{
"id": chore.ID,
"name": chore.Name,
"due_date": chore.NextDueDate.Format("January 2nd"),
"due_date": chore.NextDueDate,
"assignee": assignee.DisplayName,
"assignee_username": assignee.Username,
},
@ -122,12 +123,13 @@ func generatePreDueNotifications(chore *chModel.Chore, users []*cModel.UserCircl
CreatedAt: time.Now().UTC().Add(-time.Hour * 3),
TypeID: user.NotificationType,
UserID: user.ID,
CircleID: user.CircleID,
TargetID: user.TargetID,
Text: fmt.Sprintf("📢 Heads up! *%s* is due soon (on %s) and assigned to %s.", chore.Name, chore.NextDueDate.Format("January 2nd"), assignee.DisplayName),
RawEvent: map[string]interface{}{
"id": chore.ID,
"name": chore.Name,
"due_date": chore.NextDueDate.Format("January 2nd"),
"due_date": chore.NextDueDate,
"assignee": assignee.DisplayName,
"assignee_username": assignee.Username,
},
@ -160,13 +162,14 @@ func generateOverdueNotifications(chore *chModel.Chore, users []*cModel.UserCirc
CreatedAt: time.Now().UTC(),
TypeID: user.NotificationType,
UserID: user.ID,
CircleID: user.CircleID,
TargetID: fmt.Sprint(user.TargetID),
Text: fmt.Sprintf("🚨 *%s* is now %d hours overdue. Please complete it as soon as possible. (Assigned to %s)", chore.Name, hours, assignee.DisplayName),
RawEvent: map[string]interface{}{
"id": chore.ID,
"type": EventTypeOverdue,
"name": chore.Name,
"due_date": chore.NextDueDate.Format("January 2nd"),
"due_date": chore.NextDueDate,
"assignee": assignee.DisplayName,
"assignee_username": assignee.Username,
},