resync rooms every 5 minutes

This commit is contained in:
Aine
2023-01-03 20:13:30 +02:00
parent 2ac6c64d13
commit f54b87c1f7
3 changed files with 18 additions and 2 deletions

View File

@@ -45,6 +45,7 @@ func (m *Manager) GetBot() Bot {
}
if config == nil {
config = make(Bot, 0)
return config
}
m.ble = config.BanlistEnabled()
@@ -86,6 +87,7 @@ func (m *Manager) GetBanlist() List {
}
if config == nil {
config = make(List, 0)
return config
}
m.bl = config
return config
@@ -115,6 +117,7 @@ func (m *Manager) GetGreylist() List {
}
if config == nil {
config = make(List, 0)
return config
}
return config

View File

@@ -38,9 +38,11 @@ func (b *Bot) migrate() error {
}
func (b *Bot) syncRooms() error {
adminRooms := []id.RoomID{}
adminRoom := b.cfg.GetBot().AdminRoom()
if adminRoom != "" {
b.adminRooms = append(b.adminRooms, adminRoom)
adminRooms = append(adminRooms, adminRoom)
}
resp, err := b.lp.GetClient().JoinedRooms()
@@ -60,9 +62,10 @@ func (b *Bot) syncRooms() error {
}
if cfg.Owner() != "" && b.allowAdmin(id.UserID(cfg.Owner()), "") {
b.adminRooms = append(b.adminRooms, roomID)
adminRooms = append(adminRooms, roomID)
}
}
b.adminRooms = adminRooms
return nil
}
@@ -101,3 +104,8 @@ func (b *Bot) initBotUsers() ([]string, error) {
cfg.Set(config.BotUsers, "@*:"+homeserver)
return cfg.Users(), b.cfg.SetBot(cfg)
}
// SyncRooms and mailboxes
func (b *Bot) SyncRooms() {
b.syncRooms() //nolint:errcheck // nothing can be done here
}