summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml2
-rw-r--r--bridge/api/api.go26
-rw-r--r--bridge/config/config.go38
-rw-r--r--bridge/discord/discord.go10
-rw-r--r--bridge/gitter/gitter.go4
-rw-r--r--bridge/helper/helper.go6
-rw-r--r--bridge/irc/irc.go14
-rw-r--r--bridge/matrix/matrix.go10
-rw-r--r--bridge/mattermost/mattermost.go14
-rw-r--r--bridge/rocketchat/rocketchat.go2
-rw-r--r--bridge/slack/handlers.go14
-rw-r--r--bridge/slack/legacy.go6
-rw-r--r--bridge/slack/slack.go8
-rw-r--r--bridge/sshchat/sshchat.go6
-rw-r--r--bridge/steam/steam.go2
-rw-r--r--bridge/telegram/telegram.go6
-rw-r--r--bridge/xmpp/xmpp.go6
-rw-r--r--bridge/zulip/zulip.go2
-rw-r--r--gateway/gateway.go44
-rw-r--r--gateway/router.go6
-rw-r--r--gateway/samechannel/samechannel.go2
-rw-r--r--matterbridge.go2
-rw-r--r--matterclient/matterclient.go55
-rw-r--r--matterhook/matterhook.go7
24 files changed, 147 insertions, 145 deletions
diff --git a/.travis.yml b/.travis.yml
index a2b69c87..b8d9b9f5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -40,7 +40,7 @@ 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 eef41a4a..f8a7c04c 100644
--- a/bridge/api/api.go
+++ b/bridge/api/api.go
@@ -13,13 +13,13 @@ 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"`
@@ -28,7 +28,7 @@ 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
@@ -55,34 +55,34 @@ 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
@@ -98,7 +98,7 @@ 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(), " ")
@@ -106,11 +106,11 @@ 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 74f7f531..064f04a4 100644
--- a/bridge/config/config.go
+++ b/bridge/config/config.go
@@ -14,16 +14,16 @@ 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 {
@@ -157,20 +157,20 @@ 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
@@ -178,7 +178,7 @@ 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)
@@ -190,7 +190,7 @@ type config struct {
v *viper.Viper
sync.RWMutex
- cv *ConfigValues
+ cv *BridgeValues
}
func NewConfig(cfgfile string) Config {
@@ -236,7 +236,7 @@ func newConfigFromString(input []byte) *config {
log.Fatal(err)
}
- cfg := &ConfigValues{}
+ cfg := &BridgeValues{}
err = viper.Unmarshal(cfg)
if err != nil {
log.Fatal(err)
@@ -247,7 +247,7 @@ 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 b41c2e50..d3fc8eb4 100644
--- a/bridge/discord/discord.go
+++ b/bridge/discord/discord.go
@@ -129,7 +129,7 @@ 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 + "_"
}
@@ -147,7 +147,7 @@ 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")
@@ -179,7 +179,7 @@ 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
}
@@ -217,7 +217,7 @@ 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
@@ -300,7 +300,7 @@ 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 f47ca7ea..486fe433 100644
--- a/bridge/gitter/gitter.go
+++ b/bridge/gitter/gitter.go
@@ -77,7 +77,7 @@ 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)
@@ -100,7 +100,7 @@ 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 bd5e140e..c1a48ce8 100644
--- a/bridge/helper/helper.go
+++ b/bridge/helper/helper.go
@@ -82,7 +82,7 @@ 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})
@@ -113,7 +113,7 @@ 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)
}
@@ -123,7 +123,7 @@ 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 e14fa9e0..36c1cfd8 100644
--- a/bridge/irc/irc.go
+++ b/bridge/irc/irc.go
@@ -128,7 +128,7 @@ 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
})
@@ -167,7 +167,7 @@ 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
}
@@ -257,7 +257,7 @@ 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)
@@ -309,13 +309,13 @@ 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
}
}
@@ -324,7 +324,7 @@ 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
@@ -391,7 +391,7 @@ 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 aaf19326..46dfef39 100644
--- a/bridge/matrix/matrix.go
+++ b/bridge/matrix/matrix.go
@@ -72,7 +72,7 @@ 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,
@@ -85,7 +85,7 @@ 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
}
@@ -173,16 +173,16 @@ 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 26a6cb4b..8ba2c4f5 100644
--- a/bridge/mattermost/mattermost.go
+++ b/bridge/mattermost/mattermost.go
@@ -136,12 +136,12 @@ 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)
}
@@ -151,7 +151,7 @@ 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
}
@@ -201,7 +201,7 @@ 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)
@@ -256,7 +256,7 @@ 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 {
@@ -331,7 +331,7 @@ 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 {
@@ -442,7 +442,7 @@ 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 9062c1b9..1dbc7be0 100644
--- a/bridge/rocketchat/rocketchat.go
+++ b/bridge/rocketchat/rocketchat.go
@@ -43,7 +43,7 @@ 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 ef7364f6..d4e5e464 100644
--- a/bridge/slack/handlers.go
+++ b/bridge/slack/handlers.go
@@ -22,7 +22,7 @@ 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)
}
@@ -199,18 +199,18 @@ 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
}
@@ -256,7 +256,7 @@ 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 a7e7f01f..be372edd 100644
--- a/bridge/slack/legacy.go
+++ b/bridge/slack/legacy.go
@@ -8,15 +8,15 @@ 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 1f51de95..0a5d824f 100644
--- a/bridge/slack/slack.go
+++ b/bridge/slack/slack.go
@@ -185,12 +185,12 @@ 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 + "_"
}
@@ -270,7 +270,7 @@ 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))
}
@@ -312,7 +312,7 @@ 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 846a9081..827c81de 100644
--- a/bridge/sshchat/sshchat.go
+++ b/bridge/sshchat/sshchat.go
@@ -31,7 +31,7 @@ func (b *Bsshchat) Connect() error {
b.w = w
b.r.Scan()
w.Write([]byte("/theme mono\r\n"))
- b.handleSshChat()
+ b.handleSSHChat()
return nil
})
}()
@@ -53,7 +53,7 @@ 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)
@@ -113,7 +113,7 @@ 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 b04c10be..1a4dab27 100644
--- a/bridge/steam/steam.go
+++ b/bridge/steam/steam.go
@@ -60,7 +60,7 @@ 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 748ee87d..7097644e 100644
--- a/bridge/telegram/telegram.go
+++ b/bridge/telegram/telegram.go
@@ -66,7 +66,7 @@ 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)
}
@@ -75,7 +75,7 @@ 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
}
@@ -268,7 +268,7 @@ 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 4d6cc3cf..75fc83a4 100644
--- a/bridge/xmpp/xmpp.go
+++ b/bridge/xmpp/xmpp.go
@@ -51,7 +51,7 @@ 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()
}
@@ -76,7 +76,7 @@ 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)
@@ -177,7 +177,7 @@ 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 ebeabc1c..88832d36 100644
--- a/bridge/zulip/zulip.go
+++ b/bridge/zulip/zulip.go
@@ -52,7 +52,7 @@ 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 bbaef04f..d723d854 100644
--- a/gateway/gateway.go
+++ b/gateway/gateway.go
@@ -108,7 +108,7 @@ 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}
@@ -159,7 +159,7 @@ 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
@@ -246,7 +246,7 @@ 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
}
@@ -254,7 +254,7 @@ 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
@@ -262,24 +262,24 @@ 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)
}
@@ -289,7 +289,7 @@ 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
}
@@ -301,7 +301,7 @@ 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)
}
@@ -349,14 +349,14 @@ 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)
@@ -392,13 +392,13 @@ 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
@@ -437,7 +437,7 @@ 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")
}
@@ -479,8 +479,8 @@ 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
}
@@ -502,10 +502,10 @@ 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 {
@@ -524,7 +524,7 @@ 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)
@@ -542,7 +542,7 @@ 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)
@@ -562,6 +562,6 @@ 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 a6c6dafb..e62df205 100644
--- a/gateway/router.go
+++ b/gateway/router.go
@@ -27,7 +27,7 @@ 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
}
@@ -77,7 +77,7 @@ 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 {
@@ -88,7 +88,7 @@ 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 ea846e92..1d85ea7d 100644
--- a/gateway/samechannel/samechannel.go
+++ b/gateway/samechannel/samechannel.go
@@ -15,7 +15,7 @@ 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 90c0437b..bfb573f2 100644
--- a/matterbridge.go
+++ b/matterbridge.go
@@ -44,7 +44,7 @@ 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 edd298db..2967feb7 100644
--- a/matterclient/matterclient.go
+++ b/matterclient/matterclient.go
@@ -43,6 +43,7 @@ type Message struct {
UserID string
}
+//nolint:golint
type Team struct {
Team *model.Team
Id string
@@ -423,7 +424,7 @@ 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 {
@@ -458,7 +459,7 @@ 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 == "" {
@@ -488,7 +489,7 @@ 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) {
@@ -501,7 +502,7 @@ 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 {
@@ -515,7 +516,7 @@ 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 {
@@ -524,7 +525,7 @@ 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 {
@@ -533,7 +534,7 @@ 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 {
@@ -542,7 +543,7 @@ 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
@@ -550,7 +551,7 @@ 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 {
@@ -567,7 +568,7 @@ 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
@@ -583,7 +584,7 @@ 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
@@ -630,7 +631,7 @@ 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)
@@ -639,7 +640,7 @@ 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)
@@ -660,7 +661,7 @@ 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)
@@ -690,11 +691,11 @@ 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)
@@ -714,7 +715,7 @@ 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 {
@@ -752,7 +753,7 @@ 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
@@ -774,7 +775,7 @@ 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, "")
@@ -794,7 +795,7 @@ 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]
@@ -808,7 +809,7 @@ 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, "")
@@ -818,7 +819,7 @@ 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
@@ -826,7 +827,7 @@ 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
@@ -834,7 +835,7 @@ 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 ""
@@ -848,7 +849,7 @@ 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
@@ -878,11 +879,11 @@ 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 9287baa9..f602ed44 100644
--- a/matterhook/matterhook.go
+++ b/matterhook/matterhook.go
@@ -41,9 +41,9 @@ 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"`
@@ -51,7 +51,8 @@ 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