feat: add time zone setting for reminders (#1092)
Instead of naeveily checking for all reminders due in the next minute, we now check all reminders in all time zones in the next minutes. This essentially means checking for reminders due in the next 14 or past 12 hours. We then check for each user who would receive a reminder from that result if it is actually due in their time zone. This should prevent issues where users would get the reminder in the time zone of their server, not in their own. Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/api/pulls/1092 Co-authored-by: konrad <k@knt.li> Co-committed-by: konrad <k@knt.li>
This commit is contained in:
@ -95,6 +95,7 @@ type User struct {
|
||||
DefaultListID int64 `xorm:"bigint null index" json:"-"`
|
||||
WeekStart int `xorm:"null" json:"-"`
|
||||
Language string `xorm:"varchar(50) null" json:"-"`
|
||||
Timezone string `xorm:"varchar(255) null" json:"-"`
|
||||
|
||||
DeletionScheduledAt time.Time `xorm:"datetime null" json:"-"`
|
||||
DeletionLastReminderSent time.Time `xorm:"datetime null" json:"-"`
|
||||
@ -462,6 +463,16 @@ func UpdateUser(s *xorm.Session, user *User) (updatedUser *User, err error) {
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we have a valid time zone
|
||||
if user.Timezone == "" {
|
||||
user.Timezone = config.GetTimeZone().String()
|
||||
}
|
||||
|
||||
_, err = time.LoadLocation(user.Timezone)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Update it
|
||||
_, err = s.
|
||||
ID(user.ID).
|
||||
@ -479,6 +490,7 @@ func UpdateUser(s *xorm.Session, user *User) (updatedUser *User, err error) {
|
||||
"default_list_id",
|
||||
"week_start",
|
||||
"language",
|
||||
"timezone",
|
||||
).
|
||||
Update(user)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user