From 9fd67102ad2cca16c092e23ffd928b77ab08d7e0 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Wed, 21 Mar 2018 23:29:58 +0200 Subject: Refactoring and godocs --- config/config.go | 4 ++-- config/session.go | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'config') diff --git a/config/config.go b/config/config.go index 858f1d2..7d99274 100644 --- a/config/config.go +++ b/config/config.go @@ -27,8 +27,8 @@ import ( ) type Config struct { - MXID string `yaml:"mxid"` - HS string `yaml:"homeserver"` + UserID string `yaml:"mxid"` + HS string `yaml:"homeserver"` dir string `yaml:"-"` Session *Session `yaml:"-"` diff --git a/config/session.go b/config/session.go index 631c954..3fdc169 100644 --- a/config/session.go +++ b/config/session.go @@ -22,19 +22,19 @@ import ( "path/filepath" "maunium.net/go/gomatrix" - "maunium.net/go/gomuks/matrix/ext" + "maunium.net/go/gomuks/matrix/pushrules" rooms "maunium.net/go/gomuks/matrix/room" "maunium.net/go/gomuks/ui/debug" ) type Session struct { - MXID string `json:"-"` + UserID string `json:"-"` path string `json:"-"` AccessToken string NextBatch string FilterID string Rooms map[string]*rooms.Room - PushRules *gomx_ext.PushRuleset + PushRules *pushrules.PushRuleset } func (config *Config) LoadSession(mxid string) error { @@ -44,9 +44,9 @@ func (config *Config) LoadSession(mxid string) error { func (config *Config) NewSession(mxid string) *Session { return &Session{ - MXID: mxid, - path: filepath.Join(config.dir, mxid+".session"), - Rooms: make(map[string]*rooms.Room), + UserID: mxid, + path: filepath.Join(config.dir, mxid+".session"), + Rooms: make(map[string]*rooms.Room), } } @@ -76,7 +76,7 @@ func (s *Session) Load() error { func (s *Session) Save() error { data, err := json.Marshal(s) if err != nil { - debug.Print("Failed to marshal session of", s.MXID, err) + debug.Print("Failed to marshal session of", s.UserID, err) return err } @@ -99,7 +99,7 @@ func (s *Session) LoadNextBatch(_ string) string { func (s *Session) GetRoom(mxid string) *rooms.Room { room, _ := s.Rooms[mxid] if room == nil { - room = rooms.NewRoom(mxid, s.MXID) + room = rooms.NewRoom(mxid, s.UserID) s.Rooms[room.ID] = room } return room -- cgit v1.2.3