mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-13 21:02:25 +03:00
Clean old notifications regularly (#2244)
* Clean old notifications regularly We'll keep highlights for a month and non-highlights for a day, to stop the `userapi_notifications` table from growing indefinitely. We'll also allow storing events even if no pushers are present, because apparently Element Web expects to work that way. * Fix the milliseconds * Use process context * Update sytest lists * Fix build issue
This commit is contained in:
parent
c44029f269
commit
5592322e13
9 changed files with 63 additions and 16 deletions
|
@ -15,6 +15,8 @@
|
|||
package userapi
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/matrix-org/dendrite/internal/pushgateway"
|
||||
keyapi "github.com/matrix-org/dendrite/keyserver/api"
|
||||
|
@ -79,5 +81,15 @@ func NewInternalAPI(
|
|||
logrus.WithError(err).Panic("failed to start user API streamed event consumer")
|
||||
}
|
||||
|
||||
var cleanOldNotifs func()
|
||||
cleanOldNotifs = func() {
|
||||
logrus.Infof("Cleaning old notifications")
|
||||
if err := db.DeleteOldNotifications(base.Context()); err != nil {
|
||||
logrus.WithError(err).Error("Failed to clean old notifications")
|
||||
}
|
||||
time.AfterFunc(time.Hour, cleanOldNotifs)
|
||||
}
|
||||
time.AfterFunc(time.Minute, cleanOldNotifs)
|
||||
|
||||
return userAPI
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue