commit 1b1927ce13eb0fecb94548a56f1df58b63af7c8b
Author: Duco van Amstel <duco.vanamstel@gmail.com>
Date: Thu Nov 15 19:43:43 2018 +0000
diff --git a/.travis.yml b/.travis.yml
index a2b69c8..b8d9b9f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -407 +407 @@ script:
#- test -z "$(go fmt ./...)" # Fail if a .go file hasn't been formatted with gofmt
- go test -v -race $PKGS # Run all the tests with the race detector enabled
#- go vet $PKGS # go vet is the official Go static analyzer
- - golangci-lint run --enable-all -D golint -D lll -D errcheck -D gosec -D maligned -D prealloc -D gocyclo -D gochecknoglobals
+ - golangci-lint run --enable-all -D lll -D errcheck -D gosec -D maligned -D prealloc -D gocyclo -D gochecknoglobals
#- megacheck $PKGS # "go vet on steroids" + linter
- /bin/bash ci/bintray.sh
#- golint -set_exit_status $PKGS # one last linter
diff --git a/bridge/api/api.go b/bridge/api/api.go
index eef41a4..f8a7c04 100644
--- a/bridge/api/api.go
+++ b/bridge/api/api.go
@@ -1313 +1313 @@ import (
"github.com/zfjagann/golang-ring"
)
-type Api struct {
+type API struct {
Messages ring.Ring
sync.RWMutex
*bridge.Config
}
-type ApiMessage struct {
+type Message struct {
Text string `json:"text"`
Username string `json:"username"`
UserID string `json:"userid"`
@@ -287 +287 @@ type ApiMessage struct {
}
func New(cfg *bridge.Config) bridge.Bridger {
- b := &Api{Config: cfg}
+ b := &API{Config: cfg}
e := echo.New()
e.HideBanner = true
e.HidePort = true
@@ -5534 +5534 @@ func New(cfg *bridge.Config) bridge.Bridger {
return b
}
-func (b *Api) Connect() error {
+func (b *API) Connect() error {
return nil
}
-func (b *Api) Disconnect() error {
+func (b *API) Disconnect() error {
return nil
}
-func (b *Api) JoinChannel(channel config.ChannelInfo) error {
+func (b *API) JoinChannel(channel config.ChannelInfo) error {
return nil
}
-func (b *Api) Send(msg config.Message) (string, error) {
+func (b *API) Send(msg config.Message) (string, error) {
b.Lock()
defer b.Unlock()
// ignore delete messages
- if msg.Event == config.EVENT_MSG_DELETE {
+ if msg.Event == config.EventMsgDelete {
return "", nil
}
b.Messages.Enqueue(&msg)
return "", nil
}
-func (b *Api) handleHealthcheck(c echo.Context) error {
+func (b *API) handleHealthcheck(c echo.Context) error {
return c.String(http.StatusOK, "OK")
}
-func (b *Api) handlePostMessage(c echo.Context) error {
+func (b *API) handlePostMessage(c echo.Context) error {
message := config.Message{}
if err := c.Bind(&message); err != nil {
return err
@@ -987 +987 @@ func (b *Api) handlePostMessage(c echo.Context) error {
return c.JSON(http.StatusOK, message)
}
-func (b *Api) handleMessages(c echo.Context) error {
+func (b *API) handleMessages(c echo.Context) error {
b.Lock()
defer b.Unlock()
c.JSONPretty(http.StatusOK, b.Messages.Values(), " ")
@@ -10611 +10611 @@ func (b *Api) handleMessages(c echo.Context) error {
return nil
}
-func (b *Api) handleStream(c echo.Context) error {
+func (b *API) handleStream(c echo.Context) error {
c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSON)
c.Response().WriteHeader(http.StatusOK)
greet := config.Message{
- Event: config.EVENT_API_CONNECTED,
+ Event: config.EventAPIConnected,
Timestamp: time.Now(),
}
if err := json.NewEncoder(c.Response()).Encode(greet); err != nil {
diff --git a/bridge/config/config.go b/bridge/config/config.go
index 74f7f53..064f04a 100644
--- a/bridge/config/config.go
+++ b/bridge/config/config.go
@@ -1416 +1416 @@ import (
)
const (
- EVENT_JOIN_LEAVE = "join_leave"
- EVENT_TOPIC_CHANGE = "topic_change"
- EVENT_FAILURE = "failure"
- EVENT_FILE_FAILURE_SIZE = "file_failure_size"
- EVENT_AVATAR_DOWNLOAD = "avatar_download"
- EVENT_REJOIN_CHANNELS = "rejoin_channels"
- EVENT_USER_ACTION = "user_action"
- EVENT_MSG_DELETE = "msg_delete"
- EVENT_API_CONNECTED = "api_connected"
- EVENT_USER_TYPING = "user_typing"
+ EventJoinLeave = "join_leave"
+ EventTopicChange = "topic_change"
+ EventFailure = "failure"
+ EventFileFailureSize = "file_failure_size"
+ EventAvatarDownload = "avatar_download"
+ EventRejoinChannels = "rejoin_channels"
+ EventUserAction = "user_action"
+ EventMsgDelete = "msg_delete"
+ EventAPIConnected = "api_connected"
+ EventUserTyping = "user_typing"
)
type Message struct {
@@ -15720 +15720 @@ type SameChannelGateway struct {
Accounts []string
}
-type ConfigValues struct {
- Api map[string]Protocol
- Irc map[string]Protocol
+type BridgeValues struct {
+ API map[string]Protocol
+ IRC map[string]Protocol
Mattermost map[string]Protocol
Matrix map[string]Protocol
Slack map[string]Protocol
SlackLegacy map[string]Protocol
Steam map[string]Protocol
Gitter map[string]Protocol
- Xmpp map[string]Protocol
+ XMPP map[string]Protocol
Discord map[string]Protocol
Telegram map[string]Protocol
Rocketchat map[string]Protocol
- Sshchat map[string]Protocol
+ SSHChat map[string]Protocol
Zulip map[string]Protocol
General Protocol
Gateway []Gateway
@@ -1787 +1787 @@ type ConfigValues struct {
}
type Config interface {
- ConfigValues() *ConfigValues
+ BridgeValues() *BridgeValues
GetBool(key string) (bool, bool)
GetInt(key string) (int, bool)
GetString(key string) (string, bool)
@@ -1907 +1907 @@ type config struct {
v *viper.Viper
sync.RWMutex
- cv *ConfigValues
+ cv *BridgeValues
}
func NewConfig(cfgfile string) Config {
@@ -2367 +2367 @@ func newConfigFromString(input []byte) *config {
log.Fatal(err)
}
- cfg := &ConfigValues{}
+ cfg := &BridgeValues{}
err = viper.Unmarshal(cfg)
if err != nil {
log.Fatal(err)
@@ -2477 +2477 @@ func newConfigFromString(input []byte) *config {
}
}
-func (c *config) ConfigValues() *ConfigValues {
+func (c *config) BridgeValues() *BridgeValues {
return c.cv
}
diff --git a/bridge/discord/discord.go b/bridge/discord/discord.go
index b41c2e5..d3fc8eb 100644
--- a/bridge/discord/discord.go
+++ b/bridge/discord/discord.go
@@ -1297 +1297 @@ func (b *Bdiscord) Send(msg config.Message) (string, error) {
}
// Make a action /me of the message
- if msg.Event == config.EVENT_USER_ACTION {
+ if msg.Event == config.EventUserAction {
msg.Text = "_" + msg.Text + "_"
}
@@ -1477 +1477 @@ func (b *Bdiscord) Send(msg config.Message) (string, error) {
// Use webhook to send the message
if wID != "" {
// skip events
- if msg.Event != "" && msg.Event != config.EVENT_JOIN_LEAVE && msg.Event != config.EVENT_TOPIC_CHANGE {
+ if msg.Event != "" && msg.Event != config.EventJoinLeave && msg.Event != config.EventTopicChange {
return "", nil
}
b.Log.Debugf("Broadcasting using Webhook")
@@ -1797 +1797 @@ func (b *Bdiscord) Send(msg config.Message) (string, error) {
b.Log.Debugf("Broadcasting using token (API)")
// Delete message
- if msg.Event == config.EVENT_MSG_DELETE {
+ if msg.Event == config.EventMsgDelete {
if msg.ID == "" {
return "", nil
}
@@ -2177 +2177 @@ func (b *Bdiscord) Send(msg config.Message) (string, error) {
}
func (b *Bdiscord) messageDelete(s *discordgo.Session, m *discordgo.MessageDelete) {
- rmsg := config.Message{Account: b.Account, ID: m.ID, Event: config.EVENT_MSG_DELETE, Text: config.EVENT_MSG_DELETE}
+ rmsg := config.Message{Account: b.Account, ID: m.ID, Event: config.EventMsgDelete, Text: config.EventMsgDelete}
rmsg.Channel = b.getChannelName(m.ChannelID)
if b.UseChannelID {
rmsg.Channel = "ID:" + m.ChannelID
@@ -3007 +3007 @@ func (b *Bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreat
var ok bool
rmsg.Text, ok = b.replaceAction(rmsg.Text)
if ok {
- rmsg.Event = config.EVENT_USER_ACTION
+ rmsg.Event = config.EventUserAction
}
b.Log.Debugf("<= Sending message from %s on %s to gateway", m.Author.Username, b.Account)
diff --git a/bridge/gitter/gitter.go b/bridge/gitter/gitter.go
index f47ca7e..486fe43 100644
--- a/bridge/gitter/gitter.go
+++ b/bridge/gitter/gitter.go
@@ -777 +777 @@ func (b *Bgitter) JoinChannel(channel config.ChannelInfo) error {
Account: b.Account, Avatar: b.getAvatar(ev.Message.From.Username), UserID: ev.Message.From.ID,
ID: ev.Message.ID}
if strings.HasPrefix(ev.Message.Text, "@"+ev.Message.From.Username) {
- rmsg.Event = config.EVENT_USER_ACTION
+ rmsg.Event = config.EventUserAction
rmsg.Text = strings.Replace(rmsg.Text, "@"+ev.Message.From.Username+" ", "", -1)
}
b.Log.Debugf("<= Message is %#v", rmsg)
@@ -1007 +1007 @@ func (b *Bgitter) Send(msg config.Message) (string, error) {
}
// Delete message
- if msg.Event == config.EVENT_MSG_DELETE {
+ if msg.Event == config.EventMsgDelete {
if msg.ID == "" {
return "", nil
}
diff --git a/bridge/helper/helper.go b/bridge/helper/helper.go
index bd5e140..c1a48ce 100644
--- a/bridge/helper/helper.go
+++ b/bridge/helper/helper.go
@@ -827 +827 @@ func GetSubLines(message string, maxLineLength int) []string {
func HandleExtra(msg *config.Message, general *config.Protocol) []config.Message {
extra := msg.Extra
rmsg := []config.Message{}
- for _, f := range extra[config.EVENT_FILE_FAILURE_SIZE] {
+ for _, f := range extra[config.EventFileFailureSize] {
fi := f.(config.FileInfo)
text := fmt.Sprintf("file %s too big to download (%#v > allowed size: %#v)", fi.Name, fi.Size, general.MediaDownloadSize)
rmsg = append(rmsg, config.Message{Text: text, Username: "<system> ", Channel: msg.Channel, Account: msg.Account})
@@ -1137 +1137 @@ func HandleDownloadSize(flog *log.Entry, msg *config.Message, name string, size
}
flog.Debugf("Trying to download %#v with size %#v", name, size)
if int(size) > general.MediaDownloadSize {
- msg.Event = config.EVENT_FILE_FAILURE_SIZE
+ msg.Event = config.EventFileFailureSize
msg.Extra[msg.Event] = append(msg.Extra[msg.Event], config.FileInfo{Name: name, Comment: msg.Text, Size: size})
return fmt.Errorf("File %#v to large to download (%#v). MediaDownloadSize is %#v", name, size, general.MediaDownloadSize)
}
@@ -1237 +1237 @@ func HandleDownloadSize(flog *log.Entry, msg *config.Message, name string, size
func HandleDownloadData(flog *log.Entry, msg *config.Message, name, comment, url string, data *[]byte, general *config.Protocol) {
var avatar bool
flog.Debugf("Download OK %#v %#v", name, len(*data))
- if msg.Event == config.EVENT_AVATAR_DOWNLOAD {
+ if msg.Event == config.EventAvatarDownload {
avatar = true
}
msg.Extra["file"] = append(msg.Extra["file"], config.FileInfo{Name: name, Data: data, URL: url, Comment: comment, Avatar: avatar})
diff --git a/bridge/irc/irc.go b/bridge/irc/irc.go
index e14fa9e..36c1cfd 100644
--- a/bridge/irc/irc.go
+++ b/bridge/irc/irc.go
@@ -1287 +1287 @@ func (b *Birc) Connect() error {
time.Sleep(30 * time.Second)
i.Handlers.Clear(girc.RPL_WELCOME)
i.Handlers.Add(girc.RPL_WELCOME, func(client *girc.Client, event girc.Event) {
- b.Remote <- config.Message{Username: "system", Text: "rejoin", Channel: "", Account: b.Account, Event: config.EVENT_REJOIN_CHANNELS}
+ b.Remote <- config.Message{Username: "system", Text: "rejoin", Channel: "", Account: b.Account, Event: config.EventRejoinChannels}
// set our correct nick on reconnect if necessary
b.Nick = event.Source.Name
})
@@ -1677 +1677 @@ func (b *Birc) JoinChannel(channel config.ChannelInfo) error {
func (b *Birc) Send(msg config.Message) (string, error) {
// ignore delete messages
- if msg.Event == config.EVENT_MSG_DELETE {
+ if msg.Event == config.EventMsgDelete {
return "", nil
}
@@ -2577 +2577 @@ func (b *Birc) doSend() {
colorCode := checksum%14 + 2 // quick fix - prevent white or black color codes
username = fmt.Sprintf("\x03%02d%s\x0F", colorCode, msg.Username)
}
- if msg.Event == config.EVENT_USER_ACTION {
+ if msg.Event == config.EventUserAction {
b.i.Cmd.Action(msg.Channel, username+msg.Text)
} else {
b.Log.Debugf("Sending to channel %s", msg.Channel)
@@ -30913 +30913 @@ func (b *Birc) handleJoinPart(client *girc.Client, event girc.Event) {
if event.Command == "KICK" && event.Params[1] == b.Nick {
b.Log.Infof("Got kicked from %s by %s", channel, event.Source.Name)
time.Sleep(time.Duration(b.GetInt("RejoinDelay")) * time.Second)
- b.Remote <- config.Message{Username: "system", Text: "rejoin", Channel: channel, Account: b.Account, Event: config.EVENT_REJOIN_CHANNELS}
+ b.Remote <- config.Message{Username: "system", Text: "rejoin", Channel: channel, Account: b.Account, Event: config.EventRejoinChannels}
return
}
if event.Command == "QUIT" {
if event.Source.Name == b.Nick && strings.Contains(event.Trailing, "Ping timeout") {
b.Log.Infof("%s reconnecting ..", b.Account)
- b.Remote <- config.Message{Username: "system", Text: "reconnect", Channel: channel, Account: b.Account, Event: config.EVENT_FAILURE}
+ b.Remote <- config.Message{Username: "system", Text: "reconnect", Channel: channel, Account: b.Account, Event: config.EventFailure}
return
}
}
@@ -3247 +3247 @@ func (b *Birc) handleJoinPart(client *girc.Client, event girc.Event) {
return
}
b.Log.Debugf("<= Sending JOIN_LEAVE event from %s to gateway", b.Account)
- msg := config.Message{Username: "system", Text: event.Source.Name + " " + strings.ToLower(event.Command) + "s", Channel: channel, Account: b.Account, Event: config.EVENT_JOIN_LEAVE}
+ msg := config.Message{Username: "system", Text: event.Source.Name + " " + strings.ToLower(event.Command) + "s", Channel: channel, Account: b.Account, Event: config.EventJoinLeave}
b.Log.Debugf("<= Message is %#v", msg)
b.Remote <- msg
return
@@ -3917 +3917 @@ func (b *Birc) handlePrivMsg(client *girc.Client, event girc.Event) {
// set action event
if event.IsAction() {
- rmsg.Event = config.EVENT_USER_ACTION
+ rmsg.Event = config.EventUserAction
}
// strip action, we made an event if it was an action
diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go
index aaf1932..46dfef3 100644
--- a/bridge/matrix/matrix.go
+++ b/bridge/matrix/matrix.go
@@ -727 +727 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) {
b.Log.Debugf("Channel %s maps to channel id %s", msg.Channel, channel)
// Make a action /me of the message
- if msg.Event == config.EVENT_USER_ACTION {
+ if msg.Event == config.EventUserAction {
m := matrix.TextMessage{
MsgType: "m.emote",
Body: msg.Username + msg.Text,
@@ -857 +857 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) {
}
// Delete message
- if msg.Event == config.EVENT_MSG_DELETE {
+ if msg.Event == config.EventMsgDelete {
if msg.ID == "" {
return "", nil
}
@@ -17316 +17316 @@ func (b *Bmatrix) handleEvent(ev *matrix.Event) {
// Delete event
if ev.Type == "m.room.redaction" {
- rmsg.Event = config.EVENT_MSG_DELETE
+ rmsg.Event = config.EventMsgDelete
rmsg.ID = ev.Redacts
- rmsg.Text = config.EVENT_MSG_DELETE
+ rmsg.Text = config.EventMsgDelete
b.Remote <- rmsg
return
}
// Do we have a /me action
if ev.Content["msgtype"].(string) == "m.emote" {
- rmsg.Event = config.EVENT_USER_ACTION
+ rmsg.Event = config.EventUserAction
}
// Do we have attachments
diff --git a/bridge/mattermost/mattermost.go b/bridge/mattermost/mattermost.go
index 26a6cb4..8ba2c4f 100644
--- a/bridge/mattermost/mattermost.go
+++ b/bridge/mattermost/mattermost.go
@@ -13612 +13612 @@ func (b *Bmattermost) Send(msg config.Message) (string, error) {
b.Log.Debugf("=> Receiving %#v", msg)
// Make a action /me of the message
- if msg.Event == config.EVENT_USER_ACTION {
+ if msg.Event == config.EventUserAction {
msg.Text = "*" + msg.Text + "*"
}
// map the file SHA to our user (caches the avatar)
- if msg.Event == config.EVENT_AVATAR_DOWNLOAD {
+ if msg.Event == config.EventAvatarDownload {
return b.cacheAvatar(&msg)
}
@@ -1517 +1517 @@ func (b *Bmattermost) Send(msg config.Message) (string, error) {
}
// Delete message
- if msg.Event == config.EVENT_MSG_DELETE {
+ if msg.Event == config.EventMsgDelete {
if msg.ID == "" {
return "", nil
}
@@ -2017 +2017 @@ func (b *Bmattermost) handleMatter() {
message.Account = b.Account
message.Text, ok = b.replaceAction(message.Text)
if ok {
- message.Event = config.EVENT_USER_ACTION
+ message.Event = config.EventUserAction
}
b.Log.Debugf("<= Sending message from %s on %s to gateway", message.Username, b.Account)
b.Log.Debugf("<= Message is %#v", message)
@@ -2567 +2567 @@ func (b *Bmattermost) handleMatterClient(messages chan *config.Message) {
}
if message.Raw.Event == model.WEBSOCKET_EVENT_POST_DELETED {
- rmsg.Event = config.EVENT_MSG_DELETE
+ rmsg.Event = config.EventMsgDelete
}
if len(message.Post.FileIds) > 0 {
@@ -3317 +3317 @@ func (b *Bmattermost) cacheAvatar(msg *config.Message) (string, error) {
// sends a EVENT_AVATAR_DOWNLOAD message to the gateway if successful.
// logs an error message if it fails
func (b *Bmattermost) handleDownloadAvatar(userid string, channel string) {
- rmsg := config.Message{Username: "system", Text: "avatar", Channel: channel, Account: b.Account, UserID: userid, Event: config.EVENT_AVATAR_DOWNLOAD, Extra: make(map[string][]interface{})}
+ rmsg := config.Message{Username: "system", Text: "avatar", Channel: channel, Account: b.Account, UserID: userid, Event: config.EventAvatarDownload, Extra: make(map[string][]interface{})}
if _, ok := b.avatarMap[userid]; !ok {
data, resp := b.mc.Client.GetProfileImage(userid, "")
if resp.Error != nil {
@@ -4427 +4427 @@ func (b *Bmattermost) skipMessage(message *matterclient.Message) bool {
return true
}
b.Log.Debugf("Sending JOIN_LEAVE event from %s to gateway", b.Account)
- b.Remote <- config.Message{Username: "system", Text: message.Text, Channel: message.Channel, Account: b.Account, Event: config.EVENT_JOIN_LEAVE}
+ b.Remote <- config.Message{Username: "system", Text: message.Text, Channel: message.Channel, Account: b.Account, Event: config.EventJoinLeave}
return true
}
diff --git a/bridge/rocketchat/rocketchat.go b/bridge/rocketchat/rocketchat.go
index 9062c1b..1dbc7be 100644
--- a/bridge/rocketchat/rocketchat.go
+++ b/bridge/rocketchat/rocketchat.go
@@ -437 +437 @@ func (b *Brocketchat) JoinChannel(channel config.ChannelInfo) error {
func (b *Brocketchat) Send(msg config.Message) (string, error) {
// ignore delete messages
- if msg.Event == config.EVENT_MSG_DELETE {
+ if msg.Event == config.EventMsgDelete {
return "", nil
}
b.Log.Debugf("=> Receiving %#v", msg)
diff --git a/bridge/slack/handlers.go b/bridge/slack/handlers.go
index ef7364f..d4e5e46 100644
--- a/bridge/slack/handlers.go
+++ b/bridge/slack/handlers.go
@@ -227 +227 @@ func (b *Bslack) handleSlack() {
time.Sleep(time.Second)
b.Log.Debug("Start listening for Slack messages")
for message := range messages {
- if message.Event != config.EVENT_USER_TYPING {
+ if message.Event != config.EventUserTyping {
b.Log.Debugf("<= Sending message from %s on %s to gateway", message.Username, b.Account)
}
@@ -19918 +19918 @@ func (b *Bslack) handleStatusEvent(ev *slack.MessageEvent, rmsg *config.Message)
return true
case sChannelJoin, sChannelLeave:
rmsg.Username = sSystemUser
- rmsg.Event = config.EVENT_JOIN_LEAVE
+ rmsg.Event = config.EventJoinLeave
case sChannelTopic, sChannelPurpose:
- rmsg.Event = config.EVENT_TOPIC_CHANGE
+ rmsg.Event = config.EventTopicChange
case sMessageDeleted:
- rmsg.Text = config.EVENT_MSG_DELETE
- rmsg.Event = config.EVENT_MSG_DELETE
+ rmsg.Text = config.EventMsgDelete
+ rmsg.Event = config.EventMsgDelete
rmsg.ID = "slack " + ev.DeletedTimestamp
// If a message is being deleted we do not need to process
// the event any further so we return 'true'.
return true
case sMeMessage:
- rmsg.Event = config.EVENT_USER_ACTION
+ rmsg.Event = config.EventUserAction
}
return false
}
@@ -2567 +2567 @@ func (b *Bslack) handleTypingEvent(ev *slack.UserTypingEvent) (*config.Message,
return &config.Message{
Channel: channelInfo.Name,
Account: b.Account,
- Event: config.EVENT_USER_TYPING,
+ Event: config.EventUserTyping,
}, nil
}
diff --git a/bridge/slack/legacy.go b/bridge/slack/legacy.go
index a7e7f01..be372ed 100644
--- a/bridge/slack/legacy.go
+++ b/bridge/slack/legacy.go
@@ -815 +815 @@ import (
"github.com/nlopes/slack"
)
-type BslackLegacy struct {
+type BLegacy struct {
*Bslack
}
func NewLegacy(cfg *bridge.Config) bridge.Bridger {
- return &BslackLegacy{Bslack: newBridge(cfg)}
+ return &BLegacy{Bslack: newBridge(cfg)}
}
-func (b *BslackLegacy) Connect() error {
+func (b *BLegacy) Connect() error {
b.RLock()
defer b.RUnlock()
if b.GetString(incomingWebhookConfig) != "" {
diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go
index 1f51de9..0a5d824 100644
--- a/bridge/slack/slack.go
+++ b/bridge/slack/slack.go
@@ -18512 +18512 @@ func (b *Bslack) Reload(cfg *bridge.Config) (string, error) {
func (b *Bslack) Send(msg config.Message) (string, error) {
// Too noisy to log like other events
- if msg.Event != config.EVENT_USER_TYPING {
+ if msg.Event != config.EventUserTyping {
b.Log.Debugf("=> Receiving %#v", msg)
}
// Make a action /me of the message
- if msg.Event == config.EVENT_USER_ACTION {
+ if msg.Event == config.EventUserAction {
msg.Text = "_" + msg.Text + "_"
}
@@ -2707 +2707 @@ func (b *Bslack) sendRTM(msg config.Message) (string, error) {
if err != nil {
return "", fmt.Errorf("could not send message: %v", err)
}
- if msg.Event == config.EVENT_USER_TYPING {
+ if msg.Event == config.EventUserTyping {
if b.GetBool("ShowUserTyping") {
b.rtm.SendMessage(b.rtm.NewTypingMessage(channelInfo.ID))
}
@@ -3127 +3127 @@ func (b *Bslack) sendRTM(msg config.Message) (string, error) {
}
func (b *Bslack) deleteMessage(msg *config.Message, channelInfo *slack.Channel) (bool, error) {
- if msg.Event != config.EVENT_MSG_DELETE {
+ if msg.Event != config.EventMsgDelete {
return false, nil
}
diff --git a/bridge/sshchat/sshchat.go b/bridge/sshchat/sshchat.go
index 846a908..827c81d 100644
--- a/bridge/sshchat/sshchat.go
+++ b/bridge/sshchat/sshchat.go
@@ -317 +317 @@ func (b *Bsshchat) Connect() error {
b.w = w
b.r.Scan()
w.Write([]byte("/theme mono\r\n"))
- b.handleSshChat()
+ b.handleSSHChat()
return nil
})
}()
@@ -537 +537 @@ func (b *Bsshchat) JoinChannel(channel config.ChannelInfo) error {
func (b *Bsshchat) Send(msg config.Message) (string, error) {
// ignore delete messages
- if msg.Event == config.EVENT_MSG_DELETE {
+ if msg.Event == config.EventMsgDelete {
return "", nil
}
b.Log.Debugf("=> Receiving %#v", msg)
@@ -1137 +1137 @@ func stripPrompt(s string) string {
return s[pos+3:]
}
-func (b *Bsshchat) handleSshChat() error {
+func (b *Bsshchat) handleSSHChat() error {
/*
done := b.sshchatKeepAlive()
defer close(done)
diff --git a/bridge/steam/steam.go b/bridge/steam/steam.go
index b04c10b..1a4dab2 100644
--- a/bridge/steam/steam.go
+++ b/bridge/steam/steam.go
@@ -607 +607 @@ func (b *Bsteam) JoinChannel(channel config.ChannelInfo) error {
func (b *Bsteam) Send(msg config.Message) (string, error) {
// ignore delete messages
- if msg.Event == config.EVENT_MSG_DELETE {
+ if msg.Event == config.EventMsgDelete {
return "", nil
}
id, err := steamid.NewId(msg.Channel)
diff --git a/bridge/telegram/telegram.go b/bridge/telegram/telegram.go
index 748ee87..7097644 100644
--- a/bridge/telegram/telegram.go
+++ b/bridge/telegram/telegram.go
@@ -667 +667 @@ func (b *Btelegram) Send(msg config.Message) (string, error) {
}
// map the file SHA to our user (caches the avatar)
- if msg.Event == config.EVENT_AVATAR_DOWNLOAD {
+ if msg.Event == config.EventAvatarDownload {
return b.cacheAvatar(&msg)
}
@@ -757 +757 @@ func (b *Btelegram) Send(msg config.Message) (string, error) {
}
// Delete message
- if msg.Event == config.EVENT_MSG_DELETE {
+ if msg.Event == config.EventMsgDelete {
if msg.ID == "" {
return "", nil
}
@@ -2687 +2687 @@ func (b *Btelegram) getFileDirectURL(id string) string {
// sends a EVENT_AVATAR_DOWNLOAD message to the gateway if successful.
// logs an error message if it fails
func (b *Btelegram) handleDownloadAvatar(userid int, channel string) {
- rmsg := config.Message{Username: "system", Text: "avatar", Channel: channel, Account: b.Account, UserID: strconv.Itoa(userid), Event: config.EVENT_AVATAR_DOWNLOAD, Extra: make(map[string][]interface{})}
+ rmsg := config.Message{Username: "system", Text: "avatar", Channel: channel, Account: b.Account, UserID: strconv.Itoa(userid), Event: config.EventAvatarDownload, Extra: make(map[string][]interface{})}
if _, ok := b.avatarMap[strconv.Itoa(userid)]; !ok {
photos, err := b.c.GetUserProfilePhotos(tgbotapi.UserProfilePhotosConfig{UserID: userid, Limit: 1})
if err != nil {
diff --git a/bridge/xmpp/xmpp.go b/bridge/xmpp/xmpp.go
index 4d6cc3c..75fc83a 100644
--- a/bridge/xmpp/xmpp.go
+++ b/bridge/xmpp/xmpp.go
@@ -517 +517 @@ func (b *Bxmpp) Connect() error {
time.Sleep(d)
b.xc, err = b.createXMPP()
if err == nil {
- b.Remote <- config.Message{Username: "system", Text: "rejoin", Channel: "", Account: b.Account, Event: config.EVENT_REJOIN_CHANNELS}
+ b.Remote <- config.Message{Username: "system", Text: "rejoin", Channel: "", Account: b.Account, Event: config.EventRejoinChannels}
b.handleXMPP()
bf.Reset()
}
@@ -767 +767 @@ func (b *Bxmpp) JoinChannel(channel config.ChannelInfo) error {
func (b *Bxmpp) Send(msg config.Message) (string, error) {
// ignore delete messages
- if msg.Event == config.EVENT_MSG_DELETE {
+ if msg.Event == config.EventMsgDelete {
return "", nil
}
b.Log.Debugf("=> Receiving %#v", msg)
@@ -1777 +1777 @@ func (b *Bxmpp) handleXMPP() error {
// check if we have an action event
rmsg.Text, ok = b.replaceAction(rmsg.Text)
if ok {
- rmsg.Event = config.EVENT_USER_ACTION
+ rmsg.Event = config.EventUserAction
}
b.Log.Debugf("<= Sending message from %s on %s to gateway", rmsg.Username, b.Account)
b.Log.Debugf("<= Message is %#v", rmsg)
diff --git a/bridge/zulip/zulip.go b/bridge/zulip/zulip.go
index ebeabc1..88832d3 100644
--- a/bridge/zulip/zulip.go
+++ b/bridge/zulip/zulip.go
@@ -527 +527 @@ func (b *Bzulip) Send(msg config.Message) (string, error) {
b.Log.Debugf("=> Receiving %#v", msg)
// Delete message
- if msg.Event == config.EVENT_MSG_DELETE {
+ if msg.Event == config.EventMsgDelete {
if msg.ID == "" {
return "", nil
}
diff --git a/gateway/gateway.go b/gateway/gateway.go
index bbaef04..d723d85 100644
--- a/gateway/gateway.go
+++ b/gateway/gateway.go
@@ -1087 +1087 @@ func (gw *Gateway) AddBridge(cfg *config.Bridge) error {
if br == nil {
br = bridge.New(cfg)
br.Config = gw.Router.Config
- br.General = &gw.ConfigValues().General
+ br.General = &gw.BridgeValues().General
// set logging
br.Log = log.WithFields(log.Fields{"prefix": "bridge"})
brconfig := &bridge.Config{Remote: gw.Message, Log: log.WithFields(log.Fields{"prefix": br.Protocol}), Bridge: br}
@@ -1597 +1597 @@ RECONNECT:
func (gw *Gateway) mapChannelConfig(cfg []config.Bridge, direction string) {
for _, br := range cfg {
- if isApi(br.Account) {
+ if isAPI(br.Account) {
br.Channel = apiProtocol
}
// make sure to lowercase irc channels in config #348
@@ -2467 +2467 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) []*BrM
// if we have an attached file, or other info
if msg.Extra != nil {
- if len(msg.Extra[config.EVENT_FILE_FAILURE_SIZE]) != 0 {
+ if len(msg.Extra[config.EventFileFailureSize]) != 0 {
if msg.Text == "" {
return brMsgIDs
}
@@ -2547 +2547 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) []*BrM
}
// Avatar downloads are only relevant for telegram and mattermost for now
- if msg.Event == config.EVENT_AVATAR_DOWNLOAD {
+ if msg.Event == config.EventAvatarDownload {
if dest.Protocol != "mattermost" &&
dest.Protocol != "telegram" {
return brMsgIDs
@@ -26224 +26224 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) []*BrM
}
// only relay join/part when configured
- if msg.Event == config.EVENT_JOIN_LEAVE && !gw.Bridges[dest.Account].GetBool("ShowJoinPart") {
+ if msg.Event == config.EventJoinLeave && !gw.Bridges[dest.Account].GetBool("ShowJoinPart") {
return brMsgIDs
}
// only relay topic change when configured
- if msg.Event == config.EVENT_TOPIC_CHANGE && !gw.Bridges[dest.Account].GetBool("ShowTopicChange") {
+ if msg.Event == config.EventTopicChange && !gw.Bridges[dest.Account].GetBool("ShowTopicChange") {
return brMsgIDs
}
// broadcast to every out channel (irc QUIT)
- if msg.Channel == "" && msg.Event != config.EVENT_JOIN_LEAVE {
+ if msg.Channel == "" && msg.Event != config.EventJoinLeave {
flog.Debug("empty channel")
return brMsgIDs
}
// Get the ID of the parent message in thread
var canonicalParentMsgID string
- if msg.ParentID != "" && (gw.ConfigValues().General.PreserveThreading || dest.GetBool("PreserveThreading")) {
+ if msg.ParentID != "" && (gw.BridgeValues().General.PreserveThreading || dest.GetBool("PreserveThreading")) {
thisParentMsgID := dest.Protocol + " " + msg.ParentID
canonicalParentMsgID = gw.FindCanonicalMsgID(thisParentMsgID)
}
@@ -2897 +2897 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) []*BrM
channels := gw.getDestChannel(&msg, *dest)
for _, channel := range channels {
// Only send the avatar download event to ourselves.
- if msg.Event == config.EVENT_AVATAR_DOWNLOAD {
+ if msg.Event == config.EventAvatarDownload {
if channel.ID != getChannelID(origmsg) {
continue
}
@@ -3017 +3017 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) []*BrM
}
// Too noisy to log like other events
- if msg.Event != config.EVENT_USER_TYPING {
+ if msg.Event != config.EventUserTyping {
flog.Debugf("=> Sending %#v from %s (%s) to %s (%s)", msg, msg.Account, originchannel, dest.Account, channel.Name)
}
@@ -34914 +34914 @@ func (gw *Gateway) ignoreMessage(msg *config.Message) bool {
// check if we need to ignore a empty message
if msg.Text == "" {
- if msg.Event == config.EVENT_USER_TYPING {
+ if msg.Event == config.EventUserTyping {
return false
}
// we have an attachment or actual bytes, do not ignore
if msg.Extra != nil &&
(msg.Extra["attachments"] != nil ||
len(msg.Extra["file"]) > 0 ||
- len(msg.Extra[config.EVENT_FILE_FAILURE_SIZE]) > 0) {
+ len(msg.Extra[config.EventFileFailureSize]) > 0) {
return false
}
flog.Debugf("ignoring empty message %#v from %s", msg, msg.Account)
@@ -39213 +39213 @@ func (gw *Gateway) ignoreMessage(msg *config.Message) bool {
func (gw *Gateway) modifyUsername(msg config.Message, dest *bridge.Bridge) string {
br := gw.Bridges[msg.Account]
msg.Protocol = br.Protocol
- if gw.ConfigValues().General.StripNick || dest.GetBool("StripNick") {
+ if gw.BridgeValues().General.StripNick || dest.GetBool("StripNick") {
re := regexp.MustCompile("[^a-zA-Z0-9]+")
msg.Username = re.ReplaceAllString(msg.Username, "")
}
nick := dest.GetString("RemoteNickFormat")
if nick == "" {
- nick = gw.ConfigValues().General.RemoteNickFormat
+ nick = gw.BridgeValues().General.RemoteNickFormat
}
// loop to replace nicks
@@ -4377 +4377 @@ func (gw *Gateway) modifyUsername(msg config.Message, dest *bridge.Bridge) strin
}
func (gw *Gateway) modifyAvatar(msg config.Message, dest *bridge.Bridge) string {
- iconurl := gw.ConfigValues().General.IconURL
+ iconurl := gw.BridgeValues().General.IconURL
if iconurl == "" {
iconurl = dest.GetString("IconURL")
}
@@ -4798 +4798 @@ func (gw *Gateway) handleFiles(msg *config.Message) {
// If we don't have a attachfield or we don't have a mediaserver configured return
if msg.Extra == nil ||
- (gw.ConfigValues().General.MediaServerUpload == "" &&
- gw.ConfigValues().General.MediaDownloadPath == "") {
+ (gw.BridgeValues().General.MediaServerUpload == "" &&
+ gw.BridgeValues().General.MediaDownloadPath == "") {
return
}
@@ -50210 +50210 @@ func (gw *Gateway) handleFiles(msg *config.Message) {
sha1sum := fmt.Sprintf("%x", sha1.Sum(*fi.Data))[:8]
- if gw.ConfigValues().General.MediaServerUpload != "" {
+ if gw.BridgeValues().General.MediaServerUpload != "" {
// Use MediaServerUpload. Upload using a PUT HTTP request and basicauth.
- url := gw.ConfigValues().General.MediaServerUpload + "/" + sha1sum + "/" + fi.Name
+ url := gw.BridgeValues().General.MediaServerUpload + "/" + sha1sum + "/" + fi.Name
req, err := http.NewRequest("PUT", url, bytes.NewReader(*fi.Data))
if err != nil {
@@ -5247 +5247 @@ func (gw *Gateway) handleFiles(msg *config.Message) {
} else {
// Use MediaServerPath. Place the file on the current filesystem.
- dir := gw.ConfigValues().General.MediaDownloadPath + "/" + sha1sum
+ dir := gw.BridgeValues().General.MediaDownloadPath + "/" + sha1sum
err := os.Mkdir(dir, os.ModePerm)
if err != nil && !os.IsExist(err) {
flog.Errorf("mediaserver path failed, could not mkdir: %s %#v", err, err)
@@ -5427 +5427 @@ func (gw *Gateway) handleFiles(msg *config.Message) {
}
// Download URL.
- durl := gw.ConfigValues().General.MediaServerDownload + "/" + sha1sum + "/" + fi.Name
+ durl := gw.BridgeValues().General.MediaServerDownload + "/" + sha1sum + "/" + fi.Name
flog.Debugf("mediaserver download URL = %s", durl)
@@ -5626 +5626 @@ func getChannelID(msg config.Message) string {
return msg.Channel + msg.Account
}
-func isApi(account string) bool {
+func isAPI(account string) bool {
return strings.HasPrefix(account, "api.")
}
diff --git a/gateway/router.go b/gateway/router.go
index a6c6daf..e62df20 100644
--- a/gateway/router.go
+++ b/gateway/router.go
@@ -277 +277 @@ func NewRouter(cfg config.Config) (*Router, error) {
sgw := samechannelgateway.New(cfg)
gwconfigs := sgw.GetConfig()
- for _, entry := range append(gwconfigs, cfg.ConfigValues().Gateway...) {
+ for _, entry := range append(gwconfigs, cfg.BridgeValues().Gateway...) {
if !entry.Enable {
continue
}
@@ -777 +777 @@ func (r *Router) getBridge(account string) *bridge.Bridge {
func (r *Router) handleReceive() {
for msg := range r.Message {
msg := msg // scopelint
- if msg.Event == config.EVENT_FAILURE {
+ if msg.Event == config.EventFailure {
Loop:
for _, gw := range r.Gateways {
for _, br := range gw.Bridges {
@@ -887 +887 @@ func (r *Router) handleReceive() {
}
}
}
- if msg.Event == config.EVENT_REJOIN_CHANNELS {
+ if msg.Event == config.EventRejoinChannels {
for _, gw := range r.Gateways {
for _, br := range gw.Bridges {
if msg.Account == br.Account {
diff --git a/gateway/samechannel/samechannel.go b/gateway/samechannel/samechannel.go
index ea846e9..1d85ea7 100644
--- a/gateway/samechannel/samechannel.go
+++ b/gateway/samechannel/samechannel.go
@@ -157 +157 @@ func New(cfg config.Config) *SameChannelGateway {
func (sgw *SameChannelGateway) GetConfig() []config.Gateway {
var gwconfigs []config.Gateway
cfg := sgw.Config
- for _, gw := range cfg.ConfigValues().SameChannelGateway {
+ for _, gw := range cfg.BridgeValues().SameChannelGateway {
gwconfig := config.Gateway{Name: gw.Name, Enable: gw.Enable}
for _, account := range gw.Accounts {
for _, channel := range gw.Channels {
diff --git a/matterbridge.go b/matterbridge.go
index 90c0437..bfb573f 100644
--- a/matterbridge.go
+++ b/matterbridge.go
@@ -447 +447 @@ func main() {
flog.Println("WARNING: THIS IS A DEVELOPMENT VERSION. Things may break.")
}
cfg := config.NewConfig(*flagConfig)
- cfg.ConfigValues().General.Debug = *flagDebug
+ cfg.BridgeValues().General.Debug = *flagDebug
r, err := gateway.NewRouter(cfg)
if err != nil {
flog.Fatalf("Starting gateway failed: %s", err)
diff --git a/matterclient/matterclient.go b/matterclient/matterclient.go
index edd298d..2967feb 100644
--- a/matterclient/matterclient.go
+++ b/matterclient/matterclient.go
@@ -436 +437 @@ type Message struct {
UserID string
}
+//nolint:golint
type Team struct {
Team *model.Team
Id string
@@ -4237 +4247 @@ func (m *MMClient) UpdateChannels() error {
return nil
}
-func (m *MMClient) GetChannelName(channelId string) string {
+func (m *MMClient) GetChannelName(channelId string) string { //nolint:golint
m.RLock()
defer m.RUnlock()
for _, t := range m.OtherTeams {
@@ -4587 +4597 @@ func (m *MMClient) GetChannelName(channelId string) string {
return ""
}
-func (m *MMClient) GetChannelId(name string, teamId string) string {
+func (m *MMClient) GetChannelId(name string, teamId string) string { //nolint:golint
m.RLock()
defer m.RUnlock()
if teamId == "" {
@@ -4887 +4897 @@ func (m *MMClient) GetChannelId(name string, teamId string) string {
return ""
}
-func (m *MMClient) GetChannelTeamId(id string) string {
+func (m *MMClient) GetChannelTeamId(id string) string { //nolint:golint
m.RLock()
defer m.RUnlock()
for _, t := range append(m.OtherTeams, m.Team) {
@@ -5017 +5027 @@ func (m *MMClient) GetChannelTeamId(id string) string {
return ""
}
-func (m *MMClient) GetChannelHeader(channelId string) string {
+func (m *MMClient) GetChannelHeader(channelId string) string { //nolint:golint
m.RLock()
defer m.RUnlock()
for _, t := range m.OtherTeams {
@@ -5157 +5167 @@ func (m *MMClient) GetChannelHeader(channelId string) string {
return ""
}
-func (m *MMClient) PostMessage(channelId string, text string) (string, error) {
+func (m *MMClient) PostMessage(channelId string, text string) (string, error) { //nolint:golint
post := &model.Post{ChannelId: channelId, Message: text}
res, resp := m.Client.CreatePost(post)
if resp.Error != nil {
@@ -5247 +5257 @@ func (m *MMClient) PostMessage(channelId string, text string) (string, error) {
return res.Id, nil
}
-func (m *MMClient) PostMessageWithFiles(channelId string, text string, fileIds []string) (string, error) {
+func (m *MMClient) PostMessageWithFiles(channelId string, text string, fileIds []string) (string, error) { //nolint:golint
post := &model.Post{ChannelId: channelId, Message: text, FileIds: fileIds}
res, resp := m.Client.CreatePost(post)
if resp.Error != nil {
@@ -5337 +5347 @@ func (m *MMClient) PostMessageWithFiles(channelId string, text string, fileIds [
return res.Id, nil
}
-func (m *MMClient) EditMessage(postId string, text string) (string, error) {
+func (m *MMClient) EditMessage(postId string, text string) (string, error) { //nolint:golint
post := &model.Post{Message: text}
res, resp := m.Client.UpdatePost(postId, post)
if resp.Error != nil {
@@ -5427 +5437 @@ func (m *MMClient) EditMessage(postId string, text string) (string, error) {
return res.Id, nil
}
-func (m *MMClient) DeleteMessage(postId string) error {
+func (m *MMClient) DeleteMessage(postId string) error { //nolint:golint
_, resp := m.Client.DeletePost(postId)
if resp.Error != nil {
return resp.Error
@@ -5507 +5517 @@ func (m *MMClient) DeleteMessage(postId string) error {
return nil
}
-func (m *MMClient) JoinChannel(channelId string) error {
+func (m *MMClient) JoinChannel(channelId string) error { //nolint:golint
m.RLock()
defer m.RUnlock()
for _, c := range m.Team.Channels {
@@ -5677 +5687 @@ func (m *MMClient) JoinChannel(channelId string) error {
return nil
}
-func (m *MMClient) GetPostsSince(channelId string, time int64) *model.PostList {
+func (m *MMClient) GetPostsSince(channelId string, time int64) *model.PostList { //nolint:golint
res, resp := m.Client.GetPostsSince(channelId, time)
if resp.Error != nil {
return nil
@@ -5837 +5847 @@ func (m *MMClient) SearchPosts(query string) *model.PostList {
return res
}
-func (m *MMClient) GetPosts(channelId string, limit int) *model.PostList {
+func (m *MMClient) GetPosts(channelId string, limit int) *model.PostList { //nolint:golint
res, resp := m.Client.GetPostsForChannel(channelId, 0, limit, "")
if resp.Error != nil {
return nil
@@ -6307 +6317 @@ func (m *MMClient) GetFileLinks(filenames []string) []string {
return output
}
-func (m *MMClient) UpdateChannelHeader(channelId string, header string) {
+func (m *MMClient) UpdateChannelHeader(channelId string, header string) { //nolint:golint
channel := &model.Channel{Id: channelId, Header: header}
m.log.Debugf("updating channelheader %#v, %#v", channelId, header)
_, resp := m.Client.UpdateChannel(channel)
@@ -6397 +6407 @@ func (m *MMClient) UpdateChannelHeader(channelId string, header string) {
}
}
-func (m *MMClient) UpdateLastViewed(channelId string) error {
+func (m *MMClient) UpdateLastViewed(channelId string) error { //nolint:golint
m.log.Debugf("posting lastview %#v", channelId)
view := &model.ChannelView{ChannelId: channelId}
_, resp := m.Client.ViewChannel(m.User.Id, view)
@@ -6607 +6617 @@ func (m *MMClient) UpdateUserNick(nick string) error {
return nil
}
-func (m *MMClient) UsernamesInChannel(channelId string) []string {
+func (m *MMClient) UsernamesInChannel(channelId string) []string { //nolint:golint
res, resp := m.Client.GetChannelMembers(channelId, 0, 50000, "")
if resp.Error != nil {
m.log.Errorf("UsernamesInChannel(%s) failed: %s", channelId, resp.Error)
@@ -69011 +69111 @@ func (m *MMClient) createCookieJar(token string) *cookiejar.Jar {
}
// SendDirectMessage sends a direct message to specified user
-func (m *MMClient) SendDirectMessage(toUserId string, msg string) {
+func (m *MMClient) SendDirectMessage(toUserId string, msg string) { //nolint:golint
m.SendDirectMessageProps(toUserId, msg, nil)
}
-func (m *MMClient) SendDirectMessageProps(toUserId string, msg string, props map[string]interface{}) {
+func (m *MMClient) SendDirectMessageProps(toUserId string, msg string, props map[string]interface{}) { //nolint:golint
m.log.Debugf("SendDirectMessage to %s, msg %s", toUserId, msg)
// create DM channel (only happens on first message)
_, resp := m.Client.CreateDirectChannel(m.User.Id, toUserId)
@@ -7147 +7157 @@ func (m *MMClient) SendDirectMessageProps(toUserId string, msg string, props map
}
// GetTeamName returns the name of the specified teamId
-func (m *MMClient) GetTeamName(teamId string) string {
+func (m *MMClient) GetTeamName(teamId string) string { //nolint:golint
m.RLock()
defer m.RUnlock()
for _, t := range m.OtherTeams {
@@ -7527 +7537 @@ func (m *MMClient) GetMoreChannels() []*model.Channel {
}
// GetTeamFromChannel returns teamId belonging to channel (DM channels have no teamId).
-func (m *MMClient) GetTeamFromChannel(channelId string) string {
+func (m *MMClient) GetTeamFromChannel(channelId string) string { //nolint:golint
m.RLock()
defer m.RUnlock()
var channels []*model.Channel
@@ -7747 +7757 @@ func (m *MMClient) GetTeamFromChannel(channelId string) string {
return ""
}
-func (m *MMClient) GetLastViewedAt(channelId string) int64 {
+func (m *MMClient) GetLastViewedAt(channelId string) int64 { //nolint:golint
m.RLock()
defer m.RUnlock()
res, resp := m.Client.GetChannelMember(channelId, m.User.Id, "")
@@ -7947 +7957 @@ func (m *MMClient) GetUsers() map[string]*model.User {
return users
}
-func (m *MMClient) GetUser(userId string) *model.User {
+func (m *MMClient) GetUser(userId string) *model.User { //nolint:golint
m.Lock()
defer m.Unlock()
_, ok := m.Users[userId]
@@ -8087 +8097 @@ func (m *MMClient) GetUser(userId string) *model.User {
return m.Users[userId]
}
-func (m *MMClient) UpdateUser(userId string) {
+func (m *MMClient) UpdateUser(userId string) { //nolint:golint
m.Lock()
defer m.Unlock()
res, resp := m.Client.GetUser(userId, "")
@@ -8187 +8197 @@ func (m *MMClient) UpdateUser(userId string) {
m.Users[userId] = res
}
-func (m *MMClient) GetUserName(userId string) string {
+func (m *MMClient) GetUserName(userId string) string { //nolint:golint
user := m.GetUser(userId)
if user != nil {
return user.Username
@@ -8267 +8277 @@ func (m *MMClient) GetUserName(userId string) string {
return ""
}
-func (m *MMClient) GetNickName(userId string) string {
+func (m *MMClient) GetNickName(userId string) string { //nolint:golint
user := m.GetUser(userId)
if user != nil {
return user.Nickname
@@ -8347 +8357 @@ func (m *MMClient) GetNickName(userId string) string {
return ""
}
-func (m *MMClient) GetStatus(userId string) string {
+func (m *MMClient) GetStatus(userId string) string { //nolint:golint
res, resp := m.Client.GetUserStatus(userId, "")
if resp.Error != nil {
return ""
@@ -8487 +8497 @@ func (m *MMClient) GetStatus(userId string) string {
return "offline"
}
-func (m *MMClient) UpdateStatus(userId string, status string) error {
+func (m *MMClient) UpdateStatus(userId string, status string) error { //nolint:golint
_, resp := m.Client.UpdateUserStatus(userId, &model.Status{Status: status})
if resp.Error != nil {
return resp.Error
@@ -87811 +87911 @@ func (m *MMClient) GetStatuses() map[string]string {
return statuses
}
-func (m *MMClient) GetTeamId() string {
+func (m *MMClient) GetTeamId() string { //nolint:golint
return m.Team.Id
}
-func (m *MMClient) UploadFile(data []byte, channelId string, filename string) (string, error) {
+func (m *MMClient) UploadFile(data []byte, channelId string, filename string) (string, error) { //nolint:golint
f, resp := m.Client.UploadFile(data, channelId, filename)
if resp.Error != nil {
return "", resp.Error
diff --git a/matterhook/matterhook.go b/matterhook/matterhook.go
index 9287baa..f602ed4 100644
--- a/matterhook/matterhook.go
+++ b/matterhook/matterhook.go
@@ -419 +419 @@ type IMessage struct {
Timestamp string `schema:"timestamp"`
UserID string `schema:"user_id"`
UserName string `schema:"user_name"`
- PostId string `schema:"post_id"`
+ PostId string `schema:"post_id"` //nolint:golint
RawText string `schema:"raw_text"`
- ServiceId string `schema:"service_id"`
+ ServiceId string `schema:"service_id"` //nolint:golint
Text string `schema:"text"`
TriggerWord string `schema:"trigger_word"`
FileIDs string `schema:"file_ids"`
@@ -517 +518 @@ type IMessage struct {
// Client for Mattermost.
type Client struct {
- Url string // URL for incoming webhooks on mattermost.
+ // URL for incoming webhooks on mattermost.
+ Url string // nolint:golint
In chan IMessage
Out chan OMessage
httpclient *http.Client