Log startup errors and only try to start users who have a token

This commit is contained in:
Tulir Asokan
2022-05-23 23:17:28 +03:00
parent 888731cec2
commit 17288f3d04
2 changed files with 8 additions and 3 deletions

View File

@@ -38,7 +38,7 @@ func (uq *UserQuery) GetByID(id string) *User {
} }
func (uq *UserQuery) GetAll() []*User { func (uq *UserQuery) GetAll() []*User {
rows, err := uq.db.Query(`SELECT mxid, id, management_room, token FROM "user"`) rows, err := uq.db.Query(`SELECT mxid, id, management_room, token FROM "user" WHERE token IS NOT NULL`)
if err != nil || rows == nil { if err != nil || rows == nil {
return nil return nil
} }

View File

@@ -182,8 +182,13 @@ func (br *DiscordBridge) getAllUsers() []*User {
func (br *DiscordBridge) startUsers() { func (br *DiscordBridge) startUsers() {
br.Log.Debugln("Starting users") br.Log.Debugln("Starting users")
for _, user := range br.getAllUsers() { for _, u := range br.getAllUsers() {
go user.Connect() go func(user *User) {
err := user.Connect()
if err != nil {
user.log.Errorfln("Error connecting: %v", err)
}
}(u)
} }
br.Log.Debugln("Starting custom puppets") br.Log.Debugln("Starting custom puppets")