fix golangci-lint warnings
This commit is contained in:
@@ -120,7 +120,7 @@ func (a *AppServiceNamespaces) containsRoom(roomID id.RoomID) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// nolint: wrapcheck
|
//nolint:wrapcheck
|
||||||
func (b *Bmatrix) startAppService() error {
|
func (b *Bmatrix) startAppService() error {
|
||||||
wrapper := b.appService
|
wrapper := b.appService
|
||||||
// TODO: detect service completion and rerun automatically
|
// TODO: detect service completion and rerun automatically
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ func (b *Bmatrix) ignoreBridgingEvents(ev *event.Event) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint: funlen
|
//nolint:funlen
|
||||||
func (b *Bmatrix) handleEvent(origin EventOrigin, ev *event.Event) {
|
func (b *Bmatrix) handleEvent(origin EventOrigin, ev *event.Event) {
|
||||||
b.RLock()
|
b.RLock()
|
||||||
channel, ok := b.RoomMap[ev.RoomID]
|
channel, ok := b.RoomMap[ev.RoomID]
|
||||||
@@ -170,7 +170,7 @@ func (b *Bmatrix) handleMessage(rmsg config.Message, ev *event.Event) {
|
|||||||
|
|
||||||
rmsg.Avatar = b.getAvatarURL(ev.RoomID, ev.Sender)
|
rmsg.Avatar = b.getAvatarURL(ev.RoomID, ev.Sender)
|
||||||
|
|
||||||
//nolint: exhaustive
|
//nolint:exhaustive
|
||||||
switch msg.MsgType {
|
switch msg.MsgType {
|
||||||
case event.MsgEmote:
|
case event.MsgEmote:
|
||||||
// Do we have a /me action
|
// Do we have a /me action
|
||||||
@@ -264,7 +264,7 @@ func (b *Bmatrix) handleUploadFiles(msg *config.Message, channel id.RoomID) (str
|
|||||||
}
|
}
|
||||||
|
|
||||||
// handleUploadFile handles native upload of a file.
|
// handleUploadFile handles native upload of a file.
|
||||||
//nolint: funlen
|
//nolint:funlen
|
||||||
func (b *Bmatrix) handleUploadFile(msg *config.Message, channel id.RoomID, fi *config.FileInfo) {
|
func (b *Bmatrix) handleUploadFile(msg *config.Message, channel id.RoomID, fi *config.FileInfo) {
|
||||||
content := bytes.NewReader(*fi.Data)
|
content := bytes.NewReader(*fi.Data)
|
||||||
sp := strings.Split(fi.Name, ".")
|
sp := strings.Split(fi.Name, ".")
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ type SendMessageEventWrapper struct {
|
|||||||
inner *matrix.Client
|
inner *matrix.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint: wrapcheck
|
//nolint:wrapcheck
|
||||||
func (w SendMessageEventWrapper) SendMessageEvent(roomID id.RoomID, eventType event.Type, contentJSON interface{}) (*matrix.RespSendEvent, error) {
|
func (w SendMessageEventWrapper) SendMessageEvent(roomID id.RoomID, eventType event.Type, contentJSON interface{}) (*matrix.RespSendEvent, error) {
|
||||||
return w.inner.SendMessageEvent(roomID, eventType, contentJSON)
|
return w.inner.SendMessageEvent(roomID, eventType, contentJSON)
|
||||||
}
|
}
|
||||||
@@ -286,7 +286,7 @@ func (b *Bmatrix) uploadAvatar(channelID id.RoomID, mxid id.UserID, intent *matr
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint: exhaustruct
|
//nolint:exhaustruct
|
||||||
matrixResp, err := b.mc.UploadMedia(matrix.ReqUploadMedia{
|
matrixResp, err := b.mc.UploadMedia(matrix.ReqUploadMedia{
|
||||||
ContentBytes: data,
|
ContentBytes: data,
|
||||||
ContentType: resp.Header.Get("Content-Type"),
|
ContentType: resp.Header.Get("Content-Type"),
|
||||||
@@ -305,7 +305,7 @@ func (b *Bmatrix) uploadAvatar(channelID id.RoomID, mxid id.UserID, intent *matr
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint: wrapcheck
|
//nolint:wrapcheck
|
||||||
func (b *Bmatrix) sendMessageEventWithRetries(channel id.RoomID, message event.MessageEventContent, username string, avatarURL string) (string, error) {
|
func (b *Bmatrix) sendMessageEventWithRetries(channel id.RoomID, message event.MessageEventContent, username string, avatarURL string) (string, error) {
|
||||||
var (
|
var (
|
||||||
resp *matrix.RespSendEvent
|
resp *matrix.RespSendEvent
|
||||||
@@ -333,7 +333,7 @@ func (b *Bmatrix) sendMessageEventWithRetries(channel id.RoomID, message event.M
|
|||||||
// if we can't change the display name it's not great but not the end of the world either, ignore it
|
// if we can't change the display name it's not great but not the end of the world either, ignore it
|
||||||
// TODO: do not perform this action on every message, with an in-memory cache or something
|
// TODO: do not perform this action on every message, with an in-memory cache or something
|
||||||
_ = intent.SetDisplayName(username)
|
_ = intent.SetDisplayName(username)
|
||||||
//nolint: errcheck
|
//nolint:errcheck
|
||||||
go b.uploadAvatar(channel, id.UserID(bridgeUserID), intent, avatarURL)
|
go b.uploadAvatar(channel, id.UserID(bridgeUserID), intent, avatarURL)
|
||||||
client = intent
|
client = intent
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// nolint: exhaustivestruct
|
//nolint:exhaustivestruct
|
||||||
package bmatrix
|
package bmatrix
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -80,7 +80,7 @@ func (b *Bmatrix) Connect() error {
|
|||||||
resp, err := b.mc.Login(&matrix.ReqLogin{
|
resp, err := b.mc.Login(&matrix.ReqLogin{
|
||||||
Type: matrix.AuthTypePassword,
|
Type: matrix.AuthTypePassword,
|
||||||
Password: b.GetString("Password"),
|
Password: b.GetString("Password"),
|
||||||
Identifier: matrix.UserIdentifier{Type: matrix.IdentifierTypeUser, User: b.GetString("Login")}, //nolint: exhaustruct
|
Identifier: matrix.UserIdentifier{Type: matrix.IdentifierTypeUser, User: b.GetString("Login")}, //nolint:exhaustruct
|
||||||
StoreCredentials: true,
|
StoreCredentials: true,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -195,7 +195,7 @@ func (b *Bmatrix) Start() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint: funlen,gocognit,gocyclo
|
//nolint:funlen,gocognit,gocyclo
|
||||||
func (b *Bmatrix) Send(msg config.Message) (string, error) {
|
func (b *Bmatrix) Send(msg config.Message) (string, error) {
|
||||||
b.Log.Debugf("=> Sending %#v", msg)
|
b.Log.Debugf("=> Sending %#v", msg)
|
||||||
|
|
||||||
@@ -334,7 +334,8 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) {
|
|||||||
|
|
||||||
// DontProcessOldEvents returns true if a sync event should be considered for further processing.
|
// DontProcessOldEvents returns true if a sync event should be considered for further processing.
|
||||||
// We use that function to filter out events we have already read.
|
// We use that function to filter out events we have already read.
|
||||||
//nolint: gocognit
|
//
|
||||||
|
//nolint:gocognit
|
||||||
func (b *Bmatrix) DontProcessOldEvents(resp *matrix.RespSync, since string) bool {
|
func (b *Bmatrix) DontProcessOldEvents(resp *matrix.RespSync, since string) bool {
|
||||||
// we only filter old events in the initial sync(), because subsequent sync()
|
// we only filter old events in the initial sync(), because subsequent sync()
|
||||||
// (where since != "") should only return new events
|
// (where since != "") should only return new events
|
||||||
|
|||||||
Reference in New Issue
Block a user