fix nil on client.Send

This commit is contained in:
Martin/Geno 2019-07-17 22:23:49 +02:00
parent e44fb17f40
commit 75f22d176a
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
2 changed files with 6 additions and 1 deletions

View File

@ -65,6 +65,8 @@ func Init(configInterface interface{}, db *database.DB, bot *bot.Bot) output.Out
return nil
}
cm := xmpp.NewStreamManager(client, func(c xmpp.Sender) {
out.client = c
for to, muc := range config.Defaults {
def := &database.Notify{
Protocol: proto,
@ -84,7 +86,6 @@ func Init(configInterface interface{}, db *database.DB, bot *bot.Bot) output.Out
}
}
logger.Info("join muc after connect")
out.client = c
})
go func() {
cm.Run()

View File

@ -31,6 +31,10 @@ func (out *Output) Join(to string) {
}
func (out *Output) Send(e *log.Entry, to *database.Notify) bool {
if out.client == nil {
logger.Error("xmpp not connected (yet)")
return false
}
html, text := formatLog(e)
if html == "" || text == "" {
logger.Error("during format notify")