syncForceFrequency = int(7 * 24 * time.Hour / syncInterval)
)
+type Room struct {
+ ID id.RoomID
+ Name string
+}
+
type Config struct {
- Homeserver string `json:"homeserver"`
- UserID id.UserID `json:"user_id"`
- Password string `json:"password,omitempty"`
- DeviceID id.DeviceID `json:"device_id,omitempty"`
- AccessToken string `json:"access_token,omitempty"`
- Rooms [][]id.RoomID `json:"rooms"`
+ Homeserver string `json:"homeserver"`
+ UserID id.UserID `json:"user_id"`
+ Password string `json:"password,omitempty"`
+ DeviceID id.DeviceID `json:"device_id,omitempty"`
+ AccessToken string `json:"access_token,omitempty"`
+ Rooms [][]Room `json:"rooms"`
}
func (c *Config) Load() error {
}
for _, group := range config.Rooms {
for _, room := range group {
- roomUsers[room] = map[id.UserID]struct{}{}
+ roomUsers[room.ID] = map[id.UserID]struct{}{}
}
}
client, err := Login(config)
}
for _, group := range config.Rooms {
for _, room := range group {
- syncPowerLevels(client, room, group, scoreData, counter%syncForceFrequency == 0)
+ syncPowerLevels(client, room.ID, group, scoreData, counter%syncForceFrequency == 0)
}
}
roomUsersMu.RUnlock()
return ret
}
-func syncPowerLevels(client *mautrix.Client, room id.RoomID, roomGroup []id.RoomID, scores map[id.RoomID]map[id.UserID]*Score, force bool) {
+func syncPowerLevels(client *mautrix.Client, room id.RoomID, roomGroup []Room, scores map[id.RoomID]map[id.UserID]*Score, force bool) {
roomLevels := roomPowerLevels[room]
if roomLevels == nil {
log.Printf("trying to ensure power levels for room %v, but did not get power level map yet", room)
prevLevel := roomLevels.Users[user]
level, raw := computePowerLevel(roomLevels.UsersDefault, *score)
for _, otherRoom := range roomGroup {
- if otherRoom == room {
+ if otherRoom.ID == room {
continue
}
- otherScore := scores[otherRoom][user]
+ otherScore := scores[otherRoom.ID][user]
if otherScore == nil {
continue
}