From b8a8b29a7515425f5a385ad8b4a8c3e0970224c3 Mon Sep 17 00:00:00 2001 From: "Lucian I. Last" Date: Wed, 19 Nov 2025 12:17:04 +0100 Subject: [PATCH 01/10] Add mastodon --- bridge/mastodon/mastodon.go | 237 +++++++++++++++++++++++++++++++++ gateway/bridgemap/bmastodon.go | 12 ++ go.mod | 2 + matterbridge.toml.sample | 27 ++++ 4 files changed, 278 insertions(+) create mode 100644 bridge/mastodon/mastodon.go create mode 100644 gateway/bridgemap/bmastodon.go diff --git a/bridge/mastodon/mastodon.go b/bridge/mastodon/mastodon.go new file mode 100644 index 0000000000..253d76a6bc --- /dev/null +++ b/bridge/mastodon/mastodon.go @@ -0,0 +1,237 @@ +package mastodon + +import ( + "bytes" + "context" + "fmt" + "io" + "net/http" + "strings" + + "github.com/42wim/matterbridge/bridge" + "github.com/42wim/matterbridge/bridge/config" + + mastodon "github.com/mattn/go-mastodon" +) + +type Bmastodon struct { + *bridge.Config + c *mastodon.Client + account *mastodon.Account + + ctxHome context.Context + ctxCancelHome context.CancelFunc + ctxLocal context.Context + ctxCancelLocal context.CancelFunc + ctxDirect context.Context + ctxCancelDirect context.CancelFunc +} + +func New(cfg *bridge.Config) bridge.Bridger { + b := &Bmastodon{Config: cfg} + return b +} + +func (b *Bmastodon) Connect() error { + b.Log.Infof("Connecting %s", b.GetString("Server")) + + config := mastodon.Config{ + Server: b.GetString("Server"), + ClientID: b.GetString("ClientID"), + ClientSecret: b.GetString("ClientSecret"), + AccessToken: b.GetString("AccessToken"), + } + b.c = mastodon.NewClient(&config) + var err error + b.account, err = + b.c.GetAccountCurrentUser(context.Background()) + if err != nil { + return nil + } + + return nil +} + +func (b *Bmastodon) Disconnect() error { + if b.ctxCancelHome != nil { + b.ctxCancelHome() + } + if b.ctxCancelLocal != nil { + b.ctxCancelLocal() + } + if b.ctxCancelDirect != nil { + b.ctxCancelDirect() + } + + return nil +} + +func (b *Bmastodon) JoinChannel(channel config.ChannelInfo) error { + var channelType string + var ch chan mastodon.Event + var err error + if channel.Name == "home" { + // You are talking to the home channel + channelType = "home" + b.ctxHome, b.ctxCancelHome = context.WithCancel(context.Background()) + ch, err = b.c.StreamingUser(b.ctxHome) + } else if channel.Name == "local" { + channelType = "local" + // You are talking to the local channel + b.ctxLocal, b.ctxCancelLocal = context.WithCancel(context.Background()) + ch, err = b.c.StreamingPublic(b.ctxLocal, true) + } else if strings.HasPrefix(channel.Name, "@") { + channelType = "direct" + // You are talking to a private user + if b.ctxCancelDirect == nil { + b.ctxDirect, b.ctxCancelDirect = context.WithCancel(context.Background()) + ch, err = b.c.StreamingDirect(b.ctxDirect) + } + } else { + return fmt.Errorf("invalid channel name: %s", channel.Name) + } + if err != nil { + return err + } + + go func() { + for msg := range ch { + switch t := msg.(type) { + case *mastodon.UpdateEvent: + switch channelType { + case "local", "home": + b.handleSendRemoteStatus(t.Status, channelType) + } + case *mastodon.ConversationEvent: + b.handleSendRemoteStatus(t.Conversation.LastStatus, "@"+t.Conversation.Accounts[0].Acct) + } + + } + }() + return nil +} + +func (b *Bmastodon) handleSendRemoteStatus(msg *mastodon.Status, channel string) { + remoteMessage := config.Message{ + Text: msg.Content, + Channel: channel, + Username: msg.Account.Username, + UserID: string(msg.Account.ID), + Account: msg.Account.DisplayName, + Avatar: msg.Account.Avatar, + ID: string(msg.ID), + Extra: map[string][]any{}, + } + if len(msg.MediaAttachments) > 0 { + remoteMessage.Extra["file"] = []any{} + } + for _, media := range msg.MediaAttachments { + resp, err := http.Get(media.RemoteURL) + if err != nil { + continue + } + defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + continue + } + b, err := io.ReadAll(resp.Body) + if err != nil { + continue + } + remoteMessage.Extra["file"] = append(remoteMessage.Extra["file"], config.FileInfo{ + Name: media.Description, + Data: &b, + Size: int64(len(b)), + Avatar: false, + }) + } +} + +func (b *Bmastodon) Send(msg config.Message) (string, error) { + ctx := context.Background() + + // Standard Message Send + if msg.Event == "" { + sentMessage, err := b.handleSendingMessage(ctx, &msg) + if err != nil { + b.Log.Errorf("Could not send message to room %v from %v: %v", msg.Channel, msg.Username, err) + + return "", nil + } + return string(sentMessage.ID), nil + } + + // Message Deletion + if msg.Event == config.EventMsgDelete { + if msg.UserID != string(b.account.ID) { + b.Log.Errorf("Can not delete a status that is owned by a different account") + return "", nil + } + err := b.c.DeleteStatus(context.Background(), mastodon.ID(msg.ID)) + return "", err + } + + // Message is not a type that is currently supported + return "", nil +} + +func (b *Bmastodon) handleSendingMessage(ctx context.Context, msg *config.Message) (*mastodon.Status, error) { + toot := mastodon.Toot{ + Status: msg.Text, + InReplyToID: "", + MediaIDs: []mastodon.ID{}, + Sensitive: false, + SpoilerText: "", + Visibility: "public", + Language: "", + } + if strings.HasPrefix(msg.Channel, "#") { + toot.Status += " " + msg.Channel + } + if strings.HasPrefix(msg.Channel, "@") { + toot.Visibility = "private" + } + if msg.ParentID != "" { + toot.InReplyToID = mastodon.ID(msg.ParentID) + if toot.Visibility == "public" { + toot.Visibility = "unlisted" + } + } + + for _, file := range msg.Extra["file"] { + fileInfo, ok := file.(config.FileInfo) + if !ok { + continue + } + var r io.Reader + var err error + var resp *http.Response + defer func() { + if resp != nil { + resp.Body.Close() + } + }() + if fileInfo.URL != "" { + resp, err = http.Get(fileInfo.URL) + if err != nil { + continue + } + if resp.StatusCode != http.StatusOK { + continue + } + r = resp.Body + } else if fileInfo.Data != nil { + r = bytes.NewReader(*fileInfo.Data) + } + attachment, err := b.c.UploadMediaFromMedia(ctx, &mastodon.Media{ + File: r, + Description: fileInfo.Comment, + }) + if err != nil { + continue + } + toot.MediaIDs = append(toot.MediaIDs, attachment.ID) + } + + return b.c.PostStatus(ctx, &toot) +} diff --git a/gateway/bridgemap/bmastodon.go b/gateway/bridgemap/bmastodon.go new file mode 100644 index 0000000000..2773e24799 --- /dev/null +++ b/gateway/bridgemap/bmastodon.go @@ -0,0 +1,12 @@ +//go:build !nomastodon +// +build !nomastodon + +package bridgemap + +import ( + bmastodon "github.com/42wim/matterbridge/bridge/mastodon" +) + +func init() { + FullMap["mastodon"] = bmastodon.New +} diff --git a/go.mod b/go.mod index a64835b58d..14fe0442de 100644 --- a/go.mod +++ b/go.mod @@ -51,9 +51,11 @@ require ( google.golang.org/protobuf v1.34.2 layeh.com/gumble v0.0.0-20221205141517-d1df60a3cc14 modernc.org/sqlite v1.32.0 + github.com/mattn/go-mastodon v0.0.10 ) require ( + github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/Benau/go_rlottie v0.0.0-20210807002906-98c1b2421989 // indirect github.com/Jeffail/gabs v1.4.0 // indirect diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample index 530f40e1c0..6efe8d42b9 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -535,6 +535,31 @@ Label="" # REQUIRED Team="myteam" +################################################################### +# +# Mastodon +# +################################################################### + +[mastodon] +[mastodon.myaccount] + +# Your mastodon instance url. +# REQUIRED +Server="https://mastodon.social" + +# Application client key +# REQUIRED +ClientID="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + +# Application client secret +# REQUIRED +ClientSecret="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + +# Application access token +# REQUIRED +AccessToken="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + ################################################################### # Microsoft teams section # See https://github.com/42wim/matterbridge/wiki/MS-Teams-setup @@ -1757,6 +1782,8 @@ enable=true # ------------------------------------------------------------------------------------------------------------------------------------- # irc | channel | #general | The # symbol is required and should be lowercase! # ------------------------------------------------------------------------------------------------------------------------------------- + # mastodon | channel | home | The channel can be home or local or @name@mastodon.social + # ------------------------------------------------------------------------------------------------------------------------------------- # | channel | general | This is the channel name as seen in the URL, not the display name # mattermost | channel id | ID:oc4wifyuojgw5f3nsuweesmz8w | This is the channel ID (only use if you know what you're doing) # ------------------------------------------------------------------------------------------------------------------------------------- From d289026975c97fc73ff4d8f236e2a0e3381d48f5 Mon Sep 17 00:00:00 2001 From: "Lucian I. Last" Date: Wed, 19 Nov 2025 14:10:59 +0100 Subject: [PATCH 02/10] Fix go mod --- go.mod | 4 ++-- go.sum | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 14fe0442de..009532a2f0 100644 --- a/go.mod +++ b/go.mod @@ -24,6 +24,7 @@ require ( github.com/matterbridge/matterclient v0.0.0-20240817214420-3d4c3aef3dc1 github.com/matterbridge/telegram-bot-api/v6 v6.5.0 github.com/mattermost/mattermost/server/public v0.1.6 + github.com/mattn/go-mastodon v0.0.10 github.com/mattn/godown v0.0.1 github.com/mdp/qrterminal v1.0.1 github.com/mitchellh/mapstructure v1.5.0 @@ -51,11 +52,9 @@ require ( google.golang.org/protobuf v1.34.2 layeh.com/gumble v0.0.0-20221205141517-d1df60a3cc14 modernc.org/sqlite v1.32.0 - github.com/mattn/go-mastodon v0.0.10 ) require ( - github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/Benau/go_rlottie v0.0.0-20210807002906-98c1b2421989 // indirect github.com/Jeffail/gabs v1.4.0 // indirect @@ -117,6 +116,7 @@ require ( github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/tinylib/msgp v1.2.0 // indirect + github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect diff --git a/go.sum b/go.sum index df67241a2a..283abb4ba9 100644 --- a/go.sum +++ b/go.sum @@ -226,6 +226,8 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-mastodon v0.0.10 h1:wz1d/aCkJOIkz46iv4eAqXHVreUMxydY1xBWrPBdDeE= +github.com/mattn/go-mastodon v0.0.10/go.mod h1:YBofeqh7G6s787787NQR8erBYz6fKDu+KNMrn5RuD6Y= github.com/mattn/go-runewidth v0.0.8/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= @@ -388,6 +390,8 @@ github.com/tj/go-buffer v1.1.0/go.mod h1:iyiJpfFcR2B9sXu7KvjbT9fpM4mOelRSDTbntVj github.com/tj/go-elastic v0.0.0-20171221160941-36157cbbebc2/go.mod h1:WjeM0Oo1eNAjXGDx2yma7uG2XoyRZTq1uv3M/o7imD0= github.com/tj/go-kinesis v0.0.0-20171128231115-08b17f58cb1b/go.mod h1:/yhzCV0xPfx6jb1bBgRFjl5lytqVqZXEaeqWP8lTEao= github.com/tj/go-spin v1.1.0/go.mod h1:Mg1mzmePZm4dva8Qz60H2lHwmJ2loum4VIrLgVnKwh4= +github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 h1:nrZ3ySNYwJbSpD6ce9duiP+QkD3JuLCcWkdaehUS/3Y= +github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80/go.mod h1:iFyPdL66DjUD96XmzVL3ZntbzcflLnznH0fr99w5VqE= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= From 54c1413789bfdeba7576c9d63b5a8c43ca36af78 Mon Sep 17 00:00:00 2001 From: "Lucian I. Last" Date: Wed, 19 Nov 2025 14:11:45 +0100 Subject: [PATCH 03/10] Fix send from mastodon --- bridge/mastodon/mastodon.go | 96 +++++++++++++++++++++++++------------ 1 file changed, 66 insertions(+), 30 deletions(-) diff --git a/bridge/mastodon/mastodon.go b/bridge/mastodon/mastodon.go index 253d76a6bc..e03929b5c8 100644 --- a/bridge/mastodon/mastodon.go +++ b/bridge/mastodon/mastodon.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "net/http" + "regexp" "strings" "github.com/42wim/matterbridge/bridge" @@ -14,17 +15,22 @@ import ( mastodon "github.com/mattn/go-mastodon" ) +var ( + htmlReplacementTag = regexp.MustCompile("<[^>]*>") +) + +type Broom struct { + channel string + ctx context.Context + ctxCancel context.CancelFunc +} + type Bmastodon struct { *bridge.Config c *mastodon.Client account *mastodon.Account - ctxHome context.Context - ctxCancelHome context.CancelFunc - ctxLocal context.Context - ctxCancelLocal context.CancelFunc - ctxDirect context.Context - ctxCancelDirect context.CancelFunc + rooms []Broom } func New(cfg *bridge.Config) bridge.Bridger { @@ -53,14 +59,8 @@ func (b *Bmastodon) Connect() error { } func (b *Bmastodon) Disconnect() error { - if b.ctxCancelHome != nil { - b.ctxCancelHome() - } - if b.ctxCancelLocal != nil { - b.ctxCancelLocal() - } - if b.ctxCancelDirect != nil { - b.ctxCancelDirect() + for _, r := range b.rooms { + r.ctxCancel() } return nil @@ -70,24 +70,45 @@ func (b *Bmastodon) JoinChannel(channel config.ChannelInfo) error { var channelType string var ch chan mastodon.Event var err error + ctx, ctxCancel := context.WithCancel(context.Background()) if channel.Name == "home" { // You are talking to the home channel + b.rooms = append(b.rooms, Broom{ + channel: "home", + ctx: ctx, + ctxCancel: ctxCancel, + }) channelType = "home" - b.ctxHome, b.ctxCancelHome = context.WithCancel(context.Background()) - ch, err = b.c.StreamingUser(b.ctxHome) + ch, err = b.c.StreamingUser(ctx) } else if channel.Name == "local" { - channelType = "local" // You are talking to the local channel - b.ctxLocal, b.ctxCancelLocal = context.WithCancel(context.Background()) - ch, err = b.c.StreamingPublic(b.ctxLocal, true) + b.rooms = append(b.rooms, Broom{ + channel: "local", + ctx: ctx, + ctxCancel: ctxCancel, + }) + channelType = "local" + ch, err = b.c.StreamingPublic(ctx, true) + } else if channel.Name == "remote" { + // You are talking to the remote channel + b.rooms = append(b.rooms, Broom{ + channel: "remote", + ctx: ctx, + ctxCancel: ctxCancel, + }) + channelType = "remote" + ch, err = b.c.StreamingPublic(ctx, false) } else if strings.HasPrefix(channel.Name, "@") { - channelType = "direct" // You are talking to a private user - if b.ctxCancelDirect == nil { - b.ctxDirect, b.ctxCancelDirect = context.WithCancel(context.Background()) - ch, err = b.c.StreamingDirect(b.ctxDirect) - } + b.rooms = append(b.rooms, Broom{ + channel: channel.Name, + ctx: ctx, + ctxCancel: ctxCancel, + }) + channelType = "direct" + ch, err = b.c.StreamingDirect(ctx) } else { + ctxCancel() return fmt.Errorf("invalid channel name: %s", channel.Name) } if err != nil { @@ -95,15 +116,24 @@ func (b *Bmastodon) JoinChannel(channel config.ChannelInfo) error { } go func() { + b.Log.Debugf("run golang channel on streaming api call, channel name: %v", channel.Name) for msg := range ch { switch t := msg.(type) { case *mastodon.UpdateEvent: switch channelType { - case "local", "home": - b.handleSendRemoteStatus(t.Status, channelType) + case "local", "home", "remote": + b.handleSendRemoteStatus(t.Status, channel.Name) + default: + b.Log.Debugf("run UpdateEvent on unsupported channelType: %s", channelType) } case *mastodon.ConversationEvent: - b.handleSendRemoteStatus(t.Conversation.LastStatus, "@"+t.Conversation.Accounts[0].Acct) + switch channelType { + case "local", "home", "remote": + // Not a conversation + b.Log.Debugf("run ConversationEvent on unsupported channelType: %s", channelType) + default: + b.handleSendRemoteStatus(t.Conversation.LastStatus, channel.Name) + } } } @@ -112,12 +142,16 @@ func (b *Bmastodon) JoinChannel(channel config.ChannelInfo) error { } func (b *Bmastodon) handleSendRemoteStatus(msg *mastodon.Status, channel string) { + if msg.Account.ID == b.account.ID { + // Ignore messages that are from the bot user + return + } remoteMessage := config.Message{ - Text: msg.Content, + Text: htmlReplacementTag.ReplaceAllString(msg.Content, ""), Channel: channel, - Username: msg.Account.Username, + Username: msg.Account.DisplayName, UserID: string(msg.Account.ID), - Account: msg.Account.DisplayName, + Account: b.Account, Avatar: msg.Account.Avatar, ID: string(msg.ID), Extra: map[string][]any{}, @@ -145,6 +179,8 @@ func (b *Bmastodon) handleSendRemoteStatus(msg *mastodon.Status, channel string) Avatar: false, }) } + b.Log.Debugf("<= Message is %#v", remoteMessage) + b.Remote <- remoteMessage } func (b *Bmastodon) Send(msg config.Message) (string, error) { From f833bf90c1127ee82f993e671a44ebb07bd72a67 Mon Sep 17 00:00:00 2001 From: "Lucian I. Last" Date: Wed, 19 Nov 2025 17:04:11 +0100 Subject: [PATCH 04/10] Update code references to old repo --- .github/workflows/development.yml | 12 ++++++------ .goreleaser.yml | 2 +- Dockerfile | 2 +- Dockerfile_whatsappmulti | 2 +- bridge/api/api.go | 4 ++-- bridge/bridge.go | 2 +- bridge/discord/discord.go | 8 ++++---- bridge/discord/handlers.go | 2 +- bridge/discord/webhook.go | 4 ++-- bridge/helper/helper.go | 2 +- bridge/irc/handlers.go | 4 ++-- bridge/irc/irc.go | 6 +++--- bridge/mastodon/mastodon.go | 4 ++-- bridge/matrix/matrix.go | 6 +++--- bridge/mattermost/handlers.go | 4 ++-- bridge/mattermost/helpers.go | 6 +++--- bridge/mattermost/mattermost.go | 8 ++++---- bridge/msteams/handler.go | 4 ++-- bridge/msteams/msteams.go | 4 ++-- bridge/mumble/codec.go | 2 +- bridge/mumble/handlers.go | 4 ++-- bridge/mumble/helpers.go | 2 +- bridge/mumble/mumble.go | 6 +++--- bridge/nctalk/nctalk.go | 4 ++-- bridge/rocketchat/handlers.go | 4 ++-- bridge/rocketchat/helpers.go | 8 ++++---- bridge/rocketchat/rocketchat.go | 10 +++++----- bridge/slack/handlers.go | 4 ++-- bridge/slack/helpers.go | 2 +- bridge/slack/helpers_test.go | 2 +- bridge/slack/legacy.go | 4 ++-- bridge/slack/slack.go | 10 +++++----- bridge/slack/users_channels.go | 2 +- bridge/sshchat/sshchat.go | 6 +++--- bridge/telegram/handlers.go | 6 +++--- bridge/telegram/telegram.go | 6 +++--- bridge/vk/vk.go | 6 +++--- bridge/whatsapp/handlers.go | 12 ++++++------ bridge/whatsapp/whatsapp.go | 10 +++++----- bridge/whatsappmulti/handlers.go | 8 ++++---- bridge/whatsappmulti/whatsapp.go | 6 +++--- bridge/xmpp/handler.go | 4 ++-- bridge/xmpp/helpers.go | 2 +- bridge/xmpp/xmpp.go | 6 +++--- bridge/zulip/zulip.go | 8 ++++---- contrib/api.yaml | 8 ++++---- contrib/example.tengo | 2 +- docker/arm/Dockerfile | 2 +- gateway/bridgemap/api.go | 2 +- gateway/bridgemap/bdiscord.go | 2 +- gateway/bridgemap/birc.go | 2 +- gateway/bridgemap/bmastodon.go | 2 +- gateway/bridgemap/bmatrix.go | 2 +- gateway/bridgemap/bmattermost.go | 2 +- gateway/bridgemap/bmsteams.go | 2 +- gateway/bridgemap/bmumble.go | 2 +- gateway/bridgemap/bnctalk.go | 2 +- gateway/bridgemap/bridgemap.go | 2 +- gateway/bridgemap/brocketchat.go | 2 +- gateway/bridgemap/bslack.go | 2 +- gateway/bridgemap/bsshchat.go | 2 +- gateway/bridgemap/btelegram.go | 2 +- gateway/bridgemap/bvk.go | 2 +- gateway/bridgemap/bwhatsapp.go | 2 +- gateway/bridgemap/bwhatsappmulti.go | 2 +- gateway/bridgemap/bxmpp.go | 2 +- gateway/bridgemap/bzulip.go | 2 +- gateway/gateway.go | 6 +++--- gateway/gateway_test.go | 4 ++-- gateway/handlers.go | 6 +++--- gateway/handlers_test.go | 4 ++-- gateway/router.go | 10 +++++----- gateway/samechannel/samechannel.go | 2 +- gateway/samechannel/samechannel_test.go | 2 +- go.mod | 2 +- matterbridge.go | 8 ++++---- tgs.Dockerfile | 2 +- 77 files changed, 163 insertions(+), 163 deletions(-) diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index 926fddc1f4..0281a7c53c 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -2,12 +2,12 @@ name: Development on: push: paths-ignore: - - 'docs/**' - - 'README.md' + - "docs/**" + - "README.md" pull_request: paths-ignore: - - 'docs/**' - - 'README.md' + - "docs/**" + - "README.md" permissions: contents: read pull-requests: read @@ -46,7 +46,7 @@ jobs: run: go test ./... build-upload: # Uploading artifacts only if lint/test succeeded - needs: [ "lint", "test" ] + needs: ["lint", "test"] strategy: matrix: arch: [amd64] @@ -67,7 +67,7 @@ jobs: uses: actions/checkout@v5 - name: Build/upload matterbridge for ${{ matrix.platform.goos }}-${{ matrix.arch }} run: | - CGO_ENABLED=0 GOOS=${{ matrix.platform.goos }} GOARCH=${{ matrix.arch }} go build -ldflags "-s -X github.com/42wim/matterbridge/version.GitHash=$(git log --pretty=format:'%h' -n 1)" -o matterbridge + CGO_ENABLED=0 GOOS=${{ matrix.platform.goos }} GOARCH=${{ matrix.arch }} go build -ldflags "-s -X github.com/matterbridge-org/matterbridge/version.GitHash=$(git log --pretty=format:'%h' -n 1)" -o matterbridge - name: Upload matterbridge-${{ matrix.name }}-${{ matrix.arch }} uses: actions/upload-artifact@v4 with: diff --git a/.goreleaser.yml b/.goreleaser.yml index c4f9064b2d..d57d413625 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -22,7 +22,7 @@ builds: - 6 - 7 ldflags: - - -s -w -X github.com/42wim/matterbridge/version.GitHash={{.ShortCommit}} + - -s -w -X github.com/matterbridge-org/matterbridge/version.GitHash={{.ShortCommit}} archives: - diff --git a/Dockerfile b/Dockerfile index de3d05ee42..366a5a42d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM alpine AS builder COPY . /go/src/matterbridge RUN apk --no-cache add go git \ && cd /go/src/matterbridge \ - && CGO_ENABLED=0 go build -ldflags "-X github.com/42wim/matterbridge/version.GitHash=$(git log --pretty=format:'%h' -n 1)" -o /bin/matterbridge + && CGO_ENABLED=0 go build -ldflags "-X github.com/matterbridge-org/matterbridge/version.GitHash=$(git log --pretty=format:'%h' -n 1)" -o /bin/matterbridge FROM alpine RUN apk --no-cache add ca-certificates mailcap diff --git a/Dockerfile_whatsappmulti b/Dockerfile_whatsappmulti index 6db65fede1..f2f30b18b4 100644 --- a/Dockerfile_whatsappmulti +++ b/Dockerfile_whatsappmulti @@ -3,7 +3,7 @@ FROM alpine AS builder COPY . /go/src/matterbridge RUN apk --no-cache add go git \ && cd /go/src/matterbridge \ - && CGO_ENABLED=0 go build -tags whatsappmulti -mod vendor -ldflags "-X github.com/42wim/matterbridge/version.GitHash=$(git log --pretty=format:'%h' -n 1)" -o /bin/matterbridge + && CGO_ENABLED=0 go build -tags whatsappmulti -mod vendor -ldflags "-X github.com/matterbridge-org/matterbridge/version.GitHash=$(git log --pretty=format:'%h' -n 1)" -o /bin/matterbridge FROM alpine RUN apk --no-cache add ca-certificates mailcap diff --git a/bridge/api/api.go b/bridge/api/api.go index cb348f1601..30ceac952f 100644 --- a/bridge/api/api.go +++ b/bridge/api/api.go @@ -10,10 +10,10 @@ import ( "github.com/olahol/melody" - "github.com/42wim/matterbridge/bridge" - "github.com/42wim/matterbridge/bridge/config" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" + "github.com/matterbridge-org/matterbridge/bridge" + "github.com/matterbridge-org/matterbridge/bridge/config" "github.com/mitchellh/mapstructure" ring "github.com/zfjagann/golang-ring" ) diff --git a/bridge/bridge.go b/bridge/bridge.go index ef71f97ee1..62e55f9cb9 100644 --- a/bridge/bridge.go +++ b/bridge/bridge.go @@ -6,7 +6,7 @@ import ( "sync" "time" - "github.com/42wim/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/config" "github.com/sirupsen/logrus" ) diff --git a/bridge/discord/discord.go b/bridge/discord/discord.go index 3f99da0cee..0192fe4add 100644 --- a/bridge/discord/discord.go +++ b/bridge/discord/discord.go @@ -6,12 +6,12 @@ import ( "strings" "sync" - "github.com/42wim/matterbridge/bridge" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/bridge/discord/transmitter" - "github.com/42wim/matterbridge/bridge/helper" "github.com/bwmarrin/discordgo" lru "github.com/hashicorp/golang-lru" + "github.com/matterbridge-org/matterbridge/bridge" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/discord/transmitter" + "github.com/matterbridge-org/matterbridge/bridge/helper" ) const ( diff --git a/bridge/discord/handlers.go b/bridge/discord/handlers.go index 34cef55480..b969122cbc 100644 --- a/bridge/discord/handlers.go +++ b/bridge/discord/handlers.go @@ -1,9 +1,9 @@ package bdiscord import ( - "github.com/42wim/matterbridge/bridge/config" "github.com/bwmarrin/discordgo" "github.com/davecgh/go-spew/spew" + "github.com/matterbridge-org/matterbridge/bridge/config" ) func (b *Bdiscord) messageDelete(s *discordgo.Session, m *discordgo.MessageDelete) { //nolint:unparam diff --git a/bridge/discord/webhook.go b/bridge/discord/webhook.go index ef129d4c07..8dadf5f23e 100644 --- a/bridge/discord/webhook.go +++ b/bridge/discord/webhook.go @@ -4,9 +4,9 @@ import ( "bytes" "strings" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/bridge/helper" "github.com/bwmarrin/discordgo" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/helper" ) // shouldMessageUseWebhooks checks if have a channel specific webhook, if we're not using auto webhooks diff --git a/bridge/helper/helper.go b/bridge/helper/helper.go index b90c906550..9f3a47076c 100644 --- a/bridge/helper/helper.go +++ b/bridge/helper/helper.go @@ -13,10 +13,10 @@ import ( "golang.org/x/image/webp" - "github.com/42wim/matterbridge/bridge/config" "github.com/gomarkdown/markdown" "github.com/gomarkdown/markdown/html" "github.com/gomarkdown/markdown/parser" + "github.com/matterbridge-org/matterbridge/bridge/config" "github.com/sirupsen/logrus" ) diff --git a/bridge/irc/handlers.go b/bridge/irc/handlers.go index cb2cc85581..e9d79aa052 100644 --- a/bridge/irc/handlers.go +++ b/bridge/irc/handlers.go @@ -8,9 +8,9 @@ import ( "strings" "time" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/bridge/helper" "github.com/lrstanley/girc" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/helper" "github.com/paulrosania/go-charset/charset" "github.com/saintfish/chardet" diff --git a/bridge/irc/irc.go b/bridge/irc/irc.go index 7202df5e5e..cf978c410d 100644 --- a/bridge/irc/irc.go +++ b/bridge/irc/irc.go @@ -12,10 +12,10 @@ import ( "strings" "time" - "github.com/42wim/matterbridge/bridge" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/bridge/helper" "github.com/lrstanley/girc" + "github.com/matterbridge-org/matterbridge/bridge" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/helper" stripmd "github.com/writeas/go-strip-markdown" // We need to import the 'data' package as an implicit dependency. diff --git a/bridge/mastodon/mastodon.go b/bridge/mastodon/mastodon.go index e03929b5c8..007b292584 100644 --- a/bridge/mastodon/mastodon.go +++ b/bridge/mastodon/mastodon.go @@ -9,8 +9,8 @@ import ( "regexp" "strings" - "github.com/42wim/matterbridge/bridge" - "github.com/42wim/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge" + "github.com/matterbridge-org/matterbridge/bridge/config" mastodon "github.com/mattn/go-mastodon" ) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index 49fc33b3e7..4821423b7e 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -9,9 +9,9 @@ import ( "sync" "time" - "github.com/42wim/matterbridge/bridge" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/bridge/helper" + "github.com/matterbridge-org/matterbridge/bridge" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/helper" matrix "github.com/matterbridge/gomatrix" ) diff --git a/bridge/mattermost/handlers.go b/bridge/mattermost/handlers.go index b7b5338626..a4743b3b01 100644 --- a/bridge/mattermost/handlers.go +++ b/bridge/mattermost/handlers.go @@ -3,8 +3,8 @@ package bmattermost import ( "context" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/bridge/helper" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/helper" "github.com/matterbridge/matterclient" "github.com/mattermost/mattermost/server/public/model" ) diff --git a/bridge/mattermost/helpers.go b/bridge/mattermost/helpers.go index 8dba877ca6..21210f0cae 100644 --- a/bridge/mattermost/helpers.go +++ b/bridge/mattermost/helpers.go @@ -4,9 +4,9 @@ import ( "net/http" "strings" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/bridge/helper" - "github.com/42wim/matterbridge/matterhook" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/helper" + "github.com/matterbridge-org/matterbridge/matterhook" "github.com/matterbridge/matterclient" "github.com/mattermost/mattermost/server/public/model" ) diff --git a/bridge/mattermost/mattermost.go b/bridge/mattermost/mattermost.go index 349a7083ca..2a9cbf7670 100644 --- a/bridge/mattermost/mattermost.go +++ b/bridge/mattermost/mattermost.go @@ -7,10 +7,10 @@ import ( "strings" "sync" - "github.com/42wim/matterbridge/bridge" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/bridge/helper" - "github.com/42wim/matterbridge/matterhook" + "github.com/matterbridge-org/matterbridge/bridge" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/helper" + "github.com/matterbridge-org/matterbridge/matterhook" "github.com/matterbridge/matterclient" "github.com/rs/xid" ) diff --git a/bridge/msteams/handler.go b/bridge/msteams/handler.go index c8f0c468cc..6083eabd69 100644 --- a/bridge/msteams/handler.go +++ b/bridge/msteams/handler.go @@ -6,8 +6,8 @@ import ( "io/ioutil" "strings" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/bridge/helper" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/helper" msgraph "github.com/yaegashi/msgraph.go/beta" ) diff --git a/bridge/msteams/msteams.go b/bridge/msteams/msteams.go index 27d7bee07f..f79e718884 100644 --- a/bridge/msteams/msteams.go +++ b/bridge/msteams/msteams.go @@ -8,9 +8,9 @@ import ( "strings" "time" - "github.com/42wim/matterbridge/bridge" - "github.com/42wim/matterbridge/bridge/config" "github.com/davecgh/go-spew/spew" + "github.com/matterbridge-org/matterbridge/bridge" + "github.com/matterbridge-org/matterbridge/bridge/config" "github.com/mattn/godown" msgraph "github.com/yaegashi/msgraph.go/beta" diff --git a/bridge/mumble/codec.go b/bridge/mumble/codec.go index 1306e40828..cf465b374b 100644 --- a/bridge/mumble/codec.go +++ b/bridge/mumble/codec.go @@ -10,7 +10,7 @@ import ( // to implement Opus, but does not actually do anything. This serves // as a workaround until https://github.com/layeh/gumble/pull/61 is // merged. -// See https://github.com/42wim/matterbridge/issues/1750 for details. +// See https://github.com/matterbridge-org/matterbridge/issues/1750 for details. const ( audioCodecIDOpus = 4 diff --git a/bridge/mumble/handlers.go b/bridge/mumble/handlers.go index 830aa5c0e0..98dfda1f95 100644 --- a/bridge/mumble/handlers.go +++ b/bridge/mumble/handlers.go @@ -6,8 +6,8 @@ import ( "layeh.com/gumble/gumble" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/bridge/helper" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/helper" ) func (b *Bmumble) handleServerConfig(event *gumble.ServerConfigEvent) { diff --git a/bridge/mumble/helpers.go b/bridge/mumble/helpers.go index c828df2ca4..9e0a6c06c6 100644 --- a/bridge/mumble/helpers.go +++ b/bridge/mumble/helpers.go @@ -7,7 +7,7 @@ import ( "regexp" "strings" - "github.com/42wim/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/config" "github.com/mattn/godown" "github.com/vincent-petithory/dataurl" ) diff --git a/bridge/mumble/mumble.go b/bridge/mumble/mumble.go index 859ca4abd5..54bbdcdc4f 100644 --- a/bridge/mumble/mumble.go +++ b/bridge/mumble/mumble.go @@ -14,9 +14,9 @@ import ( "layeh.com/gumble/gumble" "layeh.com/gumble/gumbleutil" - "github.com/42wim/matterbridge/bridge" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/bridge/helper" + "github.com/matterbridge-org/matterbridge/bridge" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/helper" stripmd "github.com/writeas/go-strip-markdown" // We need to import the 'data' package as an implicit dependency. diff --git a/bridge/nctalk/nctalk.go b/bridge/nctalk/nctalk.go index 82acba4b53..f673169d8a 100644 --- a/bridge/nctalk/nctalk.go +++ b/bridge/nctalk/nctalk.go @@ -6,8 +6,8 @@ import ( "strconv" "strings" - "github.com/42wim/matterbridge/bridge" - "github.com/42wim/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge" + "github.com/matterbridge-org/matterbridge/bridge/config" "gomod.garykim.dev/nc-talk/ocs" "gomod.garykim.dev/nc-talk/room" diff --git a/bridge/rocketchat/handlers.go b/bridge/rocketchat/handlers.go index 03b66eac07..147d5d5916 100644 --- a/bridge/rocketchat/handlers.go +++ b/bridge/rocketchat/handlers.go @@ -3,8 +3,8 @@ package brocketchat import ( "fmt" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/bridge/helper" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/helper" "github.com/matterbridge/Rocket.Chat.Go.SDK/models" ) diff --git a/bridge/rocketchat/helpers.go b/bridge/rocketchat/helpers.go index fa1b4703f9..f7f3294ae7 100644 --- a/bridge/rocketchat/helpers.go +++ b/bridge/rocketchat/helpers.go @@ -9,10 +9,10 @@ import ( "strings" "time" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/bridge/helper" - "github.com/42wim/matterbridge/hook/rockethook" - "github.com/42wim/matterbridge/matterhook" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/helper" + "github.com/matterbridge-org/matterbridge/hook/rockethook" + "github.com/matterbridge-org/matterbridge/matterhook" "github.com/matterbridge/Rocket.Chat.Go.SDK/models" "github.com/matterbridge/Rocket.Chat.Go.SDK/realtime" "github.com/matterbridge/Rocket.Chat.Go.SDK/rest" diff --git a/bridge/rocketchat/rocketchat.go b/bridge/rocketchat/rocketchat.go index 405beadc04..75cff90d0a 100644 --- a/bridge/rocketchat/rocketchat.go +++ b/bridge/rocketchat/rocketchat.go @@ -5,12 +5,12 @@ import ( "strings" "sync" - "github.com/42wim/matterbridge/bridge" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/bridge/helper" - "github.com/42wim/matterbridge/hook/rockethook" - "github.com/42wim/matterbridge/matterhook" lru "github.com/hashicorp/golang-lru" + "github.com/matterbridge-org/matterbridge/bridge" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/helper" + "github.com/matterbridge-org/matterbridge/hook/rockethook" + "github.com/matterbridge-org/matterbridge/matterhook" "github.com/matterbridge/Rocket.Chat.Go.SDK/models" "github.com/matterbridge/Rocket.Chat.Go.SDK/realtime" "github.com/matterbridge/Rocket.Chat.Go.SDK/rest" diff --git a/bridge/slack/handlers.go b/bridge/slack/handlers.go index 3ddacfd123..e6649a98d8 100644 --- a/bridge/slack/handlers.go +++ b/bridge/slack/handlers.go @@ -6,8 +6,8 @@ import ( "html" "time" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/bridge/helper" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/helper" "github.com/slack-go/slack" ) diff --git a/bridge/slack/helpers.go b/bridge/slack/helpers.go index 309b3af84e..c7c651c2ba 100644 --- a/bridge/slack/helpers.go +++ b/bridge/slack/helpers.go @@ -6,7 +6,7 @@ import ( "strings" "time" - "github.com/42wim/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/config" "github.com/sirupsen/logrus" "github.com/slack-go/slack" ) diff --git a/bridge/slack/helpers_test.go b/bridge/slack/helpers_test.go index fe3ba416c5..5e314d34a9 100644 --- a/bridge/slack/helpers_test.go +++ b/bridge/slack/helpers_test.go @@ -4,7 +4,7 @@ import ( "io/ioutil" "testing" - "github.com/42wim/matterbridge/bridge" + "github.com/matterbridge-org/matterbridge/bridge" "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" ) diff --git a/bridge/slack/legacy.go b/bridge/slack/legacy.go index d89d286d5e..8e94685bda 100644 --- a/bridge/slack/legacy.go +++ b/bridge/slack/legacy.go @@ -3,8 +3,8 @@ package bslack import ( "errors" - "github.com/42wim/matterbridge/bridge" - "github.com/42wim/matterbridge/matterhook" + "github.com/matterbridge-org/matterbridge/bridge" + "github.com/matterbridge-org/matterbridge/matterhook" "github.com/slack-go/slack" ) diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go index c39c60826d..8012ff794c 100644 --- a/bridge/slack/slack.go +++ b/bridge/slack/slack.go @@ -8,11 +8,11 @@ import ( "sync" "time" - "github.com/42wim/matterbridge/bridge" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/bridge/helper" - "github.com/42wim/matterbridge/matterhook" lru "github.com/hashicorp/golang-lru" + "github.com/matterbridge-org/matterbridge/bridge" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/helper" + "github.com/matterbridge-org/matterbridge/matterhook" "github.com/rs/xid" "github.com/slack-go/slack" ) @@ -74,7 +74,7 @@ func New(cfg *bridge.Config) bridge.Bridger { if token != "" && !strings.HasPrefix(token, "xoxb") { cfg.Log.Warn("Non-bot token detected. It is STRONGLY recommended to use a proper bot-token instead.") cfg.Log.Warn("Legacy tokens may be deprecated by Slack at short notice. See the Matterbridge GitHub wiki for a migration guide.") - cfg.Log.Warn("See https://github.com/42wim/matterbridge/wiki/Slack-bot-setup") + cfg.Log.Warn("See https://github.com/matterbridge-org/matterbridge/wiki/Slack-bot-setup") return NewLegacy(cfg) } return newBridge(cfg) diff --git a/bridge/slack/users_channels.go b/bridge/slack/users_channels.go index 85b944bd50..f98e9f02bb 100644 --- a/bridge/slack/users_channels.go +++ b/bridge/slack/users_channels.go @@ -7,7 +7,7 @@ import ( "sync" "time" - "github.com/42wim/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/config" "github.com/sirupsen/logrus" "github.com/slack-go/slack" ) diff --git a/bridge/sshchat/sshchat.go b/bridge/sshchat/sshchat.go index 6b78c22373..92dd34a3ed 100644 --- a/bridge/sshchat/sshchat.go +++ b/bridge/sshchat/sshchat.go @@ -5,9 +5,9 @@ import ( "io" "strings" - "github.com/42wim/matterbridge/bridge" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/bridge/helper" + "github.com/matterbridge-org/matterbridge/bridge" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/helper" "github.com/shazow/ssh-chat/sshd" ) diff --git a/bridge/telegram/handlers.go b/bridge/telegram/handlers.go index 8e7dc7ba81..26c3857949 100644 --- a/bridge/telegram/handlers.go +++ b/bridge/telegram/handlers.go @@ -8,9 +8,9 @@ import ( "strings" "unicode/utf16" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/bridge/helper" "github.com/davecgh/go-spew/spew" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/helper" tgbotapi "github.com/matterbridge/telegram-bot-api/v6" ) @@ -435,7 +435,7 @@ func (b *Btelegram) handleDownload(rmsg *config.Message, message *tgbotapi.Messa b.maybeConvertWebp(&name, data) } - // rename .oga to .ogg https://github.com/42wim/matterbridge/issues/906#issuecomment-741793512 + // rename .oga to .ogg https://github.com/matterbridge-org/matterbridge/issues/906#issuecomment-741793512 if strings.HasSuffix(name, ".oga") && message.Audio != nil { name = strings.Replace(name, ".oga", ".ogg", 1) } diff --git a/bridge/telegram/telegram.go b/bridge/telegram/telegram.go index e7885ca3e9..adc027ca59 100644 --- a/bridge/telegram/telegram.go +++ b/bridge/telegram/telegram.go @@ -7,9 +7,9 @@ import ( "strconv" "strings" - "github.com/42wim/matterbridge/bridge" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/bridge/helper" + "github.com/matterbridge-org/matterbridge/bridge" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/helper" tgbotapi "github.com/matterbridge/telegram-bot-api/v6" ) diff --git a/bridge/vk/vk.go b/bridge/vk/vk.go index 7faa5b40e9..be9f2a61e4 100644 --- a/bridge/vk/vk.go +++ b/bridge/vk/vk.go @@ -8,9 +8,9 @@ import ( "strings" "time" - "github.com/42wim/matterbridge/bridge" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/bridge/helper" + "github.com/matterbridge-org/matterbridge/bridge" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/helper" "github.com/SevereCloud/vksdk/v2/api" "github.com/SevereCloud/vksdk/v2/events" diff --git a/bridge/whatsapp/handlers.go b/bridge/whatsapp/handlers.go index 8f9fef15cd..fd9770901b 100644 --- a/bridge/whatsapp/handlers.go +++ b/bridge/whatsapp/handlers.go @@ -7,10 +7,10 @@ import ( "strings" "time" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/bridge/helper" "github.com/Rhymen/go-whatsapp" "github.com/jpillora/backoff" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/helper" ) /* @@ -23,8 +23,8 @@ Check: // HandleError received from WhatsApp func (b *Bwhatsapp) HandleError(err error) { - // ignore received invalid data errors. https://github.com/42wim/matterbridge/issues/843 - // ignore tag 174 errors. https://github.com/42wim/matterbridge/issues/1094 + // ignore received invalid data errors. https://github.com/matterbridge-org/matterbridge/issues/843 + // ignore tag 174 errors. https://github.com/matterbridge-org/matterbridge/issues/1094 if strings.Contains(err.Error(), "error processing data: received invalid data") || strings.Contains(err.Error(), "invalid string with tag 174") { return @@ -172,12 +172,12 @@ func (b *Bwhatsapp) HandleImageMessage(message whatsapp.ImageMessage) { return } - // rename .jfif to .jpg https://github.com/42wim/matterbridge/issues/1292 + // rename .jfif to .jpg https://github.com/matterbridge-org/matterbridge/issues/1292 if fileExt[0] == ".jfif" { fileExt[0] = ".jpg" } - // rename .jpe to .jpg https://github.com/42wim/matterbridge/issues/1463 + // rename .jpe to .jpg https://github.com/matterbridge-org/matterbridge/issues/1463 if fileExt[0] == ".jpe" { fileExt[0] = ".jpg" } diff --git a/bridge/whatsapp/whatsapp.go b/bridge/whatsapp/whatsapp.go index bb0dfe5767..b38c840783 100644 --- a/bridge/whatsapp/whatsapp.go +++ b/bridge/whatsapp/whatsapp.go @@ -12,9 +12,9 @@ import ( "strings" "time" - "github.com/42wim/matterbridge/bridge" - "github.com/42wim/matterbridge/bridge/config" "github.com/Rhymen/go-whatsapp" + "github.com/matterbridge-org/matterbridge/bridge" + "github.com/matterbridge-org/matterbridge/bridge/config" ) const ( @@ -42,7 +42,7 @@ func New(cfg *bridge.Config) bridge.Bridger { cfg.Log.Warn("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") cfg.Log.Warn("This bridge is deprecated and not supported anymore. Use the new multidevice whatsapp bridge") - cfg.Log.Warn("See https://github.com/42wim/matterbridge#building-with-whatsapp-beta-multidevice-support for more info") + cfg.Log.Warn("See https://github.com/matterbridge-org/matterbridge#building-with-whatsapp-beta-multidevice-support for more info") cfg.Log.Warn("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") if number == "" { @@ -170,7 +170,7 @@ func (b *Bwhatsapp) Disconnect() error { // JoinChannel Join a WhatsApp group specified in gateway config as channel='number-id@g.us' or channel='Channel name' // Required implementation of the Bridger interface -// https://github.com/42wim/matterbridge/blob/2cfd880cdb0df29771bf8f31df8d990ab897889d/bridge/bridge.go#L11-L16 +// https://github.com/matterbridge-org/matterbridge/blob/2cfd880cdb0df29771bf8f31df8d990ab897889d/bridge/bridge.go#L11-L16 func (b *Bwhatsapp) JoinChannel(channel config.ChannelInfo) error { byJid := isGroupJid(channel.Name) @@ -277,7 +277,7 @@ func (b *Bwhatsapp) PostImageMessage(msg config.Message, filetype string) (strin // Send a message from the bridge to WhatsApp // Required implementation of the Bridger interface -// https://github.com/42wim/matterbridge/blob/2cfd880cdb0df29771bf8f31df8d990ab897889d/bridge/bridge.go#L11-L16 +// https://github.com/matterbridge-org/matterbridge/blob/2cfd880cdb0df29771bf8f31df8d990ab897889d/bridge/bridge.go#L11-L16 func (b *Bwhatsapp) Send(msg config.Message) (string, error) { b.Log.Debugf("=> Receiving %#v", msg) diff --git a/bridge/whatsappmulti/handlers.go b/bridge/whatsappmulti/handlers.go index 90a7c7a667..3bb73b1e40 100644 --- a/bridge/whatsappmulti/handlers.go +++ b/bridge/whatsappmulti/handlers.go @@ -8,8 +8,8 @@ import ( "mime" "strings" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/bridge/helper" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/helper" "go.mau.fi/whatsmeow/binary/proto" "go.mau.fi/whatsmeow/types" @@ -228,12 +228,12 @@ func (b *Bwhatsapp) handleImageMessage(msg *events.Message) { return } - // rename .jfif to .jpg https://github.com/42wim/matterbridge/issues/1292 + // rename .jfif to .jpg https://github.com/matterbridge-org/matterbridge/issues/1292 if fileExt[0] == ".jfif" { fileExt[0] = ".jpg" } - // rename .jpe to .jpg https://github.com/42wim/matterbridge/issues/1463 + // rename .jpe to .jpg https://github.com/matterbridge-org/matterbridge/issues/1463 if fileExt[0] == ".jpe" { fileExt[0] = ".jpg" } diff --git a/bridge/whatsappmulti/whatsapp.go b/bridge/whatsappmulti/whatsapp.go index e7c0f691a4..3f0c71fc3a 100644 --- a/bridge/whatsappmulti/whatsapp.go +++ b/bridge/whatsappmulti/whatsapp.go @@ -12,8 +12,8 @@ import ( "path/filepath" "time" - "github.com/42wim/matterbridge/bridge" - "github.com/42wim/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge" + "github.com/matterbridge-org/matterbridge/bridge/config" "github.com/mdp/qrterminal" "go.mau.fi/whatsmeow" @@ -173,7 +173,7 @@ func (b *Bwhatsapp) Disconnect() error { // JoinChannel Join a WhatsApp group specified in gateway config as channel='number-id@g.us' or channel='Channel name' // Required implementation of the Bridger interface -// https://github.com/42wim/matterbridge/blob/2cfd880cdb0df29771bf8f31df8d990ab897889d/bridge/bridge.go#L11-L16 +// https://github.com/matterbridge-org/matterbridge/blob/2cfd880cdb0df29771bf8f31df8d990ab897889d/bridge/bridge.go#L11-L16 func (b *Bwhatsapp) JoinChannel(channel config.ChannelInfo) error { byJid := isGroupJid(channel.Name) diff --git a/bridge/xmpp/handler.go b/bridge/xmpp/handler.go index 5f56ccc3a2..dd7f578f2a 100644 --- a/bridge/xmpp/handler.go +++ b/bridge/xmpp/handler.go @@ -1,8 +1,8 @@ package bxmpp import ( - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/bridge/helper" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/helper" "github.com/xmppo/go-xmpp" ) diff --git a/bridge/xmpp/helpers.go b/bridge/xmpp/helpers.go index eb6a53660b..562d7052ca 100644 --- a/bridge/xmpp/helpers.go +++ b/bridge/xmpp/helpers.go @@ -3,7 +3,7 @@ package bxmpp import ( "regexp" - "github.com/42wim/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/config" ) var pathRegex = regexp.MustCompile("[^a-zA-Z0-9]+") diff --git a/bridge/xmpp/xmpp.go b/bridge/xmpp/xmpp.go index a5647710be..6b46690cc8 100644 --- a/bridge/xmpp/xmpp.go +++ b/bridge/xmpp/xmpp.go @@ -11,10 +11,10 @@ import ( "sync" "time" - "github.com/42wim/matterbridge/bridge" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/bridge/helper" "github.com/jpillora/backoff" + "github.com/matterbridge-org/matterbridge/bridge" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/helper" "github.com/rs/xid" "github.com/xmppo/go-xmpp" ) diff --git a/bridge/zulip/zulip.go b/bridge/zulip/zulip.go index 9b8b73c29e..a7c8b664c0 100644 --- a/bridge/zulip/zulip.go +++ b/bridge/zulip/zulip.go @@ -9,10 +9,10 @@ import ( "sync" "time" - "github.com/42wim/matterbridge/bridge" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/bridge/helper" - "github.com/42wim/matterbridge/version" + "github.com/matterbridge-org/matterbridge/bridge" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/helper" + "github.com/matterbridge-org/matterbridge/version" gzb "github.com/matterbridge/gozulipbot" ) diff --git a/contrib/api.yaml b/contrib/api.yaml index 328393f286..c0e6aa0ac5 100644 --- a/contrib/api.yaml +++ b/contrib/api.yaml @@ -4,7 +4,7 @@ info: description: A read/write API for the Matterbridge chat bridge. license: name: Apache 2.0 - url: 'https://github.com/42wim/matterbridge/blob/master/LICENSE' + url: 'https://github.com/matterbridge-org/matterbridge/blob/master/LICENSE' title: Matterbridge API version: "0.1.0-oas3" paths: @@ -77,7 +77,7 @@ components: event: description: >- A specific matterbridge event. (see - https://github.com/42wim/matterbridge/blob/master/bridge/config/config.go#L16) + https://github.com/matterbridge-org/matterbridge/blob/master/bridge/config/config.go#L16) type: string gateway: description: Name of the gateway as configured in matterbridge.toml @@ -132,7 +132,7 @@ components: event: description: >- A specific matterbridge event. (see - https://github.com/42wim/matterbridge/blob/master/bridge/config/config.go#L16) + https://github.com/matterbridge-org/matterbridge/blob/master/bridge/config/config.go#L16) example: "" type: string gateway: @@ -162,7 +162,7 @@ components: event: description: >- A specific matterbridge event. (see - https://github.com/42wim/matterbridge/blob/master/bridge/config/config.go#L16) + https://github.com/matterbridge-org/matterbridge/blob/master/bridge/config/config.go#L16) example: "" type: string gateway: diff --git a/contrib/example.tengo b/contrib/example.tengo index da4eede633..cd61e1e69e 100644 --- a/contrib/example.tengo +++ b/contrib/example.tengo @@ -1,2 +1,2 @@ text := import("text") -msgText=text.re_replace("matterbridge",msgText,"matterbridge (https://github.com/42wim/matterbridge)") +msgText=text.re_replace("matterbridge",msgText,"matterbridge (https://github.com/matterbridge-org/matterbridge)") diff --git a/docker/arm/Dockerfile b/docker/arm/Dockerfile index 8c7f94bc38..82f056812d 100644 --- a/docker/arm/Dockerfile +++ b/docker/arm/Dockerfile @@ -1,7 +1,7 @@ FROM alpine:edge as certs RUN apk --update add ca-certificates ARG VERSION=1.22.3 -ADD https://github.com/42wim/matterbridge/releases/download/v${VERSION}/matterbridge-${VERSION}-linux-arm64 /bin/matterbridge +ADD https://github.com/matterbridge-org/matterbridge/releases/download/v${VERSION}/matterbridge-${VERSION}-linux-arm64 /bin/matterbridge RUN chmod +x /bin/matterbridge FROM scratch diff --git a/gateway/bridgemap/api.go b/gateway/bridgemap/api.go index b602811a87..1ed09de331 100644 --- a/gateway/bridgemap/api.go +++ b/gateway/bridgemap/api.go @@ -4,7 +4,7 @@ package bridgemap import ( - "github.com/42wim/matterbridge/bridge/api" + "github.com/matterbridge-org/matterbridge/bridge/api" ) func init() { diff --git a/gateway/bridgemap/bdiscord.go b/gateway/bridgemap/bdiscord.go index 81c4ff7576..6a6f1a345e 100644 --- a/gateway/bridgemap/bdiscord.go +++ b/gateway/bridgemap/bdiscord.go @@ -4,7 +4,7 @@ package bridgemap import ( - bdiscord "github.com/42wim/matterbridge/bridge/discord" + bdiscord "github.com/matterbridge-org/matterbridge/bridge/discord" ) func init() { diff --git a/gateway/bridgemap/birc.go b/gateway/bridgemap/birc.go index 9ce2eba2e8..e2fa80502a 100644 --- a/gateway/bridgemap/birc.go +++ b/gateway/bridgemap/birc.go @@ -4,7 +4,7 @@ package bridgemap import ( - birc "github.com/42wim/matterbridge/bridge/irc" + birc "github.com/matterbridge-org/matterbridge/bridge/irc" ) func init() { diff --git a/gateway/bridgemap/bmastodon.go b/gateway/bridgemap/bmastodon.go index 2773e24799..354f4ff34d 100644 --- a/gateway/bridgemap/bmastodon.go +++ b/gateway/bridgemap/bmastodon.go @@ -4,7 +4,7 @@ package bridgemap import ( - bmastodon "github.com/42wim/matterbridge/bridge/mastodon" + bmastodon "github.com/matterbridge-org/matterbridge/bridge/mastodon" ) func init() { diff --git a/gateway/bridgemap/bmatrix.go b/gateway/bridgemap/bmatrix.go index 9b299f7ec8..eacc27ddd2 100644 --- a/gateway/bridgemap/bmatrix.go +++ b/gateway/bridgemap/bmatrix.go @@ -4,7 +4,7 @@ package bridgemap import ( - bmatrix "github.com/42wim/matterbridge/bridge/matrix" + bmatrix "github.com/matterbridge-org/matterbridge/bridge/matrix" ) func init() { diff --git a/gateway/bridgemap/bmattermost.go b/gateway/bridgemap/bmattermost.go index 8a80e32250..307e3464fe 100644 --- a/gateway/bridgemap/bmattermost.go +++ b/gateway/bridgemap/bmattermost.go @@ -4,7 +4,7 @@ package bridgemap import ( - bmattermost "github.com/42wim/matterbridge/bridge/mattermost" + bmattermost "github.com/matterbridge-org/matterbridge/bridge/mattermost" ) func init() { diff --git a/gateway/bridgemap/bmsteams.go b/gateway/bridgemap/bmsteams.go index e43c1d9178..6cfd8aa638 100644 --- a/gateway/bridgemap/bmsteams.go +++ b/gateway/bridgemap/bmsteams.go @@ -4,7 +4,7 @@ package bridgemap import ( - bmsteams "github.com/42wim/matterbridge/bridge/msteams" + bmsteams "github.com/matterbridge-org/matterbridge/bridge/msteams" ) func init() { diff --git a/gateway/bridgemap/bmumble.go b/gateway/bridgemap/bmumble.go index 2b9c93b641..4bb8a5ab55 100644 --- a/gateway/bridgemap/bmumble.go +++ b/gateway/bridgemap/bmumble.go @@ -4,7 +4,7 @@ package bridgemap import ( - bmumble "github.com/42wim/matterbridge/bridge/mumble" + bmumble "github.com/matterbridge-org/matterbridge/bridge/mumble" ) func init() { diff --git a/gateway/bridgemap/bnctalk.go b/gateway/bridgemap/bnctalk.go index b675725b93..03d31de8c1 100644 --- a/gateway/bridgemap/bnctalk.go +++ b/gateway/bridgemap/bnctalk.go @@ -4,7 +4,7 @@ package bridgemap import ( - btalk "github.com/42wim/matterbridge/bridge/nctalk" + btalk "github.com/matterbridge-org/matterbridge/bridge/nctalk" ) func init() { diff --git a/gateway/bridgemap/bridgemap.go b/gateway/bridgemap/bridgemap.go index 885146959e..f3ecc6a072 100644 --- a/gateway/bridgemap/bridgemap.go +++ b/gateway/bridgemap/bridgemap.go @@ -1,7 +1,7 @@ package bridgemap import ( - "github.com/42wim/matterbridge/bridge" + "github.com/matterbridge-org/matterbridge/bridge" ) var ( diff --git a/gateway/bridgemap/brocketchat.go b/gateway/bridgemap/brocketchat.go index ad173a4490..c7096485ab 100644 --- a/gateway/bridgemap/brocketchat.go +++ b/gateway/bridgemap/brocketchat.go @@ -4,7 +4,7 @@ package bridgemap import ( - brocketchat "github.com/42wim/matterbridge/bridge/rocketchat" + brocketchat "github.com/matterbridge-org/matterbridge/bridge/rocketchat" ) func init() { diff --git a/gateway/bridgemap/bslack.go b/gateway/bridgemap/bslack.go index a4dd6a52a7..2efbb26a1f 100644 --- a/gateway/bridgemap/bslack.go +++ b/gateway/bridgemap/bslack.go @@ -4,7 +4,7 @@ package bridgemap import ( - bslack "github.com/42wim/matterbridge/bridge/slack" + bslack "github.com/matterbridge-org/matterbridge/bridge/slack" ) func init() { diff --git a/gateway/bridgemap/bsshchat.go b/gateway/bridgemap/bsshchat.go index 650c2a624d..5423d52b5e 100644 --- a/gateway/bridgemap/bsshchat.go +++ b/gateway/bridgemap/bsshchat.go @@ -4,7 +4,7 @@ package bridgemap import ( - bsshchat "github.com/42wim/matterbridge/bridge/sshchat" + bsshchat "github.com/matterbridge-org/matterbridge/bridge/sshchat" ) func init() { diff --git a/gateway/bridgemap/btelegram.go b/gateway/bridgemap/btelegram.go index dbff2bc6ea..81e7382fd3 100644 --- a/gateway/bridgemap/btelegram.go +++ b/gateway/bridgemap/btelegram.go @@ -4,7 +4,7 @@ package bridgemap import ( - btelegram "github.com/42wim/matterbridge/bridge/telegram" + btelegram "github.com/matterbridge-org/matterbridge/bridge/telegram" ) func init() { diff --git a/gateway/bridgemap/bvk.go b/gateway/bridgemap/bvk.go index f0496220ea..fe83ed3936 100644 --- a/gateway/bridgemap/bvk.go +++ b/gateway/bridgemap/bvk.go @@ -4,7 +4,7 @@ package bridgemap import ( - bvk "github.com/42wim/matterbridge/bridge/vk" + bvk "github.com/matterbridge-org/matterbridge/bridge/vk" ) func init() { diff --git a/gateway/bridgemap/bwhatsapp.go b/gateway/bridgemap/bwhatsapp.go index d808c814d8..42dfb2d9f6 100644 --- a/gateway/bridgemap/bwhatsapp.go +++ b/gateway/bridgemap/bwhatsapp.go @@ -4,7 +4,7 @@ package bridgemap import ( - bwhatsapp "github.com/42wim/matterbridge/bridge/whatsapp" + bwhatsapp "github.com/matterbridge-org/matterbridge/bridge/whatsapp" ) func init() { diff --git a/gateway/bridgemap/bwhatsappmulti.go b/gateway/bridgemap/bwhatsappmulti.go index 2e098e2491..646499dfad 100644 --- a/gateway/bridgemap/bwhatsappmulti.go +++ b/gateway/bridgemap/bwhatsappmulti.go @@ -4,7 +4,7 @@ package bridgemap import ( - bwhatsapp "github.com/42wim/matterbridge/bridge/whatsappmulti" + bwhatsapp "github.com/matterbridge-org/matterbridge/bridge/whatsappmulti" ) func init() { diff --git a/gateway/bridgemap/bxmpp.go b/gateway/bridgemap/bxmpp.go index aa60938c2e..89d6489f4e 100644 --- a/gateway/bridgemap/bxmpp.go +++ b/gateway/bridgemap/bxmpp.go @@ -4,7 +4,7 @@ package bridgemap import ( - bxmpp "github.com/42wim/matterbridge/bridge/xmpp" + bxmpp "github.com/matterbridge-org/matterbridge/bridge/xmpp" ) func init() { diff --git a/gateway/bridgemap/bzulip.go b/gateway/bridgemap/bzulip.go index f3105c65d8..f24e59341f 100644 --- a/gateway/bridgemap/bzulip.go +++ b/gateway/bridgemap/bzulip.go @@ -4,7 +4,7 @@ package bridgemap import ( - bzulip "github.com/42wim/matterbridge/bridge/zulip" + bzulip "github.com/matterbridge-org/matterbridge/bridge/zulip" ) func init() { diff --git a/gateway/gateway.go b/gateway/gateway.go index a2d572be67..50ba966c02 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -8,13 +8,13 @@ import ( "strings" "time" - "github.com/42wim/matterbridge/bridge" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/internal" "github.com/d5/tengo/v2" "github.com/d5/tengo/v2/stdlib" lru "github.com/hashicorp/golang-lru" "github.com/kyokomi/emoji/v2" + "github.com/matterbridge-org/matterbridge/bridge" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/internal" "github.com/sirupsen/logrus" ) diff --git a/gateway/gateway_test.go b/gateway/gateway_test.go index c1e4ab9989..c0a2980d52 100644 --- a/gateway/gateway_test.go +++ b/gateway/gateway_test.go @@ -6,8 +6,8 @@ import ( "strconv" "testing" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/gateway/bridgemap" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/gateway/bridgemap" "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" diff --git a/gateway/handlers.go b/gateway/handlers.go index 44cefe4506..2f26103844 100644 --- a/gateway/handlers.go +++ b/gateway/handlers.go @@ -12,9 +12,9 @@ import ( "strings" "time" - "github.com/42wim/matterbridge/bridge" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/gateway/bridgemap" + "github.com/matterbridge-org/matterbridge/bridge" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/gateway/bridgemap" ) // handleEventFailure handles failures and reconnects bridges. diff --git a/gateway/handlers_test.go b/gateway/handlers_test.go index 20a7cfcd41..1ca109399c 100644 --- a/gateway/handlers_test.go +++ b/gateway/handlers_test.go @@ -1,8 +1,8 @@ package gateway import ( - "github.com/42wim/matterbridge/bridge" - "github.com/42wim/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge" + "github.com/matterbridge-org/matterbridge/bridge/config" "github.com/stretchr/testify/assert" "testing" diff --git a/gateway/router.go b/gateway/router.go index a0d5f40208..08e9e47636 100644 --- a/gateway/router.go +++ b/gateway/router.go @@ -5,9 +5,9 @@ import ( "sync" "time" - "github.com/42wim/matterbridge/bridge" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/gateway/samechannel" + "github.com/matterbridge-org/matterbridge/bridge" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/gateway/samechannel" "github.com/sirupsen/logrus" ) @@ -60,12 +60,12 @@ func NewRouter(rootLogger *logrus.Logger, cfg config.Config, bridgeMap map[strin func (r *Router) Start() error { m := make(map[string]*bridge.Bridge) if len(r.Gateways) == 0 { - return fmt.Errorf("no [[gateway]] configured. See https://github.com/42wim/matterbridge/wiki/How-to-create-your-config for more info") + return fmt.Errorf("no [[gateway]] configured. See https://github.com/matterbridge-org/matterbridge/wiki/How-to-create-your-config for more info") } for _, gw := range r.Gateways { r.logger.Infof("Parsing gateway %s", gw.Name) if len(gw.Bridges) == 0 { - return fmt.Errorf("no bridges configured for gateway %s. See https://github.com/42wim/matterbridge/wiki/How-to-create-your-config for more info", gw.Name) + return fmt.Errorf("no bridges configured for gateway %s. See https://github.com/matterbridge-org/matterbridge/wiki/How-to-create-your-config for more info", gw.Name) } for _, br := range gw.Bridges { m[br.Account] = br diff --git a/gateway/samechannel/samechannel.go b/gateway/samechannel/samechannel.go index 4b6016c621..c52ed513af 100644 --- a/gateway/samechannel/samechannel.go +++ b/gateway/samechannel/samechannel.go @@ -1,7 +1,7 @@ package samechannel import ( - "github.com/42wim/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/config" ) type SameChannelGateway struct { diff --git a/gateway/samechannel/samechannel_test.go b/gateway/samechannel/samechannel_test.go index 17d816a9b5..1bed9cfa41 100644 --- a/gateway/samechannel/samechannel_test.go +++ b/gateway/samechannel/samechannel_test.go @@ -4,7 +4,7 @@ import ( "io/ioutil" "testing" - "github.com/42wim/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/bridge/config" "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" ) diff --git a/go.mod b/go.mod index 009532a2f0..827f3cbada 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/42wim/matterbridge +module github.com/matterbridge-org/matterbridge require ( github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f diff --git a/matterbridge.go b/matterbridge.go index 812f44071f..b762e75cb0 100644 --- a/matterbridge.go +++ b/matterbridge.go @@ -7,11 +7,11 @@ import ( "runtime" "strings" - "github.com/42wim/matterbridge/bridge/config" - "github.com/42wim/matterbridge/gateway" - "github.com/42wim/matterbridge/gateway/bridgemap" - "github.com/42wim/matterbridge/version" "github.com/google/gops/agent" + "github.com/matterbridge-org/matterbridge/bridge/config" + "github.com/matterbridge-org/matterbridge/gateway" + "github.com/matterbridge-org/matterbridge/gateway/bridgemap" + "github.com/matterbridge-org/matterbridge/version" prefixed "github.com/matterbridge/logrus-prefixed-formatter" "github.com/sirupsen/logrus" ) diff --git a/tgs.Dockerfile b/tgs.Dockerfile index e093531d14..b43b147b3b 100644 --- a/tgs.Dockerfile +++ b/tgs.Dockerfile @@ -5,7 +5,7 @@ RUN apk add \ go \ git \ && cd /go/src/matterbridge \ - && CGO_ENABLED=0 go build -mod vendor -ldflags "-X github.com/42wim/matterbridge/version.GitHash=$(git log --pretty=format:'%h' -n 1)" -o /bin/matterbridge + && CGO_ENABLED=0 go build -mod vendor -ldflags "-X github.com/matterbridge-org/matterbridge/version.GitHash=$(git log --pretty=format:'%h' -n 1)" -o /bin/matterbridge FROM alpine RUN apk --no-cache add \ From 58004846bdef6bef2f9c6da02016cd1119390582 Mon Sep 17 00:00:00 2001 From: "Lucian I. Last" Date: Wed, 19 Nov 2025 18:20:45 +0100 Subject: [PATCH 05/10] Add documentation --- docs/protocols/mastodon/README.md | 41 ++++++++++++++++++++++++++ docs/protocols/mastodon/application.md | 28 ++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 docs/protocols/mastodon/README.md create mode 100644 docs/protocols/mastodon/application.md diff --git a/docs/protocols/mastodon/README.md b/docs/protocols/mastodon/README.md new file mode 100644 index 0000000000..1ef1e6eb5f --- /dev/null +++ b/docs/protocols/mastodon/README.md @@ -0,0 +1,41 @@ +# Mastodon + +- Status: Working +- Maintainers: @lil5 +- Features: home, local, remote, direct toots + +## Configuration + +> [!TIP] +> For detailed information about mastodon settings, see [settings.md](settings.md) + +**Basic configuration example:** + +```toml +[mastodon] +[mastodon.mymastodon] +Server="https://mastodon.social" +ClientID="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +ClientSecret="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +AccessToken="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +``` + +## FAQ + +### How to connect to a list? + +Currently the only supported lists are: home, local, remote + +```toml +[[gateway.inout]] +account="mastodon.mymastodon" +channel="home" +``` + +### How to connect to a direct message? + +```toml +[[gateway.inout]] +account="mastodon.mymastodon" +channel="@name@mastodon.social" +``` \ No newline at end of file diff --git a/docs/protocols/mastodon/application.md b/docs/protocols/mastodon/application.md new file mode 100644 index 0000000000..c4cab9f61f --- /dev/null +++ b/docs/protocols/mastodon/application.md @@ -0,0 +1,28 @@ +# Add application to mastodon + +1. Create an mastodon Application + + Go to this url, change the domain to your mastodon website: https://mastodon.social/settings/applications/new + +2. Set the following values: + + **Application name:** `MatterBridge` + + **Redirect URL:** `urn:ietf:wg:oauth:2.0:oob` + + **Scopes:** + + Check the following: `read`, `profile`, `write:conversations`, `write:statuses` + + Then, save changes. + +3. Copy tokens to matterbridge.toml + + ```toml + [mastodon] + [mastodon.mymastodon] + Server = "https://mastodon.social" + ClientID = "" + ClientSecret = "" + AccessToken = "" + ``` From 05d692846d9d3bd8c879c64dcec5aec33f579283 Mon Sep 17 00:00:00 2001 From: "Lucian I. Last" Date: Wed, 19 Nov 2025 18:26:10 +0100 Subject: [PATCH 06/10] more docs --- docs/protocols/README.md | 4 ++++ docs/protocols/mastodon/README.md | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/protocols/README.md b/docs/protocols/README.md index c853b316f3..94514d11ee 100644 --- a/docs/protocols/README.md +++ b/docs/protocols/README.md @@ -21,6 +21,10 @@ Matterbridge supports many protocols, although not all of them support all featu - [xmpp docs](xmpp/) - [xmpp settings](xmpp/settings.md) - Channel format: `channel_name` (for `channel_name@muc.server.org` where `muc.server.org` has been configured as `Muc` for the corresponding xmpp account) +- [Mastodon](https://joinmastodon.org/) + - Matterbridge docs: + - [mastodon docs](mastodon/) + - [mastodon application](mastodon/application.md) - [Matrix](https://matrix.org) - Matterbridge docs: - [matrix docs](matrix/) diff --git a/docs/protocols/mastodon/README.md b/docs/protocols/mastodon/README.md index 1ef1e6eb5f..51dfd773c6 100644 --- a/docs/protocols/mastodon/README.md +++ b/docs/protocols/mastodon/README.md @@ -7,7 +7,7 @@ ## Configuration > [!TIP] -> For detailed information about mastodon settings, see [settings.md](settings.md) +> For help getting a client id/secret/access token, see [application.md](application.md) **Basic configuration example:** From 94c93144eb958ead2e943c62dd211aa2f993942d Mon Sep 17 00:00:00 2001 From: "Lucian I. Last" Date: Thu, 20 Nov 2025 13:48:01 +0100 Subject: [PATCH 07/10] Golang ci now works for all code --- .golangci.yaml | 9 +- bridge/config/config.go | 9 +- bridge/discord/discord.go | 6 +- bridge/discord/handlers.go | 38 ++++---- bridge/helper/helper.go | 6 +- bridge/helper/helper_test.go | 5 +- bridge/helper/lottie_convert.go | 9 +- bridge/irc/handlers.go | 4 +- bridge/irc/irc.go | 9 +- bridge/mastodon/mastodon.go | 110 +++++++++++------------- bridge/matrix/matrix.go | 16 ++-- bridge/mattermost/helpers.go | 9 +- bridge/mattermost/mattermost.go | 2 +- bridge/msteams/handler.go | 4 +- bridge/msteams/msteams.go | 4 +- bridge/mumble/handlers.go | 6 +- bridge/mumble/helpers.go | 6 +- bridge/mumble/mumble.go | 4 +- bridge/rocketchat/helpers.go | 4 +- bridge/slack/helpers.go | 2 +- bridge/slack/helpers_test.go | 4 +- bridge/slack/slack.go | 2 +- bridge/telegram/handlers.go | 6 +- bridge/telegram/telegram.go | 2 +- bridge/vk/vk.go | 2 +- bridge/whatsapp/helpers.go | 4 +- bridge/whatsappmulti/handlers.go | 1 - bridge/whatsappmulti/helpers.go | 1 - bridge/whatsappmulti/whatsapp.go | 1 - bridge/xmpp/xmpp.go | 2 +- bridge/zulip/zulip.go | 4 +- gateway/bridgemap/api.go | 1 - gateway/bridgemap/bdiscord.go | 1 - gateway/bridgemap/birc.go | 1 - gateway/bridgemap/bmastodon.go | 1 - gateway/bridgemap/bmatrix.go | 1 - gateway/bridgemap/bmattermost.go | 1 - gateway/bridgemap/bmsteams.go | 1 - gateway/bridgemap/bmumble.go | 1 - gateway/bridgemap/bnctalk.go | 1 - gateway/bridgemap/brocketchat.go | 1 - gateway/bridgemap/bslack.go | 1 - gateway/bridgemap/bsshchat.go | 1 - gateway/bridgemap/btelegram.go | 1 - gateway/bridgemap/bvk.go | 1 - gateway/bridgemap/bwhatsapp.go | 1 - gateway/bridgemap/bwhatsappmulti.go | 1 - gateway/bridgemap/bxmpp.go | 1 - gateway/bridgemap/bzulip.go | 1 - gateway/gateway.go | 9 +- gateway/gateway_test.go | 6 +- gateway/handlers.go | 3 +- gateway/router.go | 4 +- gateway/samechannel/samechannel_test.go | 4 +- hook/rockethook/rockethook.go | 4 +- matterhook/matterhook.go | 13 ++- 56 files changed, 161 insertions(+), 191 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 692a59a16a..40447153e1 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -23,7 +23,7 @@ output: # linters that we should / shouldn't run linters: - default: all + default: standard disable: - gochecknoglobals - lll @@ -32,7 +32,12 @@ linters: - godox - testpackage - godot + - errcheck + - containedctx + - unused - goheader + - wsl_v5 + - gochecknoinits - noctx - errorlint - nlreturn @@ -65,6 +70,8 @@ linters: # all available settings of specific linters, we can set an option for # a given linter even if we deactivate that same linter at runtime settings: + staticcheck: + checks: [ "all", "-QF1001", "-ST1020", "-ST1000"] errcheck: # report about not checking of errors in type assertions: `a := b.(MyStruct)`; # default is false: such cases aren't reported by default. diff --git a/bridge/config/config.go b/bridge/config/config.go index 23ad83fc0b..2303c56857 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -2,7 +2,6 @@ package config import ( "bytes" - "io/ioutil" "os" "path/filepath" "strings" @@ -260,7 +259,7 @@ func NewConfig(rootLogger *logrus.Logger, cfgfile string) Config { logger := rootLogger.WithFields(logrus.Fields{"prefix": "config"}) viper.SetConfigFile(cfgfile) - input, err := ioutil.ReadFile(cfgfile) + input, err := os.ReadFile(cfgfile) if err != nil { logger.Fatalf("Failed to read configuration file: %#v", err) } @@ -386,9 +385,9 @@ func GetIconURL(msg *Message, iconURL string) string { info := strings.Split(msg.Account, ".") protocol := info[0] name := info[1] - iconURL = strings.Replace(iconURL, "{NICK}", msg.Username, -1) - iconURL = strings.Replace(iconURL, "{BRIDGE}", name, -1) - iconURL = strings.Replace(iconURL, "{PROTOCOL}", protocol, -1) + iconURL = strings.ReplaceAll(iconURL, "{NICK}", msg.Username) + iconURL = strings.ReplaceAll(iconURL, "{BRIDGE}", name) + iconURL = strings.ReplaceAll(iconURL, "{PROTOCOL}", protocol) return iconURL } diff --git a/bridge/discord/discord.go b/bridge/discord/discord.go index 0192fe4add..8bb4a87eec 100644 --- a/bridge/discord/discord.go +++ b/bridge/discord/discord.go @@ -73,7 +73,7 @@ func (b *Bdiscord) Connect() error { } // if we have a User token, remove the `Bot` prefix if strings.HasPrefix(b.GetString("Token"), "User ") { - token = strings.Replace(b.GetString("Token"), "User ", "", -1) + token = strings.ReplaceAll(b.GetString("Token"), "User ", "") } b.c, err = discordgo.New(token) @@ -98,7 +98,7 @@ func (b *Bdiscord) Connect() error { if err != nil { return err } - serverName := strings.Replace(b.GetString("Server"), "ID:", "", -1) + serverName := strings.ReplaceAll(b.GetString("Server"), "ID:", "") b.nick = userinfo.Username b.userID = userinfo.ID @@ -255,7 +255,7 @@ func (b *Bdiscord) Send(msg config.Message) (string, error) { channelID := b.getChannelID(msg.Channel) if channelID == "" { - return "", fmt.Errorf("Could not find channelID for %v", msg.Channel) + return "", fmt.Errorf("could not find channelID for %v", msg.Channel) } if msg.Event == config.EventUserTyping { diff --git a/bridge/discord/handlers.go b/bridge/discord/handlers.go index b969122cbc..ba81a47c80 100644 --- a/bridge/discord/handlers.go +++ b/bridge/discord/handlers.go @@ -72,7 +72,7 @@ func (b *Bdiscord) messageUpdate(s *discordgo.Session, m *discordgo.MessageUpdat return } // only when message is actually edited - if m.Message.EditedTimestamp != nil { + if m.EditedTimestamp != nil { b.Log.Debugf("Sending edit message") m.Content += b.GetString("EditSuffix") msg := &discordgo.MessageCreate{ @@ -110,7 +110,7 @@ func (b *Bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreat b.Log.Debugf("== Receiving event %#v", m.Message) if m.Content != "" { - m.Message.Content = b.replaceChannelMentions(m.Message.Content) + m.Content = b.replaceChannelMentions(m.Content) rmsg.Text, err = m.ContentWithMoreMentionsReplaced(b.c) if err != nil { b.Log.Errorf("ContentWithMoreMentionsReplaced failed: %s", err) @@ -132,8 +132,8 @@ func (b *Bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreat } // if we have embedded content add it to text - if b.GetBool("ShowEmbeds") && m.Message.Embeds != nil { - for _, embed := range m.Message.Embeds { + if b.GetBool("ShowEmbeds") && m.Embeds != nil { + for _, embed := range m.Embeds { rmsg.Text += handleEmbed(embed) } } @@ -175,22 +175,22 @@ func (b *Bdiscord) memberUpdate(s *discordgo.Session, m *discordgo.GuildMemberUp b.membersMutex.Lock() defer b.membersMutex.Unlock() - if currMember, ok := b.userMemberMap[m.Member.User.ID]; ok { + if currMember, ok := b.userMemberMap[m.User.ID]; ok { b.Log.Debugf( "%s: memberupdate: user %s (nick %s) changes nick to %s", b.Account, - m.Member.User.Username, - b.userMemberMap[m.Member.User.ID].Nick, - m.Member.Nick, + m.User.Username, + b.userMemberMap[m.User.ID].Nick, + m.Nick, ) delete(b.nickMemberMap, currMember.User.Username) delete(b.nickMemberMap, currMember.Nick) - delete(b.userMemberMap, m.Member.User.ID) + delete(b.userMemberMap, m.User.ID) } - b.userMemberMap[m.Member.User.ID] = m.Member - b.nickMemberMap[m.Member.User.Username] = m.Member - if m.Member.Nick != "" { - b.nickMemberMap[m.Member.Nick] = m.Member + b.userMemberMap[m.User.ID] = m.Member + b.nickMemberMap[m.User.Username] = m.Member + if m.Nick != "" { + b.nickMemberMap[m.Nick] = m.Member } } @@ -206,9 +206,9 @@ func (b *Bdiscord) memberAdd(s *discordgo.Session, m *discordgo.GuildMemberAdd) b.Log.Warnf("Received member update with no member information: %#v", m) return } - username := m.Member.User.Username - if m.Member.Nick != "" { - username = m.Member.Nick + username := m.User.Username + if m.Nick != "" { + username = m.Nick } rmsg := config.Message{ @@ -234,9 +234,9 @@ func (b *Bdiscord) memberRemove(s *discordgo.Session, m *discordgo.GuildMemberRe b.Log.Warnf("Received member update with no member information: %#v", m) return } - username := m.Member.User.Username - if m.Member.Nick != "" { - username = m.Member.Nick + username := m.User.Username + if m.Nick != "" { + username = m.Nick } rmsg := config.Message{ diff --git a/bridge/helper/helper.go b/bridge/helper/helper.go index 9f3a47076c..005b245af6 100644 --- a/bridge/helper/helper.go +++ b/bridge/helper/helper.go @@ -155,11 +155,11 @@ func HandleDownloadSize(logger *logrus.Entry, msg *config.Message, name string, continue } if re.MatchString(name) { - return fmt.Errorf("Matching blacklist %s. Not downloading %s", entry, name) + return fmt.Errorf("matching blacklist %s. Not downloading %s", entry, name) } } } - logger.Debugf("Trying to download %#v with size %#v", name, size) + logger.Debugf("Trying to download %s with size %d", name, size) if int(size) > general.MediaDownloadSize { msg.Event = config.EventFileFailureSize msg.Extra[msg.Event] = append(msg.Extra[msg.Event], config.FileInfo{ @@ -167,7 +167,7 @@ func HandleDownloadSize(logger *logrus.Entry, msg *config.Message, name string, Comment: msg.Text, Size: size, }) - return fmt.Errorf("File %#v to large to download (%#v). MediaDownloadSize is %#v", name, size, general.MediaDownloadSize) + return fmt.Errorf("file %s to large to download (%d). MediaDownloadSize is %d", name, size, general.MediaDownloadSize) } return nil } diff --git a/bridge/helper/helper_test.go b/bridge/helper/helper_test.go index 6823de6b2c..7c9ca669ed 100644 --- a/bridge/helper/helper_test.go +++ b/bridge/helper/helper_test.go @@ -1,7 +1,6 @@ package helper import ( - "io/ioutil" "os" "testing" @@ -118,7 +117,7 @@ func TestConvertWebPToPNG(t *testing.T) { t.Skip() } - input, err := ioutil.ReadFile("test.webp") + input, err := os.ReadFile("test.webp") if err != nil { t.Fail() } @@ -129,7 +128,7 @@ func TestConvertWebPToPNG(t *testing.T) { t.Fail() } - err = ioutil.WriteFile("test.png", *d, 0o644) // nolint:gosec + err = os.WriteFile("test.png", *d, 0o644) // nolint:gosec if err != nil { t.Fail() } diff --git a/bridge/helper/lottie_convert.go b/bridge/helper/lottie_convert.go index ffbe95d754..514ec0cee3 100644 --- a/bridge/helper/lottie_convert.go +++ b/bridge/helper/lottie_convert.go @@ -3,7 +3,6 @@ package helper import ( - "io/ioutil" "os" "os/exec" @@ -23,7 +22,7 @@ func CanConvertTgsToX() error { // This relies on an external command, which is ugly, but works. func ConvertTgsToX(data *[]byte, outputFormat string, logger *logrus.Entry) error { // lottie can't handle input from a pipe, so write to a temporary file: - tmpInFile, err := ioutil.TempFile(os.TempDir(), "matterbridge-lottie-input-*.tgs") + tmpInFile, err := os.CreateTemp("", "matterbridge-lottie-input-*.tgs") if err != nil { return err } @@ -35,7 +34,7 @@ func ConvertTgsToX(data *[]byte, outputFormat string, logger *logrus.Entry) erro }() // lottie can handle writing to a pipe, but there is no way to do that platform-independently. // "/dev/stdout" won't work on Windows, and "-" upsets Cairo for some reason. So we need another file: - tmpOutFile, err := ioutil.TempFile(os.TempDir(), "matterbridge-lottie-output-*.data") + tmpOutFile, err := os.CreateTemp("", "matterbridge-lottie-output-*.data") if err != nil { return err } @@ -64,7 +63,7 @@ func ConvertTgsToX(data *[]byte, outputFormat string, logger *logrus.Entry) erro // 'stderr' already contains some parts of Stderr, because it was set to 'nil'. return stderr } - dataContents, err := ioutil.ReadFile(tmpOutFileName) + dataContents, err := os.ReadFile(tmpOutFileName) if err != nil { return err } @@ -79,8 +78,6 @@ func SupportsFormat(format string) bool { fallthrough case "webp": return true - default: - return false } return false } diff --git a/bridge/irc/handlers.go b/bridge/irc/handlers.go index e9d79aa052..fbf625b3ee 100644 --- a/bridge/irc/handlers.go +++ b/bridge/irc/handlers.go @@ -3,7 +3,7 @@ package birc import ( "bytes" "fmt" - "io/ioutil" + "io" "strconv" "strings" "time" @@ -247,7 +247,7 @@ func (b *Birc) handlePrivMsg(client *girc.Client, event girc.Event) { b.Log.Errorf("charset to utf-8 conversion failed: %s", err) return } - output, _ := ioutil.ReadAll(r) + output, _ := io.ReadAll(r) rmsg.Text = string(output) } diff --git a/bridge/irc/irc.go b/bridge/irc/irc.go index cf978c410d..5855563703 100644 --- a/bridge/irc/irc.go +++ b/bridge/irc/irc.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" "hash/crc32" - "io/ioutil" + "io" "net" "sort" "strconv" @@ -122,10 +122,7 @@ func (b *Birc) Disconnect() error { func (b *Birc) JoinChannel(channel config.ChannelInfo) error { b.channels[channel.Name] = true // need to check if we have nickserv auth done before joining channels - for { - if b.authDone { - break - } + for !b.authDone { time.Sleep(time.Second) } if channel.Options.Key != "" { @@ -293,7 +290,7 @@ func (b *Birc) getClient() (*girc.Client, error) { realName = b.GetString("Nick") } - debug := ioutil.Discard + debug := io.Discard if b.GetInt("DebugLevel") == 2 { debug = b.Log.Writer() } diff --git a/bridge/mastodon/mastodon.go b/bridge/mastodon/mastodon.go index 007b292584..3adfb821a9 100644 --- a/bridge/mastodon/mastodon.go +++ b/bridge/mastodon/mastodon.go @@ -17,6 +17,10 @@ import ( var ( htmlReplacementTag = regexp.MustCompile("<[^>]*>") + channelTypeHome = "home" + channelTypeLocal = "local" + channelTypeRemote = "remote" + channelTypeDirect = "direct" ) type Broom struct { @@ -27,6 +31,7 @@ type Broom struct { type Bmastodon struct { *bridge.Config + c *mastodon.Client account *mastodon.Account @@ -41,18 +46,18 @@ func New(cfg *bridge.Config) bridge.Bridger { func (b *Bmastodon) Connect() error { b.Log.Infof("Connecting %s", b.GetString("Server")) - config := mastodon.Config{ + cfg := mastodon.Config{ Server: b.GetString("Server"), ClientID: b.GetString("ClientID"), ClientSecret: b.GetString("ClientSecret"), AccessToken: b.GetString("AccessToken"), } - b.c = mastodon.NewClient(&config) + b.c = mastodon.NewClient(&cfg) var err error b.account, err = b.c.GetAccountCurrentUser(context.Background()) if err != nil { - return nil + return err } return nil @@ -71,41 +76,30 @@ func (b *Bmastodon) JoinChannel(channel config.ChannelInfo) error { var ch chan mastodon.Event var err error ctx, ctxCancel := context.WithCancel(context.Background()) + room := Broom{ + channel: "", + ctx: ctx, + ctxCancel: ctxCancel, + } if channel.Name == "home" { // You are talking to the home channel - b.rooms = append(b.rooms, Broom{ - channel: "home", - ctx: ctx, - ctxCancel: ctxCancel, - }) - channelType = "home" + room.channel = "home" + channelType = channelTypeHome ch, err = b.c.StreamingUser(ctx) } else if channel.Name == "local" { // You are talking to the local channel - b.rooms = append(b.rooms, Broom{ - channel: "local", - ctx: ctx, - ctxCancel: ctxCancel, - }) - channelType = "local" + room.channel = "local" + channelType = channelTypeLocal ch, err = b.c.StreamingPublic(ctx, true) } else if channel.Name == "remote" { // You are talking to the remote channel - b.rooms = append(b.rooms, Broom{ - channel: "remote", - ctx: ctx, - ctxCancel: ctxCancel, - }) - channelType = "remote" + room.channel = "remote" + channelType = channelTypeRemote ch, err = b.c.StreamingPublic(ctx, false) } else if strings.HasPrefix(channel.Name, "@") { // You are talking to a private user - b.rooms = append(b.rooms, Broom{ - channel: channel.Name, - ctx: ctx, - ctxCancel: ctxCancel, - }) - channelType = "direct" + room.channel = channel.Name + channelType = channelTypeDirect ch, err = b.c.StreamingDirect(ctx) } else { ctxCancel() @@ -114,6 +108,7 @@ func (b *Bmastodon) JoinChannel(channel config.ChannelInfo) error { if err != nil { return err } + b.rooms = append(b.rooms, room) go func() { b.Log.Debugf("run golang channel on streaming api call, channel name: %v", channel.Name) @@ -121,26 +116,53 @@ func (b *Bmastodon) JoinChannel(channel config.ChannelInfo) error { switch t := msg.(type) { case *mastodon.UpdateEvent: switch channelType { - case "local", "home", "remote": + case channelTypeHome, channelTypeLocal, channelTypeRemote: b.handleSendRemoteStatus(t.Status, channel.Name) default: b.Log.Debugf("run UpdateEvent on unsupported channelType: %s", channelType) } case *mastodon.ConversationEvent: switch channelType { - case "local", "home", "remote": + case channelTypeHome, channelTypeLocal, channelTypeRemote: // Not a conversation b.Log.Debugf("run ConversationEvent on unsupported channelType: %s", channelType) default: b.handleSendRemoteStatus(t.Conversation.LastStatus, channel.Name) } } - } }() return nil } +func (b *Bmastodon) Send(msg config.Message) (string, error) { + ctx := context.Background() + + // Standard Message Send + if msg.Event == "" { + sentMessage, err := b.handleSendingMessage(ctx, &msg) + if err != nil { + b.Log.Errorf("Could not send message to room %v from %v: %v", msg.Channel, msg.Username, err) + + return "", nil + } + return string(sentMessage.ID), nil + } + + // Message Deletion + if msg.Event == config.EventMsgDelete { + if msg.UserID != string(b.account.ID) { + b.Log.Errorf("Can not delete a status that is owned by a different account") + return "", nil + } + err := b.c.DeleteStatus(context.Background(), mastodon.ID(msg.ID)) + return "", err + } + + // Message is not a type that is currently supported + return "", nil +} + func (b *Bmastodon) handleSendRemoteStatus(msg *mastodon.Status, channel string) { if msg.Account.ID == b.account.ID { // Ignore messages that are from the bot user @@ -183,34 +205,6 @@ func (b *Bmastodon) handleSendRemoteStatus(msg *mastodon.Status, channel string) b.Remote <- remoteMessage } -func (b *Bmastodon) Send(msg config.Message) (string, error) { - ctx := context.Background() - - // Standard Message Send - if msg.Event == "" { - sentMessage, err := b.handleSendingMessage(ctx, &msg) - if err != nil { - b.Log.Errorf("Could not send message to room %v from %v: %v", msg.Channel, msg.Username, err) - - return "", nil - } - return string(sentMessage.ID), nil - } - - // Message Deletion - if msg.Event == config.EventMsgDelete { - if msg.UserID != string(b.account.ID) { - b.Log.Errorf("Can not delete a status that is owned by a different account") - return "", nil - } - err := b.c.DeleteStatus(context.Background(), mastodon.ID(msg.ID)) - return "", err - } - - // Message is not a type that is currently supported - return "", nil -} - func (b *Bmastodon) handleSendingMessage(ctx context.Context, msg *config.Message) (*mastodon.Status, error) { toot := mastodon.Toot{ Status: msg.Text, diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index 4821423b7e..b1f21e9f1f 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -257,15 +257,15 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { } rmsg.NewContent = SubTextMessage{ - Body: rmsg.TextMessage.Body, - FormattedBody: rmsg.TextMessage.FormattedBody, - Format: rmsg.TextMessage.Format, + Body: rmsg.Body, + FormattedBody: rmsg.FormattedBody, + Format: rmsg.Format, MsgType: "m.text", } if b.GetBool("HTMLDisable") { - rmsg.TextMessage.Format = "" - rmsg.TextMessage.FormattedBody = "" + rmsg.Format = "" + rmsg.FormattedBody = "" rmsg.NewContent.Format = "" rmsg.NewContent.FormattedBody = "" } @@ -329,8 +329,8 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { } if b.GetBool("HTMLDisable") { - m.TextMessage.Format = "" - m.TextMessage.FormattedBody = "" + m.Format = "" + m.FormattedBody = "" } m.RelatedTo = InReplyToRelation{ @@ -569,7 +569,7 @@ func (b *Bmatrix) handleDownloadFile(rmsg *config.Message, content map[string]in if url, ok = content["url"].(string); !ok { return fmt.Errorf("url isn't a %T", url) } - url = strings.Replace(url, "mxc://", b.GetString("Server")+"/_matrix/media/v1/download/", -1) + url = strings.ReplaceAll(url, "mxc://", b.GetString("Server")+"/_matrix/media/v1/download/") if info, ok = content["info"].(map[string]interface{}); !ok { return fmt.Errorf("info isn't a %T", info) diff --git a/bridge/mattermost/helpers.go b/bridge/mattermost/helpers.go index 21210f0cae..8e2d971716 100644 --- a/bridge/mattermost/helpers.go +++ b/bridge/mattermost/helpers.go @@ -94,7 +94,7 @@ func (b *Bmattermost) apiLogin() error { // replaceAction replace the message with the correct action (/me) code func (b *Bmattermost) replaceAction(text string) (string, bool) { if strings.HasPrefix(text, "*") && strings.HasSuffix(text, "*") { - return strings.Replace(text, "*", "", -1), true + return strings.ReplaceAll(text, "*", ""), true } return text, false } @@ -245,11 +245,12 @@ func (b *Bmattermost) skipMessage(message *matterclient.Message) bool { } // only handle posted, edited or deleted events - if !(message.Raw.EventType() == "posted" || message.Raw.EventType() == model.WebsocketEventPostEdited || - message.Raw.EventType() == model.WebsocketEventPostDeleted) { + switch message.Raw.EventType() { + case "posted", model.WebsocketEventPostEdited, model.WebsocketEventPostDeleted: + return false + default: return true } - return false } func (b *Bmattermost) getVersion() string { diff --git a/bridge/mattermost/mattermost.go b/bridge/mattermost/mattermost.go index 2a9cbf7670..cf0ff8edad 100644 --- a/bridge/mattermost/mattermost.go +++ b/bridge/mattermost/mattermost.go @@ -111,7 +111,7 @@ func (b *Bmattermost) JoinChannel(channel config.ChannelInfo) error { if b.GetString("WebhookURL") == "" && b.GetString("WebhookBindAddress") == "" { id := b.getChannelID(channel.Name) if id == "" { - return fmt.Errorf("Could not find channel ID for channel %s", channel.Name) + return fmt.Errorf("could not find channel ID for channel %s", channel.Name) } return b.mc.JoinChannel(id) diff --git a/bridge/msteams/handler.go b/bridge/msteams/handler.go index 6083eabd69..f1b65249dd 100644 --- a/bridge/msteams/handler.go +++ b/bridge/msteams/handler.go @@ -3,7 +3,7 @@ package bmsteams import ( "encoding/json" "fmt" - "io/ioutil" + "io" "strings" "github.com/matterbridge-org/matterbridge/bridge/config" @@ -92,7 +92,7 @@ func (b *Bmsteams) handleCodeSnippet(rmsg *config.Message, attach msgraph.ChatMe return } defer resp.Body.Close() - res, err := ioutil.ReadAll(resp.Body) + res, err := io.ReadAll(resp.Body) if err != nil { b.Log.Errorf("reading snippet data failed: %s", err) return diff --git a/bridge/msteams/msteams.go b/bridge/msteams/msteams.go index f79e718884..0deeb36ae3 100644 --- a/bridge/msteams/msteams.go +++ b/bridge/msteams/msteams.go @@ -157,10 +157,10 @@ func (b *Bmsteams) poll(channelName string) error { for i := len(res) - 1; i >= 0; i-- { msg := res[i] if mtime, ok := msgmap[*msg.ID]; ok { - if mtime == *msg.CreatedDateTime && msg.LastModifiedDateTime == nil { + if mtime.Equal(*msg.CreatedDateTime) && msg.LastModifiedDateTime == nil { continue } - if msg.LastModifiedDateTime != nil && mtime == *msg.LastModifiedDateTime { + if msg.LastModifiedDateTime != nil && mtime.Equal(*msg.LastModifiedDateTime) { continue } } diff --git a/bridge/mumble/handlers.go b/bridge/mumble/handlers.go index 98dfda1f95..23a0514072 100644 --- a/bridge/mumble/handlers.go +++ b/bridge/mumble/handlers.go @@ -16,8 +16,8 @@ func (b *Bmumble) handleServerConfig(event *gumble.ServerConfigEvent) { func (b *Bmumble) handleTextMessage(event *gumble.TextMessageEvent) { sender := "unknown" - if event.TextMessage.Sender != nil { - sender = event.TextMessage.Sender.Name + if event.Sender != nil { + sender = event.Sender.Name } // If the text message is received before receiving a ServerSync // and UserState, Client.Self or Self.Channel are nil @@ -26,7 +26,7 @@ func (b *Bmumble) handleTextMessage(event *gumble.TextMessageEvent) { return } // Convert Mumble HTML messages to markdown - parts, err := b.convertHTMLtoMarkdown(event.TextMessage.Message) + parts, err := b.convertHTMLtoMarkdown(event.Message) if err != nil { b.Log.Error(err) } diff --git a/bridge/mumble/helpers.go b/bridge/mumble/helpers.go index 9e0a6c06c6..c06da1fd2e 100644 --- a/bridge/mumble/helpers.go +++ b/bridge/mumble/helpers.go @@ -22,13 +22,13 @@ func (b *Bmumble) decodeImage(uri string, parts *[]MessagePart) error { // Decode the data:image/... URI image, err := dataurl.DecodeString(uri) if err != nil { - b.Log.WithError(err).Info("No image extracted") + b.Log.WithError(err).Info("no image extracted") return err } // Determine the file extensions for that image - ext, err := mime.ExtensionsByType(image.MediaType.ContentType()) + ext, err := mime.ExtensionsByType(image.ContentType()) if err != nil || len(ext) == 0 { - b.Log.WithError(err).Infof("No file extension registered for MIME type '%s'", image.MediaType.ContentType()) + b.Log.WithError(err).Infof("no file extension registered for MIME type '%s'", image.ContentType()) return err } // Add the image to the MessagePart slice diff --git a/bridge/mumble/mumble.go b/bridge/mumble/mumble.go index 54bbdcdc4f..1ffbaa8501 100644 --- a/bridge/mumble/mumble.go +++ b/bridge/mumble/mumble.go @@ -5,8 +5,8 @@ import ( "crypto/x509" "errors" "fmt" - "io/ioutil" "net" + "os" "strconv" "strings" "time" @@ -119,7 +119,7 @@ func (b *Bmumble) buildTLSConfig() error { } // Load TLS CA used for server verification. If not provided, the Go system trust anchor is used if capath := b.GetString("TLSCACertificate"); capath != "" { - ca, err := ioutil.ReadFile(capath) + ca, err := os.ReadFile(capath) if err != nil { return err } diff --git a/bridge/rocketchat/helpers.go b/bridge/rocketchat/helpers.go index f7f3294ae7..96774af3d4 100644 --- a/bridge/rocketchat/helpers.go +++ b/bridge/rocketchat/helpers.go @@ -2,7 +2,7 @@ package brocketchat import ( "context" - "io/ioutil" + "io" "mime" "net/http" "net/url" @@ -136,7 +136,7 @@ func (b *Brocketchat) uploadFile(fi *config.FileInfo, channel string) error { return err } defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return err } diff --git a/bridge/slack/helpers.go b/bridge/slack/helpers.go index c7c651c2ba..5cfc31628e 100644 --- a/bridge/slack/helpers.go +++ b/bridge/slack/helpers.go @@ -231,7 +231,7 @@ func (b *Bslack) getUsersInConversation(channelID string) ([]string, error) { members, nextCursor, err := b.sc.GetUsersInConversation(queryParams) if err != nil { if err = handleRateLimit(b.Log, err); err != nil { - return channelMembers, fmt.Errorf("Could not retrieve users in channels: %#v", err) + return channelMembers, fmt.Errorf("could not retrieve users in channels: %#v", err) } continue } diff --git a/bridge/slack/helpers_test.go b/bridge/slack/helpers_test.go index 5e314d34a9..6a9e9ee8e4 100644 --- a/bridge/slack/helpers_test.go +++ b/bridge/slack/helpers_test.go @@ -1,7 +1,7 @@ package bslack import ( - "io/ioutil" + "io" "testing" "github.com/matterbridge-org/matterbridge/bridge" @@ -24,7 +24,7 @@ func TestExtractTopicOrPurpose(t *testing.T) { } logger := logrus.New() - logger.SetOutput(ioutil.Discard) + logger.SetOutput(io.Discard) cfg := &bridge.Config{Bridge: &bridge.Bridge{Log: logrus.NewEntry(logger)}} b := newBridge(cfg) for name, tc := range testcases { diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go index 8012ff794c..0c4bbd2310 100644 --- a/bridge/slack/slack.go +++ b/bridge/slack/slack.go @@ -130,7 +130,7 @@ func (b *Bslack) Connect() error { ) if b.GetString(outgoingWebhookConfig) != "" { b.Log.Info("Using specified webhook for outgoing messages.") - b.mh.Url = b.GetString(outgoingWebhookConfig) + b.mh.URL = b.GetString(outgoingWebhookConfig) } if b.GetString(incomingWebhookConfig) != "" { b.Log.Info("Setting up local webhook for incoming messages.") diff --git a/bridge/telegram/handlers.go b/bridge/telegram/handlers.go index 26c3857949..708be636de 100644 --- a/bridge/telegram/handlers.go +++ b/bridge/telegram/handlers.go @@ -575,9 +575,9 @@ func (b *Btelegram) handleQuote(message, quoteNick, quoteMessage string) string quoteMessage += "..." } } - format = strings.Replace(format, "{MESSAGE}", message, -1) - format = strings.Replace(format, "{QUOTENICK}", quoteNick, -1) - format = strings.Replace(format, "{QUOTEMESSAGE}", quoteMessage, -1) + format = strings.ReplaceAll(format, "{MESSAGE}", message) + format = strings.ReplaceAll(format, "{QUOTENICK}", quoteNick) + format = strings.ReplaceAll(format, "{QUOTEMESSAGE}", quoteMessage) return format } diff --git a/bridge/telegram/telegram.go b/bridge/telegram/telegram.go index adc027ca59..1206f32ef7 100644 --- a/bridge/telegram/telegram.go +++ b/bridge/telegram/telegram.go @@ -191,7 +191,7 @@ func (b *Btelegram) sendMessage(chatid int64, topicid int, username, text string m := tgbotapi.NewMessage(chatid, "") m.Text, m.ParseMode = TGGetParseMode(b, username, text) if topicid != 0 { - m.BaseChat.MessageThreadID = topicid + m.MessageThreadID = topicid } m.ReplyToMessageID = parentID m.DisableWebPagePreview = b.GetBool("DisableWebPagePreview") diff --git a/bridge/vk/vk.go b/bridge/vk/vk.go index be9f2a61e4..2e731cc4c6 100644 --- a/bridge/vk/vk.go +++ b/bridge/vk/vk.go @@ -294,7 +294,7 @@ func (b *Bvk) getFiles(attachments []object.MessagesMessageAttachment) ([]string urls = append(urls, a.Graffiti.URL) case audioMessage: - urls = append(urls, a.AudioMessage.DocsDocPreviewAudioMessage.LinkOgg) + urls = append(urls, a.AudioMessage.LinkOgg) case sticker: var resolution float64 = 0 diff --git a/bridge/whatsapp/helpers.go b/bridge/whatsapp/helpers.go index 9d39d36865..2c8cd8ebf9 100644 --- a/bridge/whatsapp/helpers.go +++ b/bridge/whatsapp/helpers.go @@ -36,7 +36,7 @@ func qrFromTerminal(invert bool) chan string { func (b *Bwhatsapp) readSession() (whatsapp.Session, error) { session := whatsapp.Session{} - sessionFile := b.Config.GetString(sessionFile) + sessionFile := b.GetString(sessionFile) if sessionFile == "" { return session, errors.New("if you won't set SessionFile then you will need to scan QR code on every restart") @@ -55,7 +55,7 @@ func (b *Bwhatsapp) readSession() (whatsapp.Session, error) { } func (b *Bwhatsapp) writeSession(session whatsapp.Session) error { - sessionFile := b.Config.GetString(sessionFile) + sessionFile := b.GetString(sessionFile) if sessionFile == "" { // we already sent a warning while starting the bridge, so let's be quiet here diff --git a/bridge/whatsappmulti/handlers.go b/bridge/whatsappmulti/handlers.go index 3bb73b1e40..929843a4e7 100644 --- a/bridge/whatsappmulti/handlers.go +++ b/bridge/whatsappmulti/handlers.go @@ -1,5 +1,4 @@ //go:build whatsappmulti -// +build whatsappmulti package bwhatsapp diff --git a/bridge/whatsappmulti/helpers.go b/bridge/whatsappmulti/helpers.go index 5eac958e64..dc336b9c6e 100644 --- a/bridge/whatsappmulti/helpers.go +++ b/bridge/whatsappmulti/helpers.go @@ -1,5 +1,4 @@ //go:build whatsappmulti -// +build whatsappmulti package bwhatsapp diff --git a/bridge/whatsappmulti/whatsapp.go b/bridge/whatsappmulti/whatsapp.go index 3f0c71fc3a..783fd5d67b 100644 --- a/bridge/whatsappmulti/whatsapp.go +++ b/bridge/whatsappmulti/whatsapp.go @@ -1,5 +1,4 @@ //go:build whatsappmulti -// +build whatsappmulti package bwhatsapp diff --git a/bridge/xmpp/xmpp.go b/bridge/xmpp/xmpp.go index 6b46690cc8..d1ebf60420 100644 --- a/bridge/xmpp/xmpp.go +++ b/bridge/xmpp/xmpp.go @@ -349,7 +349,7 @@ func (b *Bxmpp) handleXMPP() error { func (b *Bxmpp) replaceAction(text string) (string, bool) { if strings.HasPrefix(text, "/me ") { - return strings.Replace(text, "/me ", "", -1), true + return strings.ReplaceAll(text, "/me ", ""), true } return text, false } diff --git a/bridge/zulip/zulip.go b/bridge/zulip/zulip.go index a7c8b664c0..196bc5b29d 100644 --- a/bridge/zulip/zulip.go +++ b/bridge/zulip/zulip.go @@ -3,7 +3,7 @@ package bzulip import ( "encoding/json" "fmt" - "io/ioutil" + "io" "strconv" "strings" "sync" @@ -180,7 +180,7 @@ func (b *Bzulip) sendMessage(msg config.Message) (string, error) { } if resp != nil { defer resp.Body.Close() - res, err := ioutil.ReadAll(resp.Body) + res, err := io.ReadAll(resp.Body) if err != nil { return "", err } diff --git a/gateway/bridgemap/api.go b/gateway/bridgemap/api.go index 1ed09de331..29fca68cd9 100644 --- a/gateway/bridgemap/api.go +++ b/gateway/bridgemap/api.go @@ -1,5 +1,4 @@ //go:build !noapi -// +build !noapi package bridgemap diff --git a/gateway/bridgemap/bdiscord.go b/gateway/bridgemap/bdiscord.go index 6a6f1a345e..e7b143094d 100644 --- a/gateway/bridgemap/bdiscord.go +++ b/gateway/bridgemap/bdiscord.go @@ -1,5 +1,4 @@ //go:build !nodiscord -// +build !nodiscord package bridgemap diff --git a/gateway/bridgemap/birc.go b/gateway/bridgemap/birc.go index e2fa80502a..8d1a7f3140 100644 --- a/gateway/bridgemap/birc.go +++ b/gateway/bridgemap/birc.go @@ -1,5 +1,4 @@ //go:build !noirc -// +build !noirc package bridgemap diff --git a/gateway/bridgemap/bmastodon.go b/gateway/bridgemap/bmastodon.go index 354f4ff34d..6a389516db 100644 --- a/gateway/bridgemap/bmastodon.go +++ b/gateway/bridgemap/bmastodon.go @@ -1,5 +1,4 @@ //go:build !nomastodon -// +build !nomastodon package bridgemap diff --git a/gateway/bridgemap/bmatrix.go b/gateway/bridgemap/bmatrix.go index eacc27ddd2..9883886cac 100644 --- a/gateway/bridgemap/bmatrix.go +++ b/gateway/bridgemap/bmatrix.go @@ -1,5 +1,4 @@ //go:build !nomatrix -// +build !nomatrix package bridgemap diff --git a/gateway/bridgemap/bmattermost.go b/gateway/bridgemap/bmattermost.go index 307e3464fe..2cb7ae7afd 100644 --- a/gateway/bridgemap/bmattermost.go +++ b/gateway/bridgemap/bmattermost.go @@ -1,5 +1,4 @@ //go:build !nomattermost -// +build !nomattermost package bridgemap diff --git a/gateway/bridgemap/bmsteams.go b/gateway/bridgemap/bmsteams.go index 6cfd8aa638..66ce8eecbe 100644 --- a/gateway/bridgemap/bmsteams.go +++ b/gateway/bridgemap/bmsteams.go @@ -1,5 +1,4 @@ //go:build !nomsteams -// +build !nomsteams package bridgemap diff --git a/gateway/bridgemap/bmumble.go b/gateway/bridgemap/bmumble.go index 4bb8a5ab55..b691ec7093 100644 --- a/gateway/bridgemap/bmumble.go +++ b/gateway/bridgemap/bmumble.go @@ -1,5 +1,4 @@ //go:build !nomumble -// +build !nomumble package bridgemap diff --git a/gateway/bridgemap/bnctalk.go b/gateway/bridgemap/bnctalk.go index 03d31de8c1..0d15e48047 100644 --- a/gateway/bridgemap/bnctalk.go +++ b/gateway/bridgemap/bnctalk.go @@ -1,5 +1,4 @@ //go:build !nonctalk -// +build !nonctalk package bridgemap diff --git a/gateway/bridgemap/brocketchat.go b/gateway/bridgemap/brocketchat.go index c7096485ab..4a8f466009 100644 --- a/gateway/bridgemap/brocketchat.go +++ b/gateway/bridgemap/brocketchat.go @@ -1,5 +1,4 @@ //go:build !norocketchat -// +build !norocketchat package bridgemap diff --git a/gateway/bridgemap/bslack.go b/gateway/bridgemap/bslack.go index 2efbb26a1f..0410714d20 100644 --- a/gateway/bridgemap/bslack.go +++ b/gateway/bridgemap/bslack.go @@ -1,5 +1,4 @@ //go:build !noslack -// +build !noslack package bridgemap diff --git a/gateway/bridgemap/bsshchat.go b/gateway/bridgemap/bsshchat.go index 5423d52b5e..0b4da51981 100644 --- a/gateway/bridgemap/bsshchat.go +++ b/gateway/bridgemap/bsshchat.go @@ -1,5 +1,4 @@ //go:build !nosshchat -// +build !nosshchat package bridgemap diff --git a/gateway/bridgemap/btelegram.go b/gateway/bridgemap/btelegram.go index 81e7382fd3..b67f19f80e 100644 --- a/gateway/bridgemap/btelegram.go +++ b/gateway/bridgemap/btelegram.go @@ -1,5 +1,4 @@ //go:build !notelegram -// +build !notelegram package bridgemap diff --git a/gateway/bridgemap/bvk.go b/gateway/bridgemap/bvk.go index fe83ed3936..694df60153 100644 --- a/gateway/bridgemap/bvk.go +++ b/gateway/bridgemap/bvk.go @@ -1,5 +1,4 @@ //go:build !novk -// +build !novk package bridgemap diff --git a/gateway/bridgemap/bwhatsapp.go b/gateway/bridgemap/bwhatsapp.go index 42dfb2d9f6..20dc9b1e95 100644 --- a/gateway/bridgemap/bwhatsapp.go +++ b/gateway/bridgemap/bwhatsapp.go @@ -1,5 +1,4 @@ //go:build !nowhatsapp && !whatsappmulti -// +build !nowhatsapp,!whatsappmulti package bridgemap diff --git a/gateway/bridgemap/bwhatsappmulti.go b/gateway/bridgemap/bwhatsappmulti.go index 646499dfad..e749bd9432 100644 --- a/gateway/bridgemap/bwhatsappmulti.go +++ b/gateway/bridgemap/bwhatsappmulti.go @@ -1,5 +1,4 @@ //go:build whatsappmulti -// +build whatsappmulti package bridgemap diff --git a/gateway/bridgemap/bxmpp.go b/gateway/bridgemap/bxmpp.go index 89d6489f4e..dee6b76bf7 100644 --- a/gateway/bridgemap/bxmpp.go +++ b/gateway/bridgemap/bxmpp.go @@ -1,5 +1,4 @@ //go:build !noxmpp -// +build !noxmpp package bridgemap diff --git a/gateway/bridgemap/bzulip.go b/gateway/bridgemap/bzulip.go index f24e59341f..94b721a539 100644 --- a/gateway/bridgemap/bzulip.go +++ b/gateway/bridgemap/bzulip.go @@ -1,5 +1,4 @@ //go:build !nozulip -// +build !nozulip package bridgemap diff --git a/gateway/gateway.go b/gateway/gateway.go index 50ba966c02..0ec4471d08 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -2,7 +2,6 @@ package gateway import ( "fmt" - "io/ioutil" "os" "regexp" "strings" @@ -374,7 +373,7 @@ func (gw *Gateway) modifyUsername(msg *config.Message, dest *bridge.Bridge) stri func (gw *Gateway) modifyAvatar(msg *config.Message, dest *bridge.Bridge) string { iconurl := dest.GetString("IconURL") - iconurl = strings.Replace(iconurl, "{NICK}", msg.Username, -1) + iconurl = strings.ReplaceAll(iconurl, "{NICK}", msg.Username) if msg.Avatar == "" { msg.Avatar = iconurl } @@ -563,7 +562,7 @@ func modifyInMessageTengo(filename string, msg *config.Message) error { if filename == "" { return nil } - res, err := ioutil.ReadFile(filename) + res, err := os.ReadFile(filename) if err != nil { return err } @@ -591,7 +590,7 @@ func (gw *Gateway) modifyUsernameTengo(msg *config.Message, br *bridge.Bridge) ( if filename == "" { return "", nil } - res, err := ioutil.ReadFile(filename) + res, err := os.ReadFile(filename) if err != nil { return "", err } @@ -634,7 +633,7 @@ func (gw *Gateway) modifyOutMessageTengo(origmsg *config.Message, msg *config.Me return drop, err } } else { - res, err = ioutil.ReadFile(filename) + res, err = os.ReadFile(filename) if err != nil { return drop, err } diff --git a/gateway/gateway_test.go b/gateway/gateway_test.go index c0a2980d52..0f5a6c31dd 100644 --- a/gateway/gateway_test.go +++ b/gateway/gateway_test.go @@ -2,7 +2,7 @@ package gateway import ( "fmt" - "io/ioutil" + "io" "strconv" "testing" @@ -159,7 +159,7 @@ const ( func maketestRouter(input []byte) *Router { logger := logrus.New() - logger.SetOutput(ioutil.Discard) + logger.SetOutput(io.Discard) cfg := config.NewConfigFromString(logger, input) r, err := NewRouter(logger, cfg, bridgemap.FullMap) if err != nil { @@ -385,7 +385,7 @@ func TestIgnoreSuite(t *testing.T) { func (s *ignoreTestSuite) SetupSuite() { logger := logrus.New() - logger.SetOutput(ioutil.Discard) + logger.SetOutput(io.Discard) s.gw = &Gateway{logger: logrus.NewEntry(logger)} } diff --git a/gateway/handlers.go b/gateway/handlers.go index 2f26103844..58bf9b592d 100644 --- a/gateway/handlers.go +++ b/gateway/handlers.go @@ -4,7 +4,6 @@ import ( "bytes" "crypto/sha1" //nolint:gosec "fmt" - "io/ioutil" "net/http" "os" "path/filepath" @@ -157,7 +156,7 @@ func (gw *Gateway) handleFilesLocal(fi *config.FileInfo) error { path := dir + "/" + fi.Name gw.logger.Debugf("mediaserver path placing file: %s", path) - err = ioutil.WriteFile(path, *fi.Data, os.ModePerm) + err = os.WriteFile(path, *fi.Data, os.ModePerm) if err != nil { return fmt.Errorf("mediaserver path failed, could not writefile: %s %#v", err, err) } diff --git a/gateway/router.go b/gateway/router.go index 08e9e47636..a8d9bed233 100644 --- a/gateway/router.go +++ b/gateway/router.go @@ -75,7 +75,7 @@ func (r *Router) Start() error { r.logger.Infof("Starting bridge: %s ", br.Account) err := br.Connect() if err != nil { - e := fmt.Errorf("Bridge %s failed to start: %v", br.Account, err) + e := fmt.Errorf("bridge %s failed to start: %v", br.Account, err) if r.disableBridge(br, e) { continue } @@ -83,7 +83,7 @@ func (r *Router) Start() error { } err = br.JoinChannels() if err != nil { - e := fmt.Errorf("Bridge %s failed to join channel: %v", br.Account, err) + e := fmt.Errorf("bridge %s failed to join channel: %v", br.Account, err) if r.disableBridge(br, e) { continue } diff --git a/gateway/samechannel/samechannel_test.go b/gateway/samechannel/samechannel_test.go index 1bed9cfa41..e5f54f23da 100644 --- a/gateway/samechannel/samechannel_test.go +++ b/gateway/samechannel/samechannel_test.go @@ -1,7 +1,7 @@ package samechannel import ( - "io/ioutil" + "io" "testing" "github.com/matterbridge-org/matterbridge/bridge/config" @@ -69,7 +69,7 @@ var ( func TestGetConfig(t *testing.T) { logger := logrus.New() - logger.SetOutput(ioutil.Discard) + logger.SetOutput(io.Discard) cfg := config.NewConfigFromString(logger, []byte(testConfig)) sgw := New(cfg) configs := sgw.GetConfig() diff --git a/hook/rockethook/rockethook.go b/hook/rockethook/rockethook.go index 38f53e4a63..e9f8f74fe7 100644 --- a/hook/rockethook/rockethook.go +++ b/hook/rockethook/rockethook.go @@ -3,7 +3,7 @@ package rockethook import ( "crypto/tls" "encoding/json" - "io/ioutil" + "io" "log" "net" "net/http" @@ -68,7 +68,7 @@ func (c *Client) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } msg := Message{} - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) if err != nil { log.Println(err) http.NotFound(w, r) diff --git a/matterhook/matterhook.go b/matterhook/matterhook.go index b989d25f06..68acc5bd9c 100644 --- a/matterhook/matterhook.go +++ b/matterhook/matterhook.go @@ -7,7 +7,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "log" "net" "net/http" @@ -41,9 +40,9 @@ type IMessage struct { Timestamp string `schema:"timestamp"` UserID string `schema:"user_id"` UserName string `schema:"user_name"` - PostId string `schema:"post_id"` //nolint:golint + PostID string `schema:"post_id"` //nolint:golint RawText string `schema:"raw_text"` - ServiceId string `schema:"service_id"` //nolint:golint + ServiceID string `schema:"service_id"` //nolint:golint Text string `schema:"text"` TriggerWord string `schema:"trigger_word"` FileIDs string `schema:"file_ids"` @@ -52,7 +51,7 @@ type IMessage struct { // Client for Mattermost. type Client struct { // URL for incoming webhooks on mattermost. - Url string // nolint:golint + URL string // nolint:golint In chan IMessage Out chan OMessage httpclient *http.Client @@ -69,7 +68,7 @@ type Config struct { // New Mattermost client. func New(url string, config Config) *Client { - c := &Client{Url: url, In: make(chan IMessage), Out: make(chan OMessage), Config: config} + c := &Client{URL: url, In: make(chan IMessage), Out: make(chan OMessage), Config: config} tr := &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify}, //nolint:gosec } @@ -152,14 +151,14 @@ func (c *Client) Send(msg OMessage) error { if err != nil { return err } - resp, err := c.httpclient.Post(c.Url, "application/json", bytes.NewReader(buf)) + resp, err := c.httpclient.Post(c.URL, "application/json", bytes.NewReader(buf)) if err != nil { return err } defer resp.Body.Close() // Read entire body to completion to re-use keep-alive connections. - io.Copy(ioutil.Discard, resp.Body) + io.Copy(io.Discard, resp.Body) if resp.StatusCode != 200 { return fmt.Errorf("unexpected status code: %d", resp.StatusCode) From 0ca3b6f29bc9cc05fc846dfb5558f7dc3b6c4eed Mon Sep 17 00:00:00 2001 From: "Lucian I. Last" Date: Thu, 20 Nov 2025 13:55:26 +0100 Subject: [PATCH 08/10] Better set of channel name --- bridge/mastodon/mastodon.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/bridge/mastodon/mastodon.go b/bridge/mastodon/mastodon.go index 3adfb821a9..9ee7225525 100644 --- a/bridge/mastodon/mastodon.go +++ b/bridge/mastodon/mastodon.go @@ -77,28 +77,24 @@ func (b *Bmastodon) JoinChannel(channel config.ChannelInfo) error { var err error ctx, ctxCancel := context.WithCancel(context.Background()) room := Broom{ - channel: "", + channel: channel.Name, ctx: ctx, ctxCancel: ctxCancel, } if channel.Name == "home" { // You are talking to the home channel - room.channel = "home" channelType = channelTypeHome ch, err = b.c.StreamingUser(ctx) } else if channel.Name == "local" { // You are talking to the local channel - room.channel = "local" channelType = channelTypeLocal ch, err = b.c.StreamingPublic(ctx, true) } else if channel.Name == "remote" { // You are talking to the remote channel - room.channel = "remote" channelType = channelTypeRemote ch, err = b.c.StreamingPublic(ctx, false) } else if strings.HasPrefix(channel.Name, "@") { // You are talking to a private user - room.channel = channel.Name channelType = channelTypeDirect ch, err = b.c.StreamingDirect(ctx) } else { From 032b52e82331c00edec2dd1659b893c82c4bde42 Mon Sep 17 00:00:00 2001 From: "Lucian I. Last" Date: Thu, 20 Nov 2025 22:13:55 +0100 Subject: [PATCH 09/10] Update golangci-lint to v2.6 --- .github/workflows/development.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index 0281a7c53c..5c5dbe08ae 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -23,7 +23,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v8 with: - version: v2.1 + version: v2.6 # Only compare with previous commit when pushing, # and with base branch when in PR. only-new-issues: true From d58f99673496b72691d1b617d6ced5e9b623f37b Mon Sep 17 00:00:00 2001 From: "Lucian I. Last" Date: Thu, 20 Nov 2025 22:14:16 +0100 Subject: [PATCH 10/10] Update go to 1.25 --- .github/workflows/development.yml | 4 ++-- .golangci.yaml | 2 +- go.mod | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index 5c5dbe08ae..db26d7b77c 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -19,7 +19,7 @@ jobs: - uses: actions/checkout@v5 - uses: actions/setup-go@v6 with: - go-version: 1.24.x + go-version: 1.25.x - name: golangci-lint uses: golangci/golangci-lint-action@v8 with: @@ -31,7 +31,7 @@ jobs: strategy: matrix: # Test on latest release and v1.24 - go-version: [1.24.x, stable] + go-version: [1.25.x, stable] runs-on: ubuntu-latest steps: - name: Install Go diff --git a/.golangci.yaml b/.golangci.yaml index 40447153e1..ab79b356e9 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -4,7 +4,7 @@ version: "2" # options for analysis running run: - go: "1.22" + go: "1.25" # which dirs to skip: they won't be analyzed; # can use regexp here: generated.*, regexp is applied on full path; diff --git a/go.mod b/go.mod index 827f3cbada..7bd576a31c 100644 --- a/go.mod +++ b/go.mod @@ -149,4 +149,4 @@ require ( //replace github.com/matrix-org/gomatrix => github.com/matterbridge/gomatrix v0.0.0-20220205235239-607eb9ee6419 -go 1.24.0 +go 1.25.0