Whoops & refactor
This commit is contained in:
parent
f3f1b8d981
commit
facc375e8c
2 changed files with 13 additions and 15 deletions
26
account.go
26
account.go
|
@ -87,13 +87,7 @@ func (a *Account) connect(config map[string]string, join_rooms []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, room := range join_rooms {
|
for _, room := range join_rooms {
|
||||||
var entry DbJoinedRoom
|
a.addAutojoin(RoomID(room))
|
||||||
db.Where(&DbJoinedRoom{
|
|
||||||
MxUserID: a.MatrixUser,
|
|
||||||
Protocol: a.Protocol,
|
|
||||||
AccountName: a.AccountName,
|
|
||||||
RoomID: RoomID(room),
|
|
||||||
}).FirstOrCreate(&entry)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var autojoin []DbJoinedRoom
|
var autojoin []DbJoinedRoom
|
||||||
|
@ -110,6 +104,16 @@ func (a *Account) connect(config map[string]string, join_rooms []string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *Account) addAutojoin(roomId RoomID) {
|
||||||
|
var entry DbJoinedRoom
|
||||||
|
db.Where(&DbJoinedRoom{
|
||||||
|
MxUserID: a.MatrixUser,
|
||||||
|
Protocol: a.Protocol,
|
||||||
|
AccountName: a.AccountName,
|
||||||
|
RoomID: roomId,
|
||||||
|
}).FirstOrCreate(&entry)
|
||||||
|
}
|
||||||
|
|
||||||
// ---- Begin event handlers ----
|
// ---- Begin event handlers ----
|
||||||
|
|
||||||
func (a *Account) Joined(roomId RoomID) {
|
func (a *Account) Joined(roomId RoomID) {
|
||||||
|
@ -118,13 +122,7 @@ func (a *Account) Joined(roomId RoomID) {
|
||||||
a.ezbrMessagef("Dropping Account.Joined %s: %s", roomId, err.Error())
|
a.ezbrMessagef("Dropping Account.Joined %s: %s", roomId, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
var entry DbJoinedRoom
|
a.addAutojoin(roomId)
|
||||||
db.Where(&DbJoinedRoom{
|
|
||||||
MxUserID: a.MatrixUser,
|
|
||||||
Protocol: a.Protocol,
|
|
||||||
AccountName: a.AccountName,
|
|
||||||
RoomID: roomId,
|
|
||||||
}).FirstOrCreate(&entry)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Account) joinedInternal(roomId RoomID) error {
|
func (a *Account) joinedInternal(roomId RoomID) error {
|
||||||
|
|
|
@ -82,7 +82,7 @@ func (xm *XMPP) Configure(c Configuration) error {
|
||||||
}
|
}
|
||||||
xm.jid_localpart = jid_parts[0]
|
xm.jid_localpart = jid_parts[0]
|
||||||
|
|
||||||
xm.nickname = c.GetString("nickname", xm.jid_locakpart)
|
xm.nickname, _ = c.GetString("nickname", xm.jid_localpart)
|
||||||
|
|
||||||
xm.password, err = c.GetString("password")
|
xm.password, err = c.GetString("password")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue