mirror of
https://github.com/pushbits/server.git
synced 2025-07-23 19:37:52 +02:00
Add option to control repair behavior
This commit is contained in:
parent
38b615a05d
commit
77765e77a9
9 changed files with 49 additions and 22 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/pushbits/server/internal/authentication/credentials"
|
||||
"github.com/pushbits/server/internal/configuration"
|
||||
"github.com/pushbits/server/internal/log"
|
||||
"github.com/pushbits/server/internal/model"
|
||||
|
||||
|
@ -111,7 +112,7 @@ func (d *Database) Populate(name, password, matrixID string) error {
|
|||
}
|
||||
|
||||
// RepairChannels resets channels that have been modified by a user.
|
||||
func (d *Database) RepairChannels(dp Dispatcher) error {
|
||||
func (d *Database) RepairChannels(dp Dispatcher, behavior *configuration.RepairBehavior) error {
|
||||
log.L.Print("Repairing application channels.")
|
||||
|
||||
users, err := d.GetUsers()
|
||||
|
@ -130,7 +131,7 @@ func (d *Database) RepairChannels(dp Dispatcher) error {
|
|||
for _, application := range applications {
|
||||
application := application // See https://stackoverflow.com/a/68247837
|
||||
|
||||
if err := dp.UpdateApplication(&application); err != nil {
|
||||
if err := dp.UpdateApplication(&application, behavior); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package database
|
||||
|
||||
import (
|
||||
"github.com/pushbits/server/internal/configuration"
|
||||
"github.com/pushbits/server/internal/model"
|
||||
)
|
||||
|
||||
// The Dispatcher interface for constructing and destructing channels.
|
||||
type Dispatcher interface {
|
||||
DeregisterApplication(a *model.Application, u *model.User) error
|
||||
UpdateApplication(a *model.Application) error
|
||||
UpdateApplication(a *model.Application, behavior *configuration.RepairBehavior) error
|
||||
IsOrphan(a *model.Application, u *model.User) (bool, error)
|
||||
RepairApplication(a *model.Application, u *model.User) error
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue