Compare commits

...

15 Commits

Author SHA1 Message Date
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
28 changed files with 197 additions and 73 deletions

View File

@@ -35,9 +35,9 @@ jobs:
run: |
mkdir -p output/{win,lin,arm,mac}
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=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=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=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 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 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
if: startsWith(matrix.go-version,'1.17')
uses: actions/upload-artifact@v2

View File

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

View File

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

View File

@@ -3,7 +3,7 @@ FROM alpine:edge AS builder
COPY . /go/src/matterbridge
RUN apk --no-cache add go git \
&& 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
RUN apk --no-cache add ca-certificates mailcap

View File

@@ -164,7 +164,7 @@ See <https://github.com/42wim/matterbridge/wiki>
### Binaries
- Latest stable release [v1.23.0](https://github.com/42wim/matterbridge/releases/latest)
- Latest stable release [v1.23.1](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.
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://userlinux.net/mattermost-and-matterbridge.html>
- <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)
## Thanks

View File

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

View File

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

View File

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

View File

@@ -2,6 +2,7 @@ package bzulip
import (
"encoding/json"
"fmt"
"io/ioutil"
"strconv"
"strings"
@@ -11,6 +12,7 @@ import (
"github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config"
"github.com/42wim/matterbridge/bridge/helper"
"github.com/42wim/matterbridge/version"
gzb "github.com/matterbridge/gozulipbot"
)
@@ -27,7 +29,7 @@ func New(cfg *bridge.Config) bridge.Bridger {
}
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()
q, err := bot.RegisterAll()
b.q = q
@@ -125,6 +127,7 @@ func (b *Bzulip) handleQueue() error {
b.Log.Debug("heartbeat received.")
default:
b.Log.Debugf("receiving error: %#v", err)
time.Sleep(time.Second * 10)
}
if err != nil {
continue

View File

@@ -1,3 +1,17 @@
# 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
## New features
@@ -24,8 +38,6 @@
This release couldn't exist without the following contributors:
@powerjungle, @gary-kim, @KingPin, @Benau, @keenan-v1, @tytan652, @KidA001,@minecraftchest1, @irydacea
##
# v1.22.3
## Bugfixes

View File

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

14
go.mod
View File

@@ -12,7 +12,7 @@ require (
github.com/fsnotify/fsnotify v1.5.1
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/google/gops v0.3.21
github.com/google/gops v0.3.22
github.com/gorilla/schema v1.2.0
github.com/gorilla/websocket v1.4.2
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/discordgo v0.21.2-0.20210201201054-fb39a175b4f7
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/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/v6 v6.0.0
github.com/mattermost/mattermost-server/v6 v6.0.2
github.com/mattn/godown v0.0.1
github.com/missdeer/golib v1.0.4
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/yaegashi/msgraph.go v0.1.4
github.com/zfjagann/golang-ring v0.0.0-20210116075443-7c86fdb43134
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d
golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1
golang.org/x/image v0.0.0-20211028202545-6944b10bf410
golang.org/x/oauth2 v0.0.0-20211028175245-ba495a64dcb5
gomod.garykim.dev/nc-talk v0.3.0
gopkg.in/olahol/melody.v1 v1.0.0-20170518105555-d52139073376
layeh.com/gumble v0.0.0-20200818122324-146f9205029b
@@ -75,7 +75,7 @@ require (
github.com/klauspost/cpuid/v2 v2.0.6 // indirect
github.com/labstack/gommon v0.3.0 // 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/logr v1.0.13 // indirect
github.com/mattermost/logr/v2 v2.0.10 // indirect

26
go.sum
View File

@@ -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-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/gops v0.3.21 h1:SmULDdFdSLaPZHR3FgPJfNFfrrohoHUgC9DenFuGrUE=
github.com/google/gops v0.3.21/go.mod h1:7diIdLsqpCihPSX3fQagksT/Ku/y4RL9LHTlKyEUDl8=
github.com/google/gops v0.3.22 h1:lyvhDxfPLHAOR2xIYwjPhN387qHxyU21Sk9sz/GhmhQ=
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/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=
@@ -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/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/gozulipbot v0.0.0-20200820220548-be5824faa913 h1:5UGr9fLsvAvhjP6i5XJmd0ZIwYVR2gZCzU1lJZ7wfLY=
github.com/matterbridge/gozulipbot v0.0.0-20200820220548-be5824faa913/go.mod h1:yAjnZ34DuDyPHMPHHjOsTk/FefW4JJjoMMCGt/8uuQA=
github.com/matterbridge/gozulipbot v0.0.0-20211023205727-a19d6c1f3b75 h1:GslZKF7lW7oSisycGLpxPO+TnKJuA4VZuTWIfYZrClc=
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/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-20211016195328-346acac403d8/go.mod h1:Gh3tFUjkcPIBBeEkfXBbGio4ONMMKNmlmGECvXLY0TE=
github.com/mattermost/go-i18n v1.11.0 h1:1hLKqn/ZvhZ80OekjVPGYcCrBfMz+YxNNgqS+beL7zE=
github.com/matterbridge/matterclient v0.0.0-20211024214211-22e762684b4a h1:j5/5gEHtACfrG/Exygfjqj0ip/zRgsa8KaAyuvO2c5Y=
github.com/matterbridge/matterclient v0.0.0-20211024214211-22e762684b4a/go.mod h1:Gh3tFUjkcPIBBeEkfXBbGio4ONMMKNmlmGECvXLY0TE=
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.20210714143452-8b50f5209a7f/go.mod h1:QCQ3U0M9T/BlAdjKFJo0I1oe/YAgbyjNdhU8bpOLafk=
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/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/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.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/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=
@@ -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-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-20210628002857-a66eb6448b8d h1:RNPAfi2nHY7C2srAV8A49jpsYr0ADedCk1wq6fTMTvs=
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
golang.org/x/image v0.0.0-20211028202545-6944b10bf410 h1:hTftEOvwiOq2+O8k2D5/Q7COC7k5Qcrgc2TFURJYnvQ=
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-20181026193005-c67002cb31c3/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-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-20211005180243-6b3c2da341f1 h1:B333XXssMuKQeBwiNODx4TupZy7bf4sxFZnN2ZOcvUE=
golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20211028175245-ba495a64dcb5 h1:v79phzBz03tsVCUTbvTBmmC3CUXF5mKYt7DA4ZVldpM=
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/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=

View File

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

View File

@@ -9,7 +9,7 @@ import (
func (m *MMClient) parseActionPost(rmsg *Message) {
// add post to cache, if it already exists don't relay this again.
// 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))
rmsg.Text = ""
return

View File

@@ -5,7 +5,7 @@ RUN apk add \
go \
git \
&& 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
RUN apk --no-cache add \

View File

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

View File

@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build !js && !plan9 && !windows
// +build !js,!plan9,!windows
//go:build !js && !plan9 && !solaris && !windows
// +build !js,!plan9,!solaris,!windows
package agent
@@ -13,10 +13,10 @@ import (
"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()
// 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
if err := c.Control(func(su uintptr) {
sock := int(su)

View File

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

View File

@@ -10,14 +10,15 @@ import (
)
type Bot struct {
APIKey string
APIURL string
Email string
Queues []*Queue
Streams []string
Client Doer
Backoff time.Duration
Retries int64
APIKey string
APIURL string
Email string
Queues []*Queue
Streams []string
Client Doer
Backoff time.Duration
Retries int64
UserAgent string
}
type Doer interface {
@@ -117,6 +118,11 @@ func (b *Bot) Subscribe(streams []string) (*http.Response, error) {
body := "subscriptions=" + string(bodyBts)
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 {
return nil, err
}
@@ -174,6 +180,20 @@ func (b *Bot) RegisterEvents(ets []EventType, n Narrow) (*Queue, error) {
return nil, err
}
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)
if err != nil {

View File

@@ -151,6 +151,8 @@ func (q *Queue) GetEvents() ([]EventMessage, error) {
switch {
case resp.StatusCode == 429:
return nil, BackoffError
case resp.StatusCode == 401:
return nil, UnauthorizedError
case resp.StatusCode == 403:
return nil, UnauthorizedError
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) {
// add post to cache, if it already exists don't relay this again.
// 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))
rmsg.Text = ""
@@ -264,9 +264,8 @@ func (m *Client) parseMessage(rmsg *Message) {
case model.WebsocketEventPosted, model.WebsocketEventPostEdited, model.WebsocketEventPostDeleted:
m.parseActionPost(rmsg)
case "user_updated":
user := rmsg.Raw.GetData()["user"].(map[string]interface{})
if _, ok := user["id"].(string); ok {
m.UpdateUser(user["id"].(string))
if user, ok := rmsg.Raw.GetData()["user"].(*model.User); ok {
m.UpdateUser(user.Id)
}
case "group_added":
if err := m.UpdateChannels(); err != nil {

View File

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

View File

@@ -15,44 +15,88 @@ func AuditModelTypeConv(val interface{}) (newVal interface{}, converted bool) {
switch v := val.(type) {
case *Channel:
return newAuditChannel(v), true
case Channel:
return newAuditChannel(&v), true
case *Team:
return newAuditTeam(v), true
case Team:
return newAuditTeam(&v), true
case *User:
return newAuditUser(v), true
case User:
return newAuditUser(&v), true
case *UserPatch:
return newAuditUserPatch(v), true
case UserPatch:
return newAuditUserPatch(&v), true
case *Command:
return newAuditCommand(v), true
case Command:
return newAuditCommand(&v), true
case *CommandArgs:
return newAuditCommandArgs(v), true
case CommandArgs:
return newAuditCommandArgs(&v), true
case *Bot:
return newAuditBot(v), true
case Bot:
return newAuditBot(&v), true
case *ChannelModerationPatch:
return newAuditChannelModerationPatch(v), true
case ChannelModerationPatch:
return newAuditChannelModerationPatch(&v), true
case *Emoji:
return newAuditEmoji(v), true
case Emoji:
return newAuditEmoji(&v), true
case *FileInfo:
return newAuditFileInfo(v), true
case FileInfo:
return newAuditFileInfo(&v), true
case *Group:
return newAuditGroup(v), true
case Group:
return newAuditGroup(&v), true
case *Job:
return newAuditJob(v), true
case Job:
return newAuditJob(&v), true
case *OAuthApp:
return newAuditOAuthApp(v), true
case OAuthApp:
return newAuditOAuthApp(&v), true
case *Post:
return newAuditPost(v), true
case Post:
return newAuditPost(&v), true
case *Role:
return newAuditRole(v), true
case Role:
return newAuditRole(&v), true
case *Scheme:
return newAuditScheme(v), true
case Scheme:
return newAuditScheme(&v), true
case *SchemeRoles:
return newAuditSchemeRoles(v), true
case SchemeRoles:
return newAuditSchemeRoles(&v), true
case *Session:
return newAuditSession(v), true
case Session:
return newAuditSession(&v), true
case *IncomingWebhook:
return newAuditIncomingWebhook(v), true
case IncomingWebhook:
return newAuditIncomingWebhook(&v), true
case *OutgoingWebhook:
return newAuditOutgoingWebhook(v), true
case OutgoingWebhook:
return newAuditOutgoingWebhook(&v), true
case *RemoteCluster:
return newRemoteCluster(v), true
case RemoteCluster:
return newRemoteCluster(&v), true
}
return val, false
}
@@ -128,6 +172,21 @@ func newAuditUser(u *User) auditUser {
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) {
enc.StringKey("id", u.ID)
enc.StringKey("name", u.Name)

View File

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

14
vendor/modules.txt vendored
View File

@@ -92,7 +92,7 @@ github.com/gomarkdown/markdown
github.com/gomarkdown/markdown/ast
github.com/gomarkdown/markdown/html
github.com/gomarkdown/markdown/parser
# github.com/google/gops v0.3.21
# github.com/google/gops v0.3.22
## explicit; go 1.12
github.com/google/gops/agent
github.com/google/gops/internal
@@ -183,16 +183,16 @@ github.com/matterbridge/discordgo
# github.com/matterbridge/go-xmpp v0.0.0-20210731150933-5702291c239f
## explicit
github.com/matterbridge/go-xmpp
# github.com/matterbridge/gozulipbot v0.0.0-20200820220548-be5824faa913
# github.com/matterbridge/gozulipbot v0.0.0-20211023205727-a19d6c1f3b75
## explicit
github.com/matterbridge/gozulipbot
# github.com/matterbridge/logrus-prefixed-formatter v0.5.3-0.20200523233437-d971309a77ba
## explicit
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
github.com/matterbridge/matterclient
# github.com/mattermost/go-i18n v1.11.0
# github.com/mattermost/go-i18n v1.11.1-0.20211013152124-5c415071e404
## explicit
github.com/mattermost/go-i18n/i18n
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/mlog
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
github.com/mattermost/mattermost-server/v6/model
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/internal/bcrypt_pbkdf
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
golang.org/x/image/riff
golang.org/x/image/vp8
@@ -477,7 +477,7 @@ golang.org/x/net/http2/hpack
golang.org/x/net/idna
golang.org/x/net/publicsuffix
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
golang.org/x/oauth2
golang.org/x/oauth2/clientcredentials

6
version/version.go Normal file
View File

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