-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
room.go
43 lines (37 loc) · 1.38 KB
/
room.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package model
import "github.com/Unkn0wnCat/matrix-veles/internal/config"
type Room struct {
ID string `json:"id"`
Active bool `json:"active"`
Deactivated bool `json:"deactivated"`
Name string `json:"name"`
RoomID string `json:"roomId"`
Debug bool `json:"debug"`
AdminPowerLevel int `json:"adminPowerLevel"`
HashCheckerConfig *HashCheckerConfig `json:"hashCheckerConfig"`
}
type HashCheckerConfig struct {
ChatNotice bool `json:"chatNotice"`
HashCheckMode HashCheckerMode `json:"hashCheckMode"`
SubscribedLists []string `json:"subscribedLists"`
}
func MakeRoom(room *config.RoomConfig) *Room {
var subscribed []string
for _, subId := range room.HashChecker.SubscribedLists {
subscribed = append(subscribed, subId.Hex())
}
return &Room{
ID: room.ID.Hex(),
Name: room.Name,
Active: room.Active && !room.Deactivate,
Deactivated: room.Deactivate,
RoomID: room.RoomID,
Debug: room.Debug,
AdminPowerLevel: room.AdminPowerLevel,
HashCheckerConfig: &HashCheckerConfig{
ChatNotice: room.HashChecker.NoticeToChat,
HashCheckMode: AllHashCheckerMode[room.HashChecker.HashCheckMode],
SubscribedLists: subscribed,
},
}
}