go lint is a bloody picky little bastard

This commit is contained in:
Peter Molnar 2021-03-01 19:28:11 +00:00
parent 9663721680
commit 14a83e08cb

View File

@ -2,10 +2,10 @@ package bsignald
import (
"bufio"
"net"
"encoding/json"
"github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config"
"net"
)
type JSONCMD map[string]interface{}
@ -13,7 +13,6 @@ type JSONCMD map[string]interface{}
const (
cfgNumber = "Number"
cfgSocket = "UnixSocket"
cfgGroupID = "GroupID"
)
type signaldMessage struct {
@ -180,13 +179,17 @@ func (b *Bsignald) HandleUnexpectedErrorMessage(msg signaldMessage) {
func (b *Bsignald) HandleSubscribeMessage() {
b.Log.Debugln("subscribe successful", b.GetString(cfgNumber))
b.subscribed = true
go b.GetContacts()
if err := b.GetContacts(); err != nil {
b.Log.Errorln("Error getting contacts: ", err.Error())
}
}
func (b *Bsignald) HandleListenStoppedMessage() {
b.Log.Errorln("got listen stopped, trying to re-subscribe")
b.subscribed = false
go b.Login()
if err := b.Login(); err != nil {
b.Log.Errorln("Error logging in: ", err.Error())
}
}
func (b *Bsignald) HandleContactList(msg signaldMessage) {
@ -203,12 +206,13 @@ func (b *Bsignald) HandleContactList(msg signaldMessage) {
func (b *Bsignald) GetUsername(uuid string) string {
username := ""
if v, found := b.contacts[uuid]; found {
if "" != v.ProfileName {
if v.ProfileName != "" {
username = v.ProfileName
} else if "" != v.Name {
} else if v.Name != "" {
username = v.Name
}
}
return username
}
@ -219,7 +223,7 @@ func (b *Bsignald) HandleMessage(msg signaldMessage) {
return
}
if nil == response.Data.DataMessage {
if response.Data.DataMessage == nil {
return
}
@ -234,13 +238,13 @@ func (b *Bsignald) HandleMessage(msg signaldMessage) {
}
}
if false == groupMatched {
if !groupMatched {
b.Log.Debugln("skipping non-group message")
return
}
username := b.GetUsername(response.Data.Source.UUID)
if "" == username {
if username == "" {
username = response.Data.Source.Number
}
@ -256,7 +260,6 @@ func (b *Bsignald) HandleMessage(msg signaldMessage) {
b.Log.Debugf("<= Sending message from %s on %s to gateway", rmsg.Username, b.Account)
b.Log.Debugf("<= Message is %#v", rmsg)
b.Remote <- rmsg
}
func (b *Bsignald) Listen() {
@ -288,7 +291,7 @@ func (b *Bsignald) Listen() {
case "message":
b.HandleMessage(msg)
default:
b.Log.Debugln("unsupported signald data received, skipping it");
b.Log.Debugln("unsupported signald data received, skipping it")
}
}
}
@ -314,7 +317,7 @@ func (b *Bsignald) Login() error {
return err
}
func (b *Bsignald) SendRawJSON(cmd JSONCMD) (error) {
func (b *Bsignald) SendRawJSON(cmd JSONCMD) error {
err := json.NewEncoder(b.socket).Encode(cmd)
if err != nil {
b.Log.Errorln(err.Error())