♻️ Improve notifications mark read system
This commit is contained in:
@ -322,8 +322,10 @@ func DeleteAccount(id uint) error {
|
||||
}
|
||||
|
||||
func RecycleUnConfirmAccount() {
|
||||
deadline := time.Now().Add(-24 * time.Hour)
|
||||
|
||||
var hitList []models.Account
|
||||
if err := database.C.Where("confirmed_at IS NULL").Find(&hitList).Error; err != nil {
|
||||
if err := database.C.Where("confirmed_at IS NULL AND created_at <= ?", deadline).Find(&hitList).Error; err != nil {
|
||||
log.Error().Err(err).Msg("An error occurred while recycling accounts...")
|
||||
return
|
||||
}
|
||||
|
@ -20,7 +20,8 @@ func DoAutoDatabaseCleanup() {
|
||||
}
|
||||
|
||||
deadline := time.Now().Add(-30 * 24 * time.Hour)
|
||||
database.C.Unscoped().Where("created_at <= ?", deadline).Delete(&models.Notification{})
|
||||
seenDeadline := time.Now().Add(-7 * 24 * time.Hour)
|
||||
database.C.Unscoped().Where("created_at <= ? OR read_at <= ?", deadline, seenDeadline).Delete(&models.Notification{})
|
||||
|
||||
log.Debug().Int64("affected", count).Msg("Clean up entire database accomplished.")
|
||||
}
|
||||
|
Reference in New Issue
Block a user