feat: timezone awarenwss

This commit is contained in:
2026-03-18 01:35:09 +00:00
parent a85ac23a6b
commit db5d23c2ac
12 changed files with 406 additions and 64 deletions
+32 -17
View File
@@ -47,26 +47,41 @@ func StartScheduleReminderLoop(s *discordgo.Session, svc *services.Services) {
continue
}
// Build reminder text
whenStr := sch.ScheduledAt.UTC().Format("2006-01-02 15:04")
base := fmt.Sprintf("Reminder: you have a scheduled session at %s UTC with <@%d>.", whenStr, sch.InviteeID)
utcStr := sch.ScheduledAt.UTC().Format("2006-01-02 15:04")
desc := sch.Description
if desc != "" {
base += "\nTopic: " + desc
// Notify requester with local time if available.
if svc.UserSettings != nil {
locReq, zoneReq, _, err := svc.UserSettings.GetTimezone(ctx, sch.RequesterID)
if err != nil {
locReq = sch.ScheduledAt.UTC().Location()
zoneReq = "UTC"
}
localReq := sch.ScheduledAt.In(locReq).Format("2006-01-02 15:04")
base := fmt.Sprintf("Reminder: you have a scheduled session at %s UTC (%s %s) with <@%d>.", utcStr, localReq, zoneReq, sch.InviteeID)
if desc != "" {
base += "\nTopic: " + desc
}
if err := dmUser(s, sch.RequesterID, base); err != nil {
log.Printf("schedule: failed to DM requester reminder: %v", err)
}
}
// Notify requester
if err := dmUser(s, sch.RequesterID, base); err != nil {
log.Printf("schedule: failed to DM requester reminder: %v", err)
}
// Notify invitee (mirror text with requester mention)
baseInvitee := fmt.Sprintf("Reminder: you have a scheduled session at %s UTC with <@%d>.", whenStr, sch.RequesterID)
if desc != "" {
baseInvitee += "\nTopic: " + desc
}
if err := dmUser(s, sch.InviteeID, baseInvitee); err != nil {
log.Printf("schedule: failed to DM invitee reminder: %v", err)
// Notify invitee with their local time if available.
if svc.UserSettings != nil {
locInv, zoneInv, _, err := svc.UserSettings.GetTimezone(ctx, sch.InviteeID)
if err != nil {
locInv = sch.ScheduledAt.UTC().Location()
zoneInv = "UTC"
}
localInv := sch.ScheduledAt.In(locInv).Format("2006-01-02 15:04")
baseInvitee := fmt.Sprintf("Reminder: you have a scheduled session at %s UTC (%s %s) with <@%d>.", utcStr, localInv, zoneInv, sch.RequesterID)
if desc != "" {
baseInvitee += "\nTopic: " + desc
}
if err := dmUser(s, sch.InviteeID, baseInvitee); err != nil {
log.Printf("schedule: failed to DM invitee reminder: %v", err)
}
}
if err := svc.Schedule.MarkReminded(ctx, sch.ID); err != nil {