1
0
Fork 0

Fix nil pointer on database.GetLine()

This commit is contained in:
Chteufleur 2016-08-11 19:49:21 +02:00
parent a6281fe093
commit 149c5f9117
2 changed files with 14 additions and 10 deletions

View File

@ -132,7 +132,7 @@ func RemoveLine(jid string) bool {
func GetLine(jid string) *DatabaseLine { func GetLine(jid string) *DatabaseLine {
ret := getLine(jid) ret := getLine(jid)
if ret.SteamLogin == "" { if ret == nil || ret.SteamLogin == "" {
log.Printf("%sLine empty", LogDebug) log.Printf("%sLine empty", LogDebug)
return nil return nil
} }

View File

@ -108,18 +108,22 @@ func execCommandAdHoc(iq *xmpp.Iq) {
jidBare := strings.SplitN(iq.From, "/", 2)[0] jidBare := strings.SplitN(iq.From, "/", 2)[0]
dbUser := database.GetLine(jidBare) dbUser := database.GetLine(jidBare)
dbUser.Debug = !dbUser.Debug if dbUser != nil {
g := MapGatewayInfo[jidBare] dbUser.Debug = !dbUser.Debug
ok := dbUser.UpdateLine() g := MapGatewayInfo[jidBare]
if ok && g != nil { ok := dbUser.UpdateLine()
g.DebugMessage = dbUser.Debug if ok && g != nil {
if dbUser.Debug { g.DebugMessage = dbUser.Debug
note.Value = "Debug activated." if dbUser.Debug {
note.Value = "Debug activated."
} else {
note.Value = "Debug desactivated."
}
} else { } else {
note.Value = "Debug desactivated." note.Value = "Failed to update your profile. :("
} }
} else { } else {
note.Value = "Failed to update your profile. :(" note.Value = "Your not registered."
} }
cmd.Note = *note cmd.Note = *note