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