Add a muc option (useless yet)

This commit is contained in:
Bohdan Horbeshko 2022-07-07 18:23:50 -04:00
parent 0c71036148
commit afa21e10be
2 changed files with 13 additions and 0 deletions

View file

@ -39,6 +39,7 @@ type Session struct {
KeepOnline bool `yaml:":keeponline"` KeepOnline bool `yaml:":keeponline"`
RawMessages bool `yaml:":rawmessages"` RawMessages bool `yaml:":rawmessages"`
AsciiArrows bool `yaml:":asciiarrows"` AsciiArrows bool `yaml:":asciiarrows"`
MUC bool `yaml:":muc"`
} }
var configKeys = []string{ var configKeys = []string{
@ -46,6 +47,7 @@ var configKeys = []string{
"keeponline", "keeponline",
"rawmessages", "rawmessages",
"asciiarrows", "asciiarrows",
"muc",
} }
var sessionDB *SessionsYamlDB var sessionDB *SessionsYamlDB
@ -118,6 +120,8 @@ func (s *Session) Get(key string) (string, error) {
return fromBool(s.RawMessages), nil return fromBool(s.RawMessages), nil
case "asciiarrows": case "asciiarrows":
return fromBool(s.AsciiArrows), nil return fromBool(s.AsciiArrows), nil
case "muc":
return fromBool(s.MUC), nil
} }
return "", errors.New("Unknown session property") return "", errors.New("Unknown session property")
@ -161,6 +165,13 @@ func (s *Session) Set(key string, value string) (string, error) {
} }
s.AsciiArrows = b s.AsciiArrows = b
return value, nil return value, nil
case "muc":
b, err := toBool(value)
if err != nil {
return "", err
}
s.MUC = b
return value, nil
} }
return "", errors.New("Unknown session property") return "", errors.New("Unknown session property")

View file

@ -47,11 +47,13 @@ func TestSessionToMap(t *testing.T) {
session := Session{ session := Session{
Timezone: "klsf", Timezone: "klsf",
RawMessages: true, RawMessages: true,
MUC: true,
} }
m := session.ToMap() m := session.ToMap()
sample := map[string]string{ sample := map[string]string{
"timezone": "klsf", "timezone": "klsf",
"keeponline": "false", "keeponline": "false",
"muc": "true",
"rawmessages": "true", "rawmessages": "true",
"asciiarrows": "false", "asciiarrows": "false",
} }