Compare commits

...

18 Commits

Author SHA1 Message Date
Wim
73ec02ab9d Release v1.23.2 (#1631) 2021-11-02 23:22:21 +01:00
snikpic
d1f8347071 Update go-whatsapp version (#1630) 2021-11-02 21:11:42 +01:00
Wim
8601eedada Bump version 2021-11-01 23:56:24 +01:00
Wim
9afd33cdfc Release v1.23.1 (#1629) 2021-10-30 18:47:35 +02:00
Polynomdivision
5e1be8e558 Do not fail on no avatar data (xmpp) #1529 (#1627)
* Detect errors when working with AvatarData

* Remove not neccessary line

Co-authored-by: Wim <wim@42.be>
2021-10-30 17:50:37 +02:00
Wim
835dd2635a Update dependencies (#1628) 2021-10-30 15:17:50 +02:00
Wim
f65b18c2f6 Remove wrapcheck linter 2021-10-30 15:12:31 +02:00
Minecraftchest1
b0e7b84f40 Add article. (#1625)
Add article at https://minecraftchest1.wordpress.com/2021/06/05/how-to-install-and-setup-matterbridge/
2021-10-25 19:05:13 +02:00
Wim
1635db93c7 Do not check cache on deleted messages (mattermost). Fixes #1555 (#1624) 2021-10-25 00:08:08 +02:00
Wim
c4fe462d11 Use a new msgID when replacing messages (xmpp). Fixes #1584 (#1623) 2021-10-24 23:15:46 +02:00
Wim
b1f403165d Fix panic in msteams. Fixes #1588 (#1622) 2021-10-24 22:17:46 +02:00
Wim
46e4317b77 Keep the logger on a disabled bridge. Fixes #1616 (#1621) 2021-10-24 19:00:15 +02:00
Alex Vandiver
e3ffbcadd8 Add better error handling on Zulip (#1589)
* zulip: Treat unknown errors with a 10-second backoff.

An unknown error (including an unauthorized error) would fall through
with no calls to time.Sleep, resulting in hammering the server as
quickly as possible.

Add a 10-second sleep in the default error case.  The heartbeat is
left with no explicit sleep, but all other codepaths now contain one.

* version: Move version information into a separate package.

This will allow it to be accessed by other sections of the code.

* zulip: Use the matterbridge version in the user-agent.

Co-authored-by: Wim <wim@42.be>
2021-10-23 23:46:27 +02:00
Wim
b7d73077e5 Remove forbidigo linter 2021-10-23 23:25:15 +02:00
Wim
77f61ee20a Fix gozulipbot vendor 2021-10-23 23:20:34 +02:00
Wim
8967f02fc9 Update gozulipbot dependency (#1618) 2021-10-23 23:13:07 +02:00
Wim
831ff6d0a9 Update matterclient dep. Fixes #1617 2021-10-21 15:57:34 +02:00
Wim
2199174def Bump version 2021-10-18 23:40:20 +02:00
29 changed files with 210 additions and 78 deletions

View File

@@ -35,9 +35,9 @@ jobs:
run: | run: |
mkdir -p output/{win,lin,arm,mac} mkdir -p output/{win,lin,arm,mac}
VERSION=$(git describe --tags) VERSION=$(git describe --tags)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -X main.githash=$(git log --pretty=format:'%h' -n 1)" -o output/lin/matterbridge-$VERSION-linux-amd64 CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -X github.com/42wim/matterbridge/version.GitHash=$(git log --pretty=format:'%h' -n 1)" -o output/lin/matterbridge-$VERSION-linux-amd64
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -X main.githash=$(git log --pretty=format:'%h' -n 1)" -o output/win/matterbridge-$VERSION-windows-amd64.exe CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -X github.com/42wim/matterbridge/version.GitHash=$(git log --pretty=format:'%h' -n 1)" -o output/win/matterbridge-$VERSION-windows-amd64.exe
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -X main.githash=$(git log --pretty=format:'%h' -n 1)" -o output/mac/matterbridge-$VERSION-darwin-amd64 CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -X github.com/42wim/matterbridge/version.GitHash=$(git log --pretty=format:'%h' -n 1)" -o output/mac/matterbridge-$VERSION-darwin-amd64
- name: Upload linux 64-bit - name: Upload linux 64-bit
if: startsWith(matrix.go-version,'1.17') if: startsWith(matrix.go-version,'1.17')
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2

View File

@@ -186,6 +186,8 @@ linters:
- errorlint - errorlint
- nlreturn - nlreturn
- exhaustivestruct - exhaustivestruct
- forbidigo
- wrapcheck
# rules to deal with reported isues # rules to deal with reported isues
issues: issues:

View File

@@ -22,7 +22,7 @@ builds:
- 6 - 6
- 7 - 7
ldflags: ldflags:
- -s -w -X main.githash={{.ShortCommit}} - -s -w -X github.com/42wim/matterbridge/version.GitHash={{.ShortCommit}}
archives: archives:
- -

View File

@@ -3,7 +3,7 @@ FROM alpine:edge AS builder
COPY . /go/src/matterbridge COPY . /go/src/matterbridge
RUN apk --no-cache add go git \ RUN apk --no-cache add go git \
&& cd /go/src/matterbridge \ && cd /go/src/matterbridge \
&& CGO_ENABLED=0 go build -mod vendor -ldflags "-X main.githash=$(git log --pretty=format:'%h' -n 1)" -o /bin/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
FROM alpine FROM alpine
RUN apk --no-cache add ca-certificates mailcap RUN apk --no-cache add ca-certificates mailcap

View File

@@ -164,7 +164,7 @@ See <https://github.com/42wim/matterbridge/wiki>
### Binaries ### Binaries
- Latest stable release [v1.23.0](https://github.com/42wim/matterbridge/releases/latest) - Latest stable release [v1.23.2](https://github.com/42wim/matterbridge/releases/latest)
- Development releases (follows master) can be downloaded [here](https://github.com/42wim/matterbridge/actions) selecting the latest green build and then artifacts. - Development releases (follows master) can be downloaded [here](https://github.com/42wim/matterbridge/actions) selecting the latest green build and then artifacts.
To install or upgrade just download the latest [binary](https://github.com/42wim/matterbridge/releases/latest). On \*nix platforms you may need to make the binary executable - you can do this by running `chmod a+x` on the binary (example: `chmod a+x matterbridge-1.20.0-linux-64bit`). After downloading (and making the binary executable, if necessary), follow the instructions on the [howto](https://github.com/42wim/matterbridge/wiki/How-to-create-your-config) for a step by step walkthrough for creating your configuration. To install or upgrade just download the latest [binary](https://github.com/42wim/matterbridge/releases/latest). On \*nix platforms you may need to make the binary executable - you can do this by running `chmod a+x` on the binary (example: `chmod a+x matterbridge-1.20.0-linux-64bit`). After downloading (and making the binary executable, if necessary), follow the instructions on the [howto](https://github.com/42wim/matterbridge/wiki/How-to-create-your-config) for a step by step walkthrough for creating your configuration.
@@ -336,6 +336,7 @@ See [FAQ](https://github.com/42wim/matterbridge/wiki/FAQ)
- <https://daniele.tech/2019/02/how-to-use-matterbridge-to-connect-2-different-slack-workspaces/> - <https://daniele.tech/2019/02/how-to-use-matterbridge-to-connect-2-different-slack-workspaces/>
- <https://userlinux.net/mattermost-and-matterbridge.html> - <https://userlinux.net/mattermost-and-matterbridge.html>
- <https://nextcloud.com/blog/bridging-chat-services-in-talk/> - <https://nextcloud.com/blog/bridging-chat-services-in-talk/>
- <https://minecraftchest1.wordpress.com/2021/06/05/how-to-install-and-setup-matterbridge/>
- Youtube: [whatsapp - telegram bridging](https://www.youtube.com/watch?v=W-VXISoKtNc) - Youtube: [whatsapp - telegram bridging](https://www.youtube.com/watch?v=W-VXISoKtNc)
## Thanks ## Thanks

View File

@@ -301,6 +301,9 @@ func (b *Bmatrix) handlematrix() {
syncer.OnEventType("m.room.member", b.handleMemberChange) syncer.OnEventType("m.room.member", b.handleMemberChange)
go func() { go func() {
for { for {
if b == nil {
return
}
if err := b.mc.Sync(); err != nil { if err := b.mc.Sync(); err != nil {
b.Log.Println("Sync() returned ", err) b.Log.Println("Sync() returned ", err)
} }

View File

@@ -19,8 +19,10 @@ import (
"golang.org/x/oauth2" "golang.org/x/oauth2"
) )
var defaultScopes = []string{"openid", "profile", "offline_access", "Group.Read.All", "Group.ReadWrite.All"} var (
var attachRE = regexp.MustCompile(`<attachment id=.*?attachment>`) defaultScopes = []string{"openid", "profile", "offline_access", "Group.Read.All", "Group.ReadWrite.All"}
attachRE = regexp.MustCompile(`<attachment id=.*?attachment>`)
)
type Bmsteams struct { type Bmsteams struct {
gc *msgraph.GraphServiceRequestBuilder gc *msgraph.GraphServiceRequestBuilder
@@ -50,7 +52,7 @@ func (b *Bmsteams) Connect() error {
b.Log.Errorf("Couldn't save sessionfile in %s: %s", tokenCachePath, err) b.Log.Errorf("Couldn't save sessionfile in %s: %s", tokenCachePath, err)
} }
// make file readable only for matterbridge user // make file readable only for matterbridge user
err = os.Chmod(tokenCachePath, 0600) err = os.Chmod(tokenCachePath, 0o600)
if err != nil { if err != nil {
b.Log.Errorf("Couldn't change permissions for %s: %s", tokenCachePath, err) b.Log.Errorf("Couldn't change permissions for %s: %s", tokenCachePath, err)
} }
@@ -168,7 +170,7 @@ func (b *Bmsteams) poll(channelName string) error {
} }
// skip non-user message for now. // skip non-user message for now.
if msg.From.User == nil { if msg.From == nil || msg.From.User == nil {
continue continue
} }

View File

@@ -128,7 +128,6 @@ func (b *Bxmpp) Send(msg config.Message) (string, error) {
var msgReplaceID string var msgReplaceID string
msgID := xid.New().String() msgID := xid.New().String()
if msg.ID != "" { if msg.ID != "" {
msgID = msg.ID
msgReplaceID = msg.ID msgReplaceID = msg.ID
} }
b.Log.Debugf("=> Sending message %#v", msg) b.Log.Debugf("=> Sending message %#v", msg)
@@ -284,8 +283,14 @@ func (b *Bxmpp) handleXMPP() error {
for { for {
m, err := b.xc.Recv() m, err := b.xc.Recv()
if err != nil { if err != nil {
// An error together with AvatarData is non-fatal
switch m.(type) {
case xmpp.AvatarData:
continue
default:
return err return err
} }
}
switch v := m.(type) { switch v := m.(type) {
case xmpp.Chat: case xmpp.Chat:

View File

@@ -2,6 +2,7 @@ package bzulip
import ( import (
"encoding/json" "encoding/json"
"fmt"
"io/ioutil" "io/ioutil"
"strconv" "strconv"
"strings" "strings"
@@ -11,6 +12,7 @@ import (
"github.com/42wim/matterbridge/bridge" "github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config" "github.com/42wim/matterbridge/bridge/config"
"github.com/42wim/matterbridge/bridge/helper" "github.com/42wim/matterbridge/bridge/helper"
"github.com/42wim/matterbridge/version"
gzb "github.com/matterbridge/gozulipbot" gzb "github.com/matterbridge/gozulipbot"
) )
@@ -27,7 +29,7 @@ func New(cfg *bridge.Config) bridge.Bridger {
} }
func (b *Bzulip) Connect() error { func (b *Bzulip) Connect() error {
bot := gzb.Bot{APIKey: b.GetString("token"), APIURL: b.GetString("server") + "/api/v1/", Email: b.GetString("login")} bot := gzb.Bot{APIKey: b.GetString("token"), APIURL: b.GetString("server") + "/api/v1/", Email: b.GetString("login"), UserAgent: fmt.Sprintf("matterbridge/%s", version.Release)}
bot.Init() bot.Init()
q, err := bot.RegisterAll() q, err := bot.RegisterAll()
b.q = q b.q = q
@@ -125,6 +127,7 @@ func (b *Bzulip) handleQueue() error {
b.Log.Debug("heartbeat received.") b.Log.Debug("heartbeat received.")
default: default:
b.Log.Debugf("receiving error: %#v", err) b.Log.Debugf("receiving error: %#v", err)
time.Sleep(time.Second * 10)
} }
if err != nil { if err != nil {
continue continue

View File

@@ -1,3 +1,25 @@
# v1.23.2
If you're running whatsapp you should update.
## Bugfix
- whatsapp: Update go-whatsapp version (#1630)
# v1.23.1
If you're running mattermost 6 you should update.
## Bugfix
- mattermost: Do not check cache on deleted messages (mattermost). Fixes #1555 (#1624)
- mattermost: Fix crash on users updating info. Update matterclient dep. Fixes #1617
- matrix: Keep the logger on a disabled bridge. Fixes #1616 (#1621)
- msteams: Fix panic in msteams. Fixes #1588 (#1622)
- xmpp: Do not fail on no avatar data (xmpp) #1529 (#1627)
- xmpp: Use a new msgID when replacing messages (xmpp). Fixes #1584 (#1623)
- zulip: Add better error handling on Zulip (#1589)
# v1.23.0 # v1.23.0
## New features ## New features
@@ -24,8 +46,6 @@
This release couldn't exist without the following contributors: This release couldn't exist without the following contributors:
@powerjungle, @gary-kim, @KingPin, @Benau, @keenan-v1, @tytan652, @KidA001,@minecraftchest1, @irydacea @powerjungle, @gary-kim, @KingPin, @Benau, @keenan-v1, @tytan652, @KidA001,@minecraftchest1, @irydacea
##
# v1.22.3 # v1.22.3
## Bugfixes ## Bugfixes

View File

@@ -110,7 +110,9 @@ func (r *Router) disableBridge(br *bridge.Bridge, err error) bool {
if r.BridgeValues().General.IgnoreFailureOnStart { if r.BridgeValues().General.IgnoreFailureOnStart {
r.logger.Error(err) r.logger.Error(err)
// setting this bridge empty // setting this bridge empty
*br = bridge.Bridge{} *br = bridge.Bridge{
Log: br.Log,
}
return true return true
} }
return false return false

16
go.mod
View File

@@ -5,14 +5,14 @@ require (
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f
github.com/Benau/tgsconverter v0.0.0-20210809170556-99f4a4f6337f github.com/Benau/tgsconverter v0.0.0-20210809170556-99f4a4f6337f
github.com/Philipp15b/go-steam v1.0.1-0.20200727090957-6ae9b3c0a560 github.com/Philipp15b/go-steam v1.0.1-0.20200727090957-6ae9b3c0a560
github.com/Rhymen/go-whatsapp v0.1.2-0.20210615184944-2b8a3e9b8aa2 github.com/Rhymen/go-whatsapp v0.1.2-0.20211102134409-31a2e740845c
github.com/SevereCloud/vksdk/v2 v2.10.0 github.com/SevereCloud/vksdk/v2 v2.10.0
github.com/d5/tengo/v2 v2.8.0 github.com/d5/tengo/v2 v2.8.0
github.com/davecgh/go-spew v1.1.1 github.com/davecgh/go-spew v1.1.1
github.com/fsnotify/fsnotify v1.5.1 github.com/fsnotify/fsnotify v1.5.1
github.com/go-telegram-bot-api/telegram-bot-api v1.0.1-0.20200524105306-7434b0456e81 github.com/go-telegram-bot-api/telegram-bot-api v1.0.1-0.20200524105306-7434b0456e81
github.com/gomarkdown/markdown v0.0.0-20210918233619-6c1113f12c4a github.com/gomarkdown/markdown v0.0.0-20210918233619-6c1113f12c4a
github.com/google/gops v0.3.21 github.com/google/gops v0.3.22
github.com/gorilla/schema v1.2.0 github.com/gorilla/schema v1.2.0
github.com/gorilla/websocket v1.4.2 github.com/gorilla/websocket v1.4.2
github.com/hashicorp/golang-lru v0.5.4 github.com/hashicorp/golang-lru v0.5.4
@@ -25,11 +25,11 @@ require (
github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20211016222428-79310a412696 github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20211016222428-79310a412696
github.com/matterbridge/discordgo v0.21.2-0.20210201201054-fb39a175b4f7 github.com/matterbridge/discordgo v0.21.2-0.20210201201054-fb39a175b4f7
github.com/matterbridge/go-xmpp v0.0.0-20210731150933-5702291c239f github.com/matterbridge/go-xmpp v0.0.0-20210731150933-5702291c239f
github.com/matterbridge/gozulipbot v0.0.0-20200820220548-be5824faa913 github.com/matterbridge/gozulipbot v0.0.0-20211023205727-a19d6c1f3b75
github.com/matterbridge/logrus-prefixed-formatter v0.5.3-0.20200523233437-d971309a77ba github.com/matterbridge/logrus-prefixed-formatter v0.5.3-0.20200523233437-d971309a77ba
github.com/matterbridge/matterclient v0.0.0-20211016195328-346acac403d8 github.com/matterbridge/matterclient v0.0.0-20211024214211-22e762684b4a
github.com/mattermost/mattermost-server/v5 v5.39.0 github.com/mattermost/mattermost-server/v5 v5.39.0
github.com/mattermost/mattermost-server/v6 v6.0.0 github.com/mattermost/mattermost-server/v6 v6.0.2
github.com/mattn/godown v0.0.1 github.com/mattn/godown v0.0.1
github.com/missdeer/golib v1.0.4 github.com/missdeer/golib v1.0.4
github.com/nelsonken/gomf v0.0.0-20180504123937-a9dd2f9deae9 github.com/nelsonken/gomf v0.0.0-20180504123937-a9dd2f9deae9
@@ -46,8 +46,8 @@ require (
github.com/writeas/go-strip-markdown v2.0.1+incompatible github.com/writeas/go-strip-markdown v2.0.1+incompatible
github.com/yaegashi/msgraph.go v0.1.4 github.com/yaegashi/msgraph.go v0.1.4
github.com/zfjagann/golang-ring v0.0.0-20210116075443-7c86fdb43134 github.com/zfjagann/golang-ring v0.0.0-20210116075443-7c86fdb43134
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d golang.org/x/image v0.0.0-20211028202545-6944b10bf410
golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1 golang.org/x/oauth2 v0.0.0-20211028175245-ba495a64dcb5
gomod.garykim.dev/nc-talk v0.3.0 gomod.garykim.dev/nc-talk v0.3.0
gopkg.in/olahol/melody.v1 v1.0.0-20170518105555-d52139073376 gopkg.in/olahol/melody.v1 v1.0.0-20170518105555-d52139073376
layeh.com/gumble v0.0.0-20200818122324-146f9205029b layeh.com/gumble v0.0.0-20200818122324-146f9205029b
@@ -75,7 +75,7 @@ require (
github.com/klauspost/cpuid/v2 v2.0.6 // indirect github.com/klauspost/cpuid/v2 v2.0.6 // indirect
github.com/labstack/gommon v0.3.0 // indirect github.com/labstack/gommon v0.3.0 // indirect
github.com/magiconair/properties v1.8.5 // indirect github.com/magiconair/properties v1.8.5 // indirect
github.com/mattermost/go-i18n v1.11.0 // indirect github.com/mattermost/go-i18n v1.11.1-0.20211013152124-5c415071e404 // indirect
github.com/mattermost/ldap v0.0.0-20201202150706-ee0e6284187d // indirect github.com/mattermost/ldap v0.0.0-20201202150706-ee0e6284187d // indirect
github.com/mattermost/logr v1.0.13 // indirect github.com/mattermost/logr v1.0.13 // indirect
github.com/mattermost/logr/v2 v2.0.10 // indirect github.com/mattermost/logr/v2 v2.0.10 // indirect

30
go.sum
View File

@@ -95,8 +95,8 @@ github.com/Philipp15b/go-steam v1.0.1-0.20200727090957-6ae9b3c0a560/go.mod h1:o3
github.com/PuerkitoBio/goquery v1.4.1/go.mod h1:T9ezsOHcCrDCgA8aF1Cqr3sSYbO/xgdy8/R/XiIMAhA= github.com/PuerkitoBio/goquery v1.4.1/go.mod h1:T9ezsOHcCrDCgA8aF1Cqr3sSYbO/xgdy8/R/XiIMAhA=
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
github.com/PuerkitoBio/goquery v1.7.0/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/PuerkitoBio/goquery v1.7.0/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
github.com/Rhymen/go-whatsapp v0.1.2-0.20210615184944-2b8a3e9b8aa2 h1:xEhWgQl3hCOtFph6nWpTjVgAdPmAk0zUTENPDb3HJ7Y= github.com/Rhymen/go-whatsapp v0.1.2-0.20211102134409-31a2e740845c h1:4mIZQXKYBymQ9coA82nNyG/CjicMNLBZ8cPVrhNUM3g=
github.com/Rhymen/go-whatsapp v0.1.2-0.20210615184944-2b8a3e9b8aa2/go.mod h1:DNSFRLFDFIqm2+0aJzSOVfn25020vldM4SRqz6YtLgI= github.com/Rhymen/go-whatsapp v0.1.2-0.20211102134409-31a2e740845c/go.mod h1:DNSFRLFDFIqm2+0aJzSOVfn25020vldM4SRqz6YtLgI=
github.com/RoaringBitmap/roaring v0.4.23/go.mod h1:D0gp8kJQgE1A4LQ5wFLggQEyvDi06Mq5mKs52e1TwOo= github.com/RoaringBitmap/roaring v0.4.23/go.mod h1:D0gp8kJQgE1A4LQ5wFLggQEyvDi06Mq5mKs52e1TwOo=
github.com/RoaringBitmap/roaring v0.8.0/go.mod h1:jdT9ykXwHFNdJbEtxePexlFYH9LXucApeS0/+/g+p1I= github.com/RoaringBitmap/roaring v0.8.0/go.mod h1:jdT9ykXwHFNdJbEtxePexlFYH9LXucApeS0/+/g+p1I=
github.com/SevereCloud/vksdk/v2 v2.10.0 h1:HFTKrRmWaPuRn46PtWjHFlJNElyWrNP3+J2b4j9ztpY= github.com/SevereCloud/vksdk/v2 v2.10.0 h1:HFTKrRmWaPuRn46PtWjHFlJNElyWrNP3+J2b4j9ztpY=
@@ -400,8 +400,8 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gops v0.3.21 h1:SmULDdFdSLaPZHR3FgPJfNFfrrohoHUgC9DenFuGrUE= github.com/google/gops v0.3.22 h1:lyvhDxfPLHAOR2xIYwjPhN387qHxyU21Sk9sz/GhmhQ=
github.com/google/gops v0.3.21/go.mod h1:7diIdLsqpCihPSX3fQagksT/Ku/y4RL9LHTlKyEUDl8= github.com/google/gops v0.3.22/go.mod h1:7diIdLsqpCihPSX3fQagksT/Ku/y4RL9LHTlKyEUDl8=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
@@ -661,14 +661,15 @@ github.com/matterbridge/discordgo v0.21.2-0.20210201201054-fb39a175b4f7 h1:4J2YZ
github.com/matterbridge/discordgo v0.21.2-0.20210201201054-fb39a175b4f7/go.mod h1:411nZYv0UMMrtppR5glXop1foboJiFAowy+42U+Ahvw= github.com/matterbridge/discordgo v0.21.2-0.20210201201054-fb39a175b4f7/go.mod h1:411nZYv0UMMrtppR5glXop1foboJiFAowy+42U+Ahvw=
github.com/matterbridge/go-xmpp v0.0.0-20210731150933-5702291c239f h1:1hfavl4YOoRjgTBWezeX8WXCGnhrxnfEgQtb38wQnyg= github.com/matterbridge/go-xmpp v0.0.0-20210731150933-5702291c239f h1:1hfavl4YOoRjgTBWezeX8WXCGnhrxnfEgQtb38wQnyg=
github.com/matterbridge/go-xmpp v0.0.0-20210731150933-5702291c239f/go.mod h1:ECDRehsR9TYTKCAsRS8/wLeOk6UUqDydw47ln7wG41Q= github.com/matterbridge/go-xmpp v0.0.0-20210731150933-5702291c239f/go.mod h1:ECDRehsR9TYTKCAsRS8/wLeOk6UUqDydw47ln7wG41Q=
github.com/matterbridge/gozulipbot v0.0.0-20200820220548-be5824faa913 h1:5UGr9fLsvAvhjP6i5XJmd0ZIwYVR2gZCzU1lJZ7wfLY= github.com/matterbridge/gozulipbot v0.0.0-20211023205727-a19d6c1f3b75 h1:GslZKF7lW7oSisycGLpxPO+TnKJuA4VZuTWIfYZrClc=
github.com/matterbridge/gozulipbot v0.0.0-20200820220548-be5824faa913/go.mod h1:yAjnZ34DuDyPHMPHHjOsTk/FefW4JJjoMMCGt/8uuQA= github.com/matterbridge/gozulipbot v0.0.0-20211023205727-a19d6c1f3b75/go.mod h1:yAjnZ34DuDyPHMPHHjOsTk/FefW4JJjoMMCGt/8uuQA=
github.com/matterbridge/logrus-prefixed-formatter v0.5.3-0.20200523233437-d971309a77ba h1:XleOY4IjAEIcxAh+IFwT5JT5Ze3RHiYz6m+4ZfZ0rc0= github.com/matterbridge/logrus-prefixed-formatter v0.5.3-0.20200523233437-d971309a77ba h1:XleOY4IjAEIcxAh+IFwT5JT5Ze3RHiYz6m+4ZfZ0rc0=
github.com/matterbridge/logrus-prefixed-formatter v0.5.3-0.20200523233437-d971309a77ba/go.mod h1:iXGEotOvwI1R1SjLxRc+BF5rUORTMtE0iMZBT2lxqAU= github.com/matterbridge/logrus-prefixed-formatter v0.5.3-0.20200523233437-d971309a77ba/go.mod h1:iXGEotOvwI1R1SjLxRc+BF5rUORTMtE0iMZBT2lxqAU=
github.com/matterbridge/matterclient v0.0.0-20211016195328-346acac403d8 h1:6U64ukl/GOvjPTKvUE9jmMLlvJCa+M2aoiq7myoE8RE= github.com/matterbridge/matterclient v0.0.0-20211024214211-22e762684b4a h1:j5/5gEHtACfrG/Exygfjqj0ip/zRgsa8KaAyuvO2c5Y=
github.com/matterbridge/matterclient v0.0.0-20211016195328-346acac403d8/go.mod h1:Gh3tFUjkcPIBBeEkfXBbGio4ONMMKNmlmGECvXLY0TE= github.com/matterbridge/matterclient v0.0.0-20211024214211-22e762684b4a/go.mod h1:Gh3tFUjkcPIBBeEkfXBbGio4ONMMKNmlmGECvXLY0TE=
github.com/mattermost/go-i18n v1.11.0 h1:1hLKqn/ZvhZ80OekjVPGYcCrBfMz+YxNNgqS+beL7zE=
github.com/mattermost/go-i18n v1.11.0/go.mod h1:RyS7FDNQlzF1PsjbJWHRI35exqaKGSO9qD4iv8QjE34= github.com/mattermost/go-i18n v1.11.0/go.mod h1:RyS7FDNQlzF1PsjbJWHRI35exqaKGSO9qD4iv8QjE34=
github.com/mattermost/go-i18n v1.11.1-0.20211013152124-5c415071e404 h1:Khvh6waxG1cHc4Cz5ef9n3XVCxRWpAKUtqg9PJl5+y8=
github.com/mattermost/go-i18n v1.11.1-0.20211013152124-5c415071e404/go.mod h1:RyS7FDNQlzF1PsjbJWHRI35exqaKGSO9qD4iv8QjE34=
github.com/mattermost/gorp v1.6.2-0.20210419141818-0904a6a388d3/go.mod h1:QCQ3U0M9T/BlAdjKFJo0I1oe/YAgbyjNdhU8bpOLafk= github.com/mattermost/gorp v1.6.2-0.20210419141818-0904a6a388d3/go.mod h1:QCQ3U0M9T/BlAdjKFJo0I1oe/YAgbyjNdhU8bpOLafk=
github.com/mattermost/gorp v1.6.2-0.20210714143452-8b50f5209a7f/go.mod h1:QCQ3U0M9T/BlAdjKFJo0I1oe/YAgbyjNdhU8bpOLafk= github.com/mattermost/gorp v1.6.2-0.20210714143452-8b50f5209a7f/go.mod h1:QCQ3U0M9T/BlAdjKFJo0I1oe/YAgbyjNdhU8bpOLafk=
github.com/mattermost/gosaml2 v0.3.3/go.mod h1:Z429EIOiEi9kbq6yHoApfzlcXpa6dzRDc6pO+Vy2Ksk= github.com/mattermost/gosaml2 v0.3.3/go.mod h1:Z429EIOiEi9kbq6yHoApfzlcXpa6dzRDc6pO+Vy2Ksk=
@@ -681,8 +682,9 @@ github.com/mattermost/logr/v2 v2.0.10 h1:i6rJbuX/EkBM9maM8M0eJ3rxB+fsBKNslPvzSlA
github.com/mattermost/logr/v2 v2.0.10/go.mod h1:mpPp935r5dIkFDo2y9Q87cQWhFR/4xXpNh0k/y8Hmwg= github.com/mattermost/logr/v2 v2.0.10/go.mod h1:mpPp935r5dIkFDo2y9Q87cQWhFR/4xXpNh0k/y8Hmwg=
github.com/mattermost/mattermost-server/v5 v5.39.0 h1:Y67Z7HIP8DGmztXfZvfqS2ChD3klulQLlntFq41D33Y= github.com/mattermost/mattermost-server/v5 v5.39.0 h1:Y67Z7HIP8DGmztXfZvfqS2ChD3klulQLlntFq41D33Y=
github.com/mattermost/mattermost-server/v5 v5.39.0/go.mod h1:MDmVSmsSsqwNkuZ7rQ0osuXVCzrR1IUqGR7I0QU91sY= github.com/mattermost/mattermost-server/v5 v5.39.0/go.mod h1:MDmVSmsSsqwNkuZ7rQ0osuXVCzrR1IUqGR7I0QU91sY=
github.com/mattermost/mattermost-server/v6 v6.0.0 h1:iSe5XGow5sKUBe9eKXRLoPoLJaiMYXzQ/uNED4lXLIA=
github.com/mattermost/mattermost-server/v6 v6.0.0/go.mod h1:+S8CsNEPv1FOl1usaPBQ6Gu9+Sm1Cc9YdU/Qh1YMGVI= github.com/mattermost/mattermost-server/v6 v6.0.0/go.mod h1:+S8CsNEPv1FOl1usaPBQ6Gu9+Sm1Cc9YdU/Qh1YMGVI=
github.com/mattermost/mattermost-server/v6 v6.0.2 h1:LSwaWjPFlundI+b+r51Qv1zOkqEwvRR6M/Trr/D/Tb8=
github.com/mattermost/mattermost-server/v6 v6.0.2/go.mod h1:I7hgNyInWiVaIcGjYMDoJufO1E4SbK3Zj+3OEIk417g=
github.com/mattermost/rsc v0.0.0-20160330161541-bbaefb05eaa0/go.mod h1:nV5bfVpT//+B1RPD2JvRnxbkLmJEYXmRaaVl15fsXjs= github.com/mattermost/rsc v0.0.0-20160330161541-bbaefb05eaa0/go.mod h1:nV5bfVpT//+B1RPD2JvRnxbkLmJEYXmRaaVl15fsXjs=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
@@ -1204,8 +1206,8 @@ golang.org/x/image v0.0.0-20190321063152-3fc05d484e9f/go.mod h1:kZ7UVZpmo3dzQBMx
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20210622092929-e6eecd499c2c/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= golang.org/x/image v0.0.0-20210622092929-e6eecd499c2c/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d h1:RNPAfi2nHY7C2srAV8A49jpsYr0ADedCk1wq6fTMTvs= golang.org/x/image v0.0.0-20211028202545-6944b10bf410 h1:hTftEOvwiOq2+O8k2D5/Q7COC7k5Qcrgc2TFURJYnvQ=
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20181217174547-8f45f776aaf1/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181217174547-8f45f776aaf1/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
@@ -1315,8 +1317,8 @@ golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ
golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1 h1:B333XXssMuKQeBwiNODx4TupZy7bf4sxFZnN2ZOcvUE= golang.org/x/oauth2 v0.0.0-20211028175245-ba495a64dcb5 h1:v79phzBz03tsVCUTbvTBmmC3CUXF5mKYt7DA4ZVldpM=
golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20211028175245-ba495a64dcb5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/perf v0.0.0-20180704124530-6e6d33e29852/go.mod h1:JLpeXjPJfIyPr5TlbXLkXWLhP8nz10XfvxElABhCtcw= golang.org/x/perf v0.0.0-20180704124530-6e6d33e29852/go.mod h1:JLpeXjPJfIyPr5TlbXLkXWLhP8nz10XfvxElABhCtcw=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

View File

@@ -10,15 +10,13 @@ import (
"github.com/42wim/matterbridge/bridge/config" "github.com/42wim/matterbridge/bridge/config"
"github.com/42wim/matterbridge/gateway" "github.com/42wim/matterbridge/gateway"
"github.com/42wim/matterbridge/gateway/bridgemap" "github.com/42wim/matterbridge/gateway/bridgemap"
"github.com/42wim/matterbridge/version"
"github.com/google/gops/agent" "github.com/google/gops/agent"
prefixed "github.com/matterbridge/logrus-prefixed-formatter" prefixed "github.com/matterbridge/logrus-prefixed-formatter"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
var ( var (
version = "1.23.0"
githash string
flagConfig = flag.String("conf", "matterbridge.toml", "config file") flagConfig = flag.String("conf", "matterbridge.toml", "config file")
flagDebug = flag.Bool("debug", false, "enable debug") flagDebug = flag.Bool("debug", false, "enable debug")
flagVersion = flag.Bool("version", false, "show version") flagVersion = flag.Bool("version", false, "show version")
@@ -28,7 +26,7 @@ var (
func main() { func main() {
flag.Parse() flag.Parse()
if *flagVersion { if *flagVersion {
fmt.Printf("version: %s %s\n", version, githash) fmt.Printf("version: %s %s\n", version.Release, version.GitHash)
return return
} }
@@ -43,8 +41,8 @@ func main() {
} }
} }
logger.Printf("Running version %s %s", version, githash) logger.Printf("Running version %s %s", version.Release, version.GitHash)
if strings.Contains(version, "-dev") { if strings.Contains(version.Release, "-dev") {
logger.Println("WARNING: THIS IS A DEVELOPMENT VERSION. Things may break.") logger.Println("WARNING: THIS IS A DEVELOPMENT VERSION. Things may break.")
} }

View File

@@ -9,7 +9,7 @@ import (
func (m *MMClient) parseActionPost(rmsg *Message) { func (m *MMClient) parseActionPost(rmsg *Message) {
// add post to cache, if it already exists don't relay this again. // add post to cache, if it already exists don't relay this again.
// this should fix reposts // this should fix reposts
if ok, _ := m.lruCache.ContainsOrAdd(digestString(rmsg.Raw.Data["post"].(string)), true); ok { if ok, _ := m.lruCache.ContainsOrAdd(digestString(rmsg.Raw.Data["post"].(string)), true); ok && rmsg.Raw.Event != model.WEBSOCKET_EVENT_POST_DELETED {
m.logger.Debugf("message %#v in cache, not processing again", rmsg.Raw.Data["post"].(string)) m.logger.Debugf("message %#v in cache, not processing again", rmsg.Raw.Data["post"].(string))
rmsg.Text = "" rmsg.Text = ""
return return

View File

@@ -5,7 +5,7 @@ RUN apk add \
go \ go \
git \ git \
&& cd /go/src/matterbridge \ && cd /go/src/matterbridge \
&& go build -mod vendor -ldflags "-X main.githash=$(git log --pretty=format:'%h' -n 1)" -o /bin/matterbridge && go build -mod vendor -ldflags "-X github.com/42wim/matterbridge/version.GitHash=$(git log --pretty=format:'%h' -n 1)" -o /bin/matterbridge
FROM alpine FROM alpine
RUN apk --no-cache add \ RUN apk --no-cache add \

View File

@@ -18,7 +18,7 @@ import (
) )
//represents the WhatsAppWeb client version //represents the WhatsAppWeb client version
var waVersion = []int{2, 2121, 6} var waVersion = []int{2, 2142, 12}
/* /*
Session contains session individual information. To be able to resume the connection without scanning the qr code Session contains session individual information. To be able to resume the connection without scanning the qr code

View File

@@ -107,7 +107,7 @@ func Listen(opts Options) error {
} }
var lc net.ListenConfig var lc net.ListenConfig
if opts.ReuseSocketAddrAndPort { if opts.ReuseSocketAddrAndPort {
lc.Control = setsockoptReuseAddrAndPort lc.Control = setReuseAddrAndPortSockopts
} }
listener, err = lc.Listen(context.Background(), "tcp", addr) listener, err = lc.Listen(context.Background(), "tcp", addr)
if err != nil { if err != nil {

View File

@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !js && !plan9 && !windows //go:build !js && !plan9 && !solaris && !windows
// +build !js,!plan9,!windows // +build !js,!plan9,!solaris,!windows
package agent package agent
@@ -13,10 +13,10 @@ import (
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )
// setsockoptReuseAddrAndPort sets the SO_REUSEADDR and SO_REUSEPORT socket // setReuseAddrAndPortSockopts sets the SO_REUSEADDR and SO_REUSEPORT socket
// options on c's underlying socket in order to increase the chance to re-bind() // options on c's underlying socket in order to increase the chance to re-bind()
// to the same address and port upon agent restart. // to the same address and port upon agent restart.
func setsockoptReuseAddrAndPort(network, address string, c syscall.RawConn) error { func setReuseAddrAndPortSockopts(network, address string, c syscall.RawConn) error {
var soerr error var soerr error
if err := c.Control(func(su uintptr) { if err := c.Control(func(su uintptr) {
sock := int(su) sock := int(su)

View File

@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build (js && wasm) || plan9 || windows //go:build (js && wasm) || plan9 || solaris || windows
// +build js,wasm plan9 windows // +build js,wasm plan9 solaris windows
package agent package agent
import "syscall" import "syscall"
func setsockoptReuseAddrAndPort(network, address string, c syscall.RawConn) error { func setReuseAddrAndPortSockopts(network, address string, c syscall.RawConn) error {
return nil return nil
} }

View File

@@ -18,6 +18,7 @@ type Bot struct {
Client Doer Client Doer
Backoff time.Duration Backoff time.Duration
Retries int64 Retries int64
UserAgent string
} }
type Doer interface { type Doer interface {
@@ -117,6 +118,11 @@ func (b *Bot) Subscribe(streams []string) (*http.Response, error) {
body := "subscriptions=" + string(bodyBts) body := "subscriptions=" + string(bodyBts)
req, err := b.constructRequest("POST", "users/me/subscriptions", body) req, err := b.constructRequest("POST", "users/me/subscriptions", body)
if b.UserAgent != "" {
req.Header.Set("User-Agent", b.UserAgent)
} else {
req.Header.Set("User-Agent", fmt.Sprintf("gozulipbot/%s", Release))
}
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -174,6 +180,20 @@ func (b *Bot) RegisterEvents(ets []EventType, n Narrow) (*Queue, error) {
return nil, err return nil, err
} }
defer resp.Body.Close() defer resp.Body.Close()
if resp.StatusCode != 200 {
// Try to parse the error out of the body
body, err := ioutil.ReadAll(resp.Body)
if err == nil {
var jsonErr map[string]string
err = json.Unmarshal(body, &jsonErr)
if err == nil {
if msg, ok := jsonErr["msg"]; ok {
return nil, fmt.Errorf("Failed to register: %s", msg)
}
}
}
return nil, fmt.Errorf("Got non-200 response code when registering: %d", resp.StatusCode)
}
body, err := ioutil.ReadAll(resp.Body) body, err := ioutil.ReadAll(resp.Body)
if err != nil { if err != nil {

View File

@@ -151,6 +151,8 @@ func (q *Queue) GetEvents() ([]EventMessage, error) {
switch { switch {
case resp.StatusCode == 429: case resp.StatusCode == 429:
return nil, BackoffError return nil, BackoffError
case resp.StatusCode == 401:
return nil, UnauthorizedError
case resp.StatusCode == 403: case resp.StatusCode == 403:
return nil, UnauthorizedError return nil, UnauthorizedError
case resp.StatusCode >= 400: case resp.StatusCode >= 400:

5
vendor/github.com/matterbridge/gozulipbot/version.go generated vendored Normal file
View File

@@ -0,0 +1,5 @@
package gozulipbot
var (
Release = "1.0-dev"
)

View File

@@ -217,7 +217,7 @@ func (m *Client) UploadFile(data []byte, channelID string, filename string) (str
func (m *Client) parseActionPost(rmsg *Message) { func (m *Client) parseActionPost(rmsg *Message) {
// add post to cache, if it already exists don't relay this again. // add post to cache, if it already exists don't relay this again.
// this should fix reposts // this should fix reposts
if ok, _ := m.lruCache.ContainsOrAdd(digestString(rmsg.Raw.GetData()["post"].(string)), true); ok { if ok, _ := m.lruCache.ContainsOrAdd(digestString(rmsg.Raw.GetData()["post"].(string)), true); ok && rmsg.Raw.EventType() != model.WebsocketEventPostDeleted {
m.logger.Debugf("message %#v in cache, not processing again", rmsg.Raw.GetData()["post"].(string)) m.logger.Debugf("message %#v in cache, not processing again", rmsg.Raw.GetData()["post"].(string))
rmsg.Text = "" rmsg.Text = ""
@@ -264,9 +264,8 @@ func (m *Client) parseMessage(rmsg *Message) {
case model.WebsocketEventPosted, model.WebsocketEventPostEdited, model.WebsocketEventPostDeleted: case model.WebsocketEventPosted, model.WebsocketEventPostEdited, model.WebsocketEventPostDeleted:
m.parseActionPost(rmsg) m.parseActionPost(rmsg)
case "user_updated": case "user_updated":
user := rmsg.Raw.GetData()["user"].(map[string]interface{}) if user, ok := rmsg.Raw.GetData()["user"].(*model.User); ok {
if _, ok := user["id"].(string); ok { m.UpdateUser(user.Id)
m.UpdateUser(user["id"].(string))
} }
case "group_added": case "group_added":
if err := m.UpdateChannels(); err != nil { if err := m.UpdateChannels(); err != nil {

View File

@@ -386,11 +386,12 @@ func (b *Bundle) translate(lang *language.Language, translationID string, args .
countInt, ok := count.(int) countInt, ok := count.(int)
if ok && countInt > 1 { if ok && countInt > 1 {
template = translation.Template(language.Other) template = translation.Template(language.Other)
}
}
if template == nil { if template == nil {
return translationID return translationID
} }
}
}
s := template.Execute(data) s := template.Execute(data)
if s == "" { if s == "" {

View File

@@ -15,44 +15,88 @@ func AuditModelTypeConv(val interface{}) (newVal interface{}, converted bool) {
switch v := val.(type) { switch v := val.(type) {
case *Channel: case *Channel:
return newAuditChannel(v), true return newAuditChannel(v), true
case Channel:
return newAuditChannel(&v), true
case *Team: case *Team:
return newAuditTeam(v), true return newAuditTeam(v), true
case Team:
return newAuditTeam(&v), true
case *User: case *User:
return newAuditUser(v), true return newAuditUser(v), true
case User:
return newAuditUser(&v), true
case *UserPatch:
return newAuditUserPatch(v), true
case UserPatch:
return newAuditUserPatch(&v), true
case *Command: case *Command:
return newAuditCommand(v), true return newAuditCommand(v), true
case Command:
return newAuditCommand(&v), true
case *CommandArgs: case *CommandArgs:
return newAuditCommandArgs(v), true return newAuditCommandArgs(v), true
case CommandArgs:
return newAuditCommandArgs(&v), true
case *Bot: case *Bot:
return newAuditBot(v), true return newAuditBot(v), true
case Bot:
return newAuditBot(&v), true
case *ChannelModerationPatch: case *ChannelModerationPatch:
return newAuditChannelModerationPatch(v), true return newAuditChannelModerationPatch(v), true
case ChannelModerationPatch:
return newAuditChannelModerationPatch(&v), true
case *Emoji: case *Emoji:
return newAuditEmoji(v), true return newAuditEmoji(v), true
case Emoji:
return newAuditEmoji(&v), true
case *FileInfo: case *FileInfo:
return newAuditFileInfo(v), true return newAuditFileInfo(v), true
case FileInfo:
return newAuditFileInfo(&v), true
case *Group: case *Group:
return newAuditGroup(v), true return newAuditGroup(v), true
case Group:
return newAuditGroup(&v), true
case *Job: case *Job:
return newAuditJob(v), true return newAuditJob(v), true
case Job:
return newAuditJob(&v), true
case *OAuthApp: case *OAuthApp:
return newAuditOAuthApp(v), true return newAuditOAuthApp(v), true
case OAuthApp:
return newAuditOAuthApp(&v), true
case *Post: case *Post:
return newAuditPost(v), true return newAuditPost(v), true
case Post:
return newAuditPost(&v), true
case *Role: case *Role:
return newAuditRole(v), true return newAuditRole(v), true
case Role:
return newAuditRole(&v), true
case *Scheme: case *Scheme:
return newAuditScheme(v), true return newAuditScheme(v), true
case Scheme:
return newAuditScheme(&v), true
case *SchemeRoles: case *SchemeRoles:
return newAuditSchemeRoles(v), true return newAuditSchemeRoles(v), true
case SchemeRoles:
return newAuditSchemeRoles(&v), true
case *Session: case *Session:
return newAuditSession(v), true return newAuditSession(v), true
case Session:
return newAuditSession(&v), true
case *IncomingWebhook: case *IncomingWebhook:
return newAuditIncomingWebhook(v), true return newAuditIncomingWebhook(v), true
case IncomingWebhook:
return newAuditIncomingWebhook(&v), true
case *OutgoingWebhook: case *OutgoingWebhook:
return newAuditOutgoingWebhook(v), true return newAuditOutgoingWebhook(v), true
case OutgoingWebhook:
return newAuditOutgoingWebhook(&v), true
case *RemoteCluster: case *RemoteCluster:
return newRemoteCluster(v), true return newRemoteCluster(v), true
case RemoteCluster:
return newRemoteCluster(&v), true
} }
return val, false return val, false
} }
@@ -128,6 +172,21 @@ func newAuditUser(u *User) auditUser {
return user return user
} }
type auditUserPatch struct {
Name string
}
// newAuditUserPatch creates a simplified representation of UserPatch for output to audit log.
func newAuditUserPatch(up *UserPatch) auditUserPatch {
var userPatch auditUserPatch
if up != nil {
if up.Username != nil {
userPatch.Name = *up.Username
}
}
return userPatch
}
func (u auditUser) MarshalJSONObject(enc *gojay.Encoder) { func (u auditUser) MarshalJSONObject(enc *gojay.Encoder) {
enc.StringKey("id", u.ID) enc.StringKey("id", u.ID)
enc.StringKey("name", u.Name) enc.StringKey("name", u.Name)

View File

@@ -13,6 +13,8 @@ import (
// It should be maintained in chronological order with most current // It should be maintained in chronological order with most current
// release at the front of the list. // release at the front of the list.
var versions = []string{ var versions = []string{
"6.0.2",
"6.0.1",
"6.0.0", "6.0.0",
"5.39.0", "5.39.0",
"5.38.0", "5.38.0",

16
vendor/modules.txt vendored
View File

@@ -25,7 +25,7 @@ github.com/Philipp15b/go-steam/protocol/steamlang
github.com/Philipp15b/go-steam/rwu github.com/Philipp15b/go-steam/rwu
github.com/Philipp15b/go-steam/socialcache github.com/Philipp15b/go-steam/socialcache
github.com/Philipp15b/go-steam/steamid github.com/Philipp15b/go-steam/steamid
# github.com/Rhymen/go-whatsapp v0.1.2-0.20210615184944-2b8a3e9b8aa2 # github.com/Rhymen/go-whatsapp v0.1.2-0.20211102134409-31a2e740845c
## explicit; go 1.13 ## explicit; go 1.13
github.com/Rhymen/go-whatsapp github.com/Rhymen/go-whatsapp
github.com/Rhymen/go-whatsapp/binary github.com/Rhymen/go-whatsapp/binary
@@ -92,7 +92,7 @@ github.com/gomarkdown/markdown
github.com/gomarkdown/markdown/ast github.com/gomarkdown/markdown/ast
github.com/gomarkdown/markdown/html github.com/gomarkdown/markdown/html
github.com/gomarkdown/markdown/parser github.com/gomarkdown/markdown/parser
# github.com/google/gops v0.3.21 # github.com/google/gops v0.3.22
## explicit; go 1.12 ## explicit; go 1.12
github.com/google/gops/agent github.com/google/gops/agent
github.com/google/gops/internal github.com/google/gops/internal
@@ -183,16 +183,16 @@ github.com/matterbridge/discordgo
# github.com/matterbridge/go-xmpp v0.0.0-20210731150933-5702291c239f # github.com/matterbridge/go-xmpp v0.0.0-20210731150933-5702291c239f
## explicit ## explicit
github.com/matterbridge/go-xmpp github.com/matterbridge/go-xmpp
# github.com/matterbridge/gozulipbot v0.0.0-20200820220548-be5824faa913 # github.com/matterbridge/gozulipbot v0.0.0-20211023205727-a19d6c1f3b75
## explicit ## explicit
github.com/matterbridge/gozulipbot github.com/matterbridge/gozulipbot
# github.com/matterbridge/logrus-prefixed-formatter v0.5.3-0.20200523233437-d971309a77ba # github.com/matterbridge/logrus-prefixed-formatter v0.5.3-0.20200523233437-d971309a77ba
## explicit ## explicit
github.com/matterbridge/logrus-prefixed-formatter github.com/matterbridge/logrus-prefixed-formatter
# github.com/matterbridge/matterclient v0.0.0-20211016195328-346acac403d8 # github.com/matterbridge/matterclient v0.0.0-20211024214211-22e762684b4a
## explicit; go 1.16 ## explicit; go 1.16
github.com/matterbridge/matterclient github.com/matterbridge/matterclient
# github.com/mattermost/go-i18n v1.11.0 # github.com/mattermost/go-i18n v1.11.1-0.20211013152124-5c415071e404
## explicit ## explicit
github.com/mattermost/go-i18n/i18n github.com/mattermost/go-i18n/i18n
github.com/mattermost/go-i18n/i18n/bundle github.com/mattermost/go-i18n/i18n/bundle
@@ -221,7 +221,7 @@ github.com/mattermost/mattermost-server/v5/shared/i18n
github.com/mattermost/mattermost-server/v5/shared/markdown github.com/mattermost/mattermost-server/v5/shared/markdown
github.com/mattermost/mattermost-server/v5/shared/mlog github.com/mattermost/mattermost-server/v5/shared/mlog
github.com/mattermost/mattermost-server/v5/utils/jsonutils github.com/mattermost/mattermost-server/v5/utils/jsonutils
# github.com/mattermost/mattermost-server/v6 v6.0.0 # github.com/mattermost/mattermost-server/v6 v6.0.2
## explicit; go 1.15 ## explicit; go 1.15
github.com/mattermost/mattermost-server/v6/model github.com/mattermost/mattermost-server/v6/model
github.com/mattermost/mattermost-server/v6/services/timezones github.com/mattermost/mattermost-server/v6/services/timezones
@@ -458,7 +458,7 @@ golang.org/x/crypto/scrypt
golang.org/x/crypto/ssh golang.org/x/crypto/ssh
golang.org/x/crypto/ssh/internal/bcrypt_pbkdf golang.org/x/crypto/ssh/internal/bcrypt_pbkdf
golang.org/x/crypto/ssh/terminal golang.org/x/crypto/ssh/terminal
# golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d # golang.org/x/image v0.0.0-20211028202545-6944b10bf410
## explicit; go 1.12 ## explicit; go 1.12
golang.org/x/image/riff golang.org/x/image/riff
golang.org/x/image/vp8 golang.org/x/image/vp8
@@ -477,7 +477,7 @@ golang.org/x/net/http2/hpack
golang.org/x/net/idna golang.org/x/net/idna
golang.org/x/net/publicsuffix golang.org/x/net/publicsuffix
golang.org/x/net/websocket golang.org/x/net/websocket
# golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1 # golang.org/x/oauth2 v0.0.0-20211028175245-ba495a64dcb5
## explicit; go 1.11 ## explicit; go 1.11
golang.org/x/oauth2 golang.org/x/oauth2
golang.org/x/oauth2/clientcredentials golang.org/x/oauth2/clientcredentials

6
version/version.go Normal file
View File

@@ -0,0 +1,6 @@
package version
var (
Release = "1.23.2"
GitHash string
)