Skip to content

[Matrix] switch to mautrix-go + initial support for application services#1864

Closed
nightmared wants to merge 11 commits into
42wim:masterfrom
nightmared:mautrix_appservice
Closed

[Matrix] switch to mautrix-go + initial support for application services#1864
nightmared wants to merge 11 commits into
42wim:masterfrom
nightmared:mautrix_appservice

Conversation

@nightmared

@nightmared nightmared commented Jul 24, 2022

Copy link
Copy Markdown
Contributor

Hello,

This is a revival of #1541, #1543 and #1544.

Fixes #137.

Before considering reviewing this, I would really like for other people to confirm that it works for them, to detect some of the numerous issues that must be lurking inside this changeset.

If you want to test the appservice support, you can use the same example configuration than in #1544.

The work that remains to be done mainly revolves around application services:

  • supporting more complex regexps for the usernames
  • accepting rooms not explictly hardcoded in the config (that is the whole point of app services after all, yet currently it only relays messages for rooms that are already defined in the config)
  • testing this enough to be confident it works as expected

@qlty-cloud-legacy qlty-cloud-legacy Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR diff size of 25715 lines exceeds the maximum allowed for the inline comments feature.

@poVoq

poVoq commented Aug 5, 2022

Copy link
Copy Markdown

accepting rooms not explictly hardcoded in the config (that is the whole point of app services after all, yet currently it only relays messages for rooms that are already defined in the config)

That seem unlikely to happen given Matterbridge config heavy approach, but it would be really nice if this appservice improvement could properly create ghost users Matrix side through the bridge.

@nightmared

Copy link
Copy Markdown
Contributor Author

Agreed on both counts!

As for the "proper ghost accounts", that's actually what it does: 2022-08-05-1659725007
2022-08-05-1659725087

@poVoq

poVoq commented Aug 11, 2022

Copy link
Copy Markdown

I am not a Go developer and thus don't have an dev environment to compile this easily. But if you can share a x86_64 binary I am willing to test it in a IRC-Matrix-Discord setting.

@42wim

42wim commented Aug 13, 2022

Copy link
Copy Markdown
Owner

@nightmared thanks for your work! :)
Could you rebase on master? I've updated dependencies.

I'll try to test later

@42wim 42wim added the matrix label Aug 13, 2022
@Mikaela

Mikaela commented Aug 14, 2022

Copy link
Copy Markdown

Does this also bring support for IRC NOTICE -> Matrix m.notice (#1393) or should that be done in a separate PR?

I don't know if the previous library supported m.notice.

@qlty-cloud-legacy qlty-cloud-legacy Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR diff size of 25126 lines exceeds the maximum allowed for the inline comments feature.

@nightmared

Copy link
Copy Markdown
Contributor Author

I am not a Go developer and thus don't have an dev environment to compile this easily. But if you can share a x86_64 binary I am willing to test it in a IRC-Matrix-Discord setting.

Sure thing, here is one: https://nightmared.fr/files/matterbridge-2022-08-14.

You can verify its integrity with sha256sum:

5d9511d784b6d4716af917026b79ab9921f65397ca8660baa40bce73b22c8f39  dev/matterbridge/matterbridge

Sorry about the time this took me, I have discovered the joys of COVID19 these past few days, and unsurprisingly that doesn't really help focusing on code (or anything really) ^_^
Anyway, I have rebased this on master, and I will take a look to see if I can tackle the CodeClimate issues.

@nightmared

Copy link
Copy Markdown
Contributor Author

Does this also bring support for IRC NOTICE -> Matrix m.notice (#1393) or should that be done in a separate PR?

I don't know if the previous library supported m.notice.

No, I haven't added support for m.notice in this PR, because if I'm being honest, I didn't even knew this feature existed!
That being said, I don't think there should be any blocker for implementing this.

@qlty-cloud-legacy qlty-cloud-legacy Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR diff size of 25160 lines exceeds the maximum allowed for the inline comments feature.

@qlty-cloud-legacy qlty-cloud-legacy Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR diff size of 25160 lines exceeds the maximum allowed for the inline comments feature.

@nightmared

Copy link
Copy Markdown
Contributor Author

For golangci-lint, while I could reproduce locally the golangci-lint messages about the extraneous spaces in // nolint, I do not have these error messages even though I also have golangci-lint v1.48.0:

  Error: File is not `gofmt`-ed with `-s` (gofmt)
  Error: File is not `gofmt`-ed with `-s` (gofmt)
  Error: File is not `gofmt`-ed with `-s` (gofmt)
  Error: File is not `gofmt`-ed with `-s` (gofmt)
  Error: File is not `gofmt`-ed with `-s` (gofmt)

Does anyone happen to know why that is ?

@Akselmo

Akselmo commented Aug 31, 2022

Copy link
Copy Markdown

Hi, is this still being worked on? I have had so much problems with other bridges yet matterbridge works really well. Would love to have this feature.

@nightmared

Copy link
Copy Markdown
Contributor Author

@Akselmo Yes, this is definitely still ongoing :)

I'm currently waiting for user feeback to know if it works for other people, and if the current design seems acceptable or if I have to go back to the drawing board.

So if you happen to have some feedback, or to know people who might, I woul be happy to hear some or discuss this further!

@Akselmo

Akselmo commented Aug 31, 2022

Copy link
Copy Markdown

@Akselmo Yes, this is definitely still ongoing :)

I'm currently waiting for user feeback to know if it works for other people, and if the current design seems acceptable or if I have to go back to the drawing board.

Ah, I could try building this with your PR and see if it works for me.

@Akselmo

Akselmo commented Aug 31, 2022

Copy link
Copy Markdown

Alright I got it to work, here's some feedback!

  • I can't use the internal id's for channel names (probably has something to do with the appservice regex, changed it to #.* and all my channels work with it)
  • Avatars do not get over the bridge in either direction. The stable build has the webhook support and the avatars get over bridge to Discord at least. I tried with localhost and my matrix domain in the appservice settings. No dice.
    • To add, the bridgebot is sending its own avatar from matrix to discord, instead of the user.
  • The RemoteNickFormat="<{NICK}> " can't be anything else but that. I tried to remove the <> but it stopped working. I tried to remove them because the nick looks like this: &lt;Aks&gt;

Anyhow so far so good and I prefer this way much more over the other bridge bots I've tried.

@nightmared

nightmared commented Sep 1, 2022

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback!

  • For the internal ID, that's concerning. Could you tell more about what it meant for the rooms IDs to not work? To you not receiving messages?
  • For the avatar, this is a known problem: fix GetAvatarURL to correctly retrieve the right avatar mautrix/go#83. This should be fixed once mautrix-go will have published a new version of the library, that we would apply by updating the vendored dependency.
  • Not being able to change the Nickname format is surprising. I will perform some tests locally to see if I can reproduce (and fix the < -> &lt; conversion) - probably not today though.

@Akselmo

Akselmo commented Sep 1, 2022

Copy link
Copy Markdown
* For the internal ID, that's concerning. Could you tell more about what it meant for the rooms IDs to not work? To you not receiving messages?

If the room ID started with !randomlettershere:address.org it wouldn't work: It couldn't find the address. But I think this was because the appservice regexp has # in the beginning, so it was trying to look for #!randomlettershere and failed because of that.

It's not that big of a deal since using the public address of the channels worked. I tend to use the internal addresses/ID's in case I change the public address, so it still keeps pointing to right place.

* Not being able to change the Nickname format is surprising. I will perform some tests locally to see if I can reproduce (and fix the `<` -> `&lt;` conversion) - probably not today though.

I could try changing it again, it was a bit odd. Sometimes when closing the bot and then starting it up again it wouldn't launch the appservice and worked in the non-appservice way: Instead of ghost accounts it would just relay messages with <name> bla way.

Edit: Okay I changed it and now it works. It seems that if the appservice is not up, it relays the messages normal way, but when appservice is up it uses the ghost bots.

Could perhaps make it so that I could change different nick style for the appservice bots itself?

@Akselmo

Akselmo commented Sep 1, 2022

Copy link
Copy Markdown

I also noticed custom emojis wont go over the bridge either. I guess this is also something to do with Mautrix?

@nightmared

Copy link
Copy Markdown
Contributor Author

What do you mean by "custom emojis"? Reactions to messages?
If you mean reactions, AFAIK they weren't shared across bridges prior to this MR either (but I could be wrong of course).

@Akselmo

Akselmo commented Sep 1, 2022

Copy link
Copy Markdown

What do you mean by "custom emojis"? Reactions to messages? If you mean reactions, AFAIK they weren't shared across bridges prior to this MR either (but I could be wrong of course).

I mean actual emojis and stickers.

Here's an example of Discord custom emoji to Matrix

Discord:
image

Matrix:
image

And from Matrix to Discord

Matrix
image

Discord
image

This bridge has managed to solve this issue, so maybe theres something we could use? https://github.com/matrix-org/matrix-appservice-discord


Also, something new I noticed!

After enabling appservice, someone on the Matrix channel has to talk first for the appservice to be active.

image

After enabling bot, the first message there came from Discord, without the appservice. But after I said something in the Matrix channel, then tried again from Discord, the appservice was enabled.

@Akselmo

Akselmo commented Sep 1, 2022

Copy link
Copy Markdown

Also it seems I can't delete messages on discord from matrix side.

@nightmared

Copy link
Copy Markdown
Contributor Author

Thanks for all these reports, I will take a look at them (mostly this week-end I think)!

@Akselmo

Akselmo commented Sep 1, 2022

Copy link
Copy Markdown

No problem, I don't know Go but I can also look into some issues if I got time.

@nightmared nightmared force-pushed the mautrix_appservice branch from 73079d0 to 7163d6c Compare April 9, 2023 12:27

@qlty-cloud-legacy qlty-cloud-legacy Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR diff size of 34586 lines exceeds the maximum allowed for the inline comments feature.

@qlty-cloud-legacy qlty-cloud-legacy Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR diff size of 34606 lines exceeds the maximum allowed for the inline comments feature.

@nightmared

Copy link
Copy Markdown
Contributor Author

You think this will be ready for a merge soon?

Sorry for the late reply!

#1864 (comment) is an adequate status of the progress of this PR.
However, given the (lack of) time I spend on this issue, this PR will probably never be merged if we wait for all these enhancements to be developed.

As such, I believe it would be best to merge the PR as-is (fixing eventual errors and style issues of course), and to open dedicated PR for each of these issues, considering they are enhancements that we would love to see, and not regressions.

This would allow other developers to look into adding support for them, which is understandably not very feasible with the current PR.

What do you think?

@nightmared nightmared force-pushed the mautrix_appservice branch from 16459b0 to bbea005 Compare April 9, 2023 12:41

@qlty-cloud-legacy qlty-cloud-legacy Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR diff size of 34605 lines exceeds the maximum allowed for the inline comments feature.

@qlty-cloud-legacy

Copy link
Copy Markdown

Code Climate has analyzed commit bbea005 and detected 5 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 5

View more on Code Climate.

@poVoq

poVoq commented Apr 11, 2023

Copy link
Copy Markdown

Can you please share another x86 binary for testing? I am running into probably very basic issues in compiling it that are likely just due to me not being used to the go tool-chain at all and I would rather spend the time actually testing the bridge than trying to debug go compilation which I am not using at all otherwise. Thanks!

@nightmared

Copy link
Copy Markdown
Contributor Author

Sure thing: https://nightmared.fr/files/matterbridge-2023-04-11.

And to check its integrity:

$ sha256sum matterbridge
80d02ff881901eb5692bca99b4a5a1fc56c2aeabeb8b3138ac0246387f1281e3  matterbridge

FYI, if you want to reproduce the build yourself (this is always better than relying on someone else on the internet, like me :)):

[sthoby@tolkien matterbridge]$ podman run --rm -it -v $(pwd):/code -w /code golang:bullseye
✔ docker.io/library/golang:bullseye
Trying to pull docker.io/library/golang:bullseye...

Getting image source signatures
Copying blob 92ac76a462cb done
Copying blob 68a71c865a2c done
Copying blob 3e440a704568 done
Copying blob 5a7a2c95f0f8 done
Copying blob 670730c27c2e done
Copying blob db119aaf144b done
Copying blob 5997e4205ef7 done
Copying config e1567729a3 done
Writing manifest to image destination
Storing signatures
root@0dc8a6799ad4:/code#
root@0dc8a6799ad4:/code# go build -v
internal/coverage/rtcov
encoding
internal/unsafeheader
internal/goarch
internal/goos
internal/goexperiment
internal/itoa
runtime/internal/atomic
runtime/internal/syscall
internal/cpu
math/bits
internal/race
unicode/utf8
sync/atomic
unicode
internal/abi
runtime/internal/math
runtime/internal/sys
unicode/utf16
internal/nettrace
container/list
crypto/internal/alias
crypto/subtle
crypto/internal/boring/sig
vendor/golang.org/x/crypto/cryptobyte/asn1
vendor/golang.org/x/crypto/internal/alias
internal/bytealg
math
github.com/pelletier/go-toml/v2/internal/characters
golang.org/x/crypto/internal/alias
image/color
golang.org/x/crypto/salsa20/salsa
google.golang.org/protobuf/internal/flags
google.golang.org/protobuf/internal/set
golang.org/x/text/encoding/internal/identifier
golang.org/x/text/internal/utf8internal
github.com/keybase/go-keybase-chat-bot/kbchat/types/gregor1
github.com/tidwall/match
golang.org/x/net/html/atom
github.com/slack-go/slack/internal/errorsx
github.com/graph-gophers/graphql-go/decode
github.com/mattermost/mattermost-server/v6/services/timezones
github.com/vmihailenco/msgpack/v5/msgpcode
image/color/palette
github.com/vmihailenco/tagparser/v2/internal
github.com/rivo/uniseg
gomod.garykim.dev/nc-talk/constants
github.com/SevereCloud/vksdk/v2
github.com/klauspost/compress/internal/cpuinfo
github.com/42wim/matterbridge/version
github.com/google/gops/signal
runtime
github.com/klauspost/compress
internal/reflectlite
sync
internal/testlog
internal/godebug
internal/singleflight
internal/sysinfo
github.com/zfjagann/golang-ring
google.golang.org/protobuf/internal/pragma
github.com/spf13/viper/internal/encoding
runtime/cgo
internal/intern
math/rand
errors
sort
io
internal/oserror
internal/safefilepath
strconv
path
vendor/golang.org/x/net/dns/dnsmessage
github.com/hashicorp/hcl/hcl/strconv
crypto/internal/nistec/fiat
syscall
github.com/hashicorp/golang-lru/simplelru
golang.org/x/text/internal/tag
hash
bytes
strings
crypto/internal/randutil
text/tabwriter
hash/crc32
reflect
net/netip
crypto
crypto/rc4
github.com/valyala/bytebufferpool
hash/adler32
hash/fnv
golang.org/x/text/transform
vendor/golang.org/x/text/transform
github.com/saintfish/chardet
encoding/base32
golang.org/x/text/runes
golang.org/x/text/encoding
bufio
net/http/internal/ascii
regexp/syntax
html
net/http/internal/testcert
golang.org/x/text/encoding/internal
golang.org/x/text/encoding/japanese
golang.org/x/text/encoding/korean
golang.org/x/text/encoding/simplifiedchinese
golang.org/x/text/encoding/traditionalchinese
image
golang.org/x/text/encoding/unicode
github.com/slack-go/slack/slackutilsx
internal/syscall/unix
time
internal/syscall/execenv
image/internal/imageutil
golang.org/x/image/vp8
image/jpeg
regexp
golang.org/x/image/vp8l
github.com/writeas/go-strip-markdown
maunium.net/go/mautrix/pushrules/glob
github.com/vmihailenco/tagparser/v2/internal/parser
github.com/vmihailenco/tagparser/v2
golang.org/x/crypto/blowfish
image/draw
github.com/shazow/ssh-chat/internal/sanitize
golang.org/x/text/width
golang.org/x/text/encoding/charmap
github.com/d5/tengo/v2/token
context
io/fs
internal/poll
github.com/labstack/gommon/random
github.com/slack-go/slack/internal/backoff
github.com/slack-go/slack/internal/timex
github.com/jpillora/backoff
github.com/matterbridge/Rocket.Chat.Go.SDK/models
github.com/shazow/rateio
internal/fmtsort
encoding/binary
internal/saferio
github.com/modern-go/reflect2
embed
github.com/spf13/afero/internal/common
encoding/base64
crypto/cipher
crypto/internal/edwards25519/field
crypto/md5
vendor/golang.org/x/crypto/internal/poly1305
crypto/internal/nistec
os
golang.org/x/sys/unix
encoding/pem
golang.org/x/crypto/internal/poly1305
crypto/internal/boring
crypto/des
crypto/internal/edwards25519
vendor/golang.org/x/crypto/chacha20
crypto/aes
crypto/sha512
crypto/hmac
crypto/sha1
crypto/sha256
vendor/golang.org/x/crypto/hkdf
golang.org/x/crypto/nacl/secretbox
fmt
path/filepath
net
io/ioutil
google.golang.org/protobuf/internal/detrand
crypto/ecdh
golang.org/x/crypto/hkdf
golang.org/x/crypto/pbkdf2
github.com/philhofer/fwd
github.com/mattn/go-runewidth
github.com/spf13/afero/mem
os/exec
vendor/golang.org/x/sys/cpu
golang.org/x/image/riff
golang.org/x/sys/cpu
golang.org/x/crypto/scrypt
golang.org/x/image/webp
layeh.com/gumble/gumble/varint
golang.org/x/crypto/chacha20
golang.org/x/crypto/curve25519/internal/field
golang.org/x/crypto/ssh/internal/bcrypt_pbkdf
github.com/Philipp15b/go-steam/rwu
vendor/golang.org/x/crypto/chacha20poly1305
github.com/klauspost/compress/internal/snapref
github.com/klauspost/compress/zstd/internal/xxhash
github.com/mitchellh/go-homedir
golang.org/x/crypto/blake2b
flag
encoding/json
log
encoding/csv
golang.org/x/text/unicode/norm
compress/flate
math/big
encoding/hex
net/url
vendor/golang.org/x/text/unicode/bidi
vendor/golang.org/x/text/unicode/norm
vendor/golang.org/x/net/http2/hpack
mime
compress/gzip
mime/quotedprintable
github.com/fsnotify/fsnotify
vendor/golang.org/x/text/secure/bidirule
net/http/internal
text/template/parse
github.com/spf13/jwalterweatherman
github.com/subosito/gotenv
github.com/hashicorp/hcl/hcl/token
gopkg.in/ini.v1
github.com/sirupsen/logrus
github.com/spf13/viper/internal/encoding/json
github.com/pelletier/go-toml/v2/internal/danger
github.com/hashicorp/hcl/hcl/ast
github.com/hashicorp/hcl/hcl/scanner
github.com/hashicorp/hcl/json/token
github.com/pelletier/go-toml/v2/unstable
gopkg.in/yaml.v3
github.com/hashicorp/hcl/hcl/parser
vendor/golang.org/x/net/idna
github.com/hashicorp/hcl/json/scanner
github.com/hashicorp/hcl/hcl/printer
github.com/pelletier/go-toml/v2/internal/tracker
github.com/hashicorp/hcl/json/parser
encoding/xml
github.com/pelletier/go-toml/v2
crypto/rand
crypto/elliptic
crypto/internal/bigmod
crypto/internal/boring/bbig
encoding/asn1
crypto/ed25519
crypto/dsa
text/template
github.com/hashicorp/hcl
github.com/mattn/go-isatty
github.com/valyala/fasttemplate
github.com/spf13/viper/internal/encoding/hcl
github.com/mattn/go-colorable
vendor/golang.org/x/crypto/cryptobyte
crypto/rsa
crypto/x509/pkix
runtime/debug
github.com/spf13/viper/internal/encoding/toml
github.com/labstack/gommon/color
golang.org/x/net/http2/hpack
golang.org/x/text/unicode/bidi
github.com/labstack/gommon/log
github.com/labstack/gommon/bytes
crypto/ecdsa
golang.org/x/time/rate
compress/zlib
github.com/gomarkdown/markdown/ast
image/png
runtime/trace
github.com/davecgh/go-spew/spew
html/template
google.golang.org/protobuf/internal/errors
golang.org/x/text/secure/bidirule
testing
go/token
google.golang.org/protobuf/encoding/protowire
golang.org/x/net/idna
github.com/gomarkdown/markdown/parser
google.golang.org/protobuf/reflect/protoreflect
google.golang.org/protobuf/internal/version
github.com/paulrosania/go-charset/charset
github.com/keybase/go-keybase-chat-bot/kbchat/types/keybase1
github.com/pmezard/go-difflib/difflib
github.com/paulrosania/go-charset/data
github.com/spf13/viper/internal/encoding/yaml
google.golang.org/protobuf/internal/encoding/messageset
github.com/spf13/cast
google.golang.org/protobuf/internal/strs
google.golang.org/protobuf/internal/order
google.golang.org/protobuf/reflect/protoregistry
google.golang.org/protobuf/internal/genid
google.golang.org/protobuf/runtime/protoiface
google.golang.org/protobuf/internal/descfmt
github.com/hashicorp/golang-lru
google.golang.org/protobuf/internal/descopts
google.golang.org/protobuf/internal/encoding/text
github.com/tidwall/pretty
maunium.net/go/maulogger/v2
github.com/spf13/viper/internal/encoding/ini
github.com/spf13/viper/internal/encoding/dotenv
encoding/gob
github.com/gomarkdown/markdown/html
google.golang.org/protobuf/proto
github.com/tidwall/gjson
golang.org/x/net/html
google.golang.org/protobuf/internal/encoding/defval
maunium.net/go/mautrix/util/base58
database/sql/driver
maunium.net/go/mautrix/util/jsontime
maunium.net/go/mautrix/id
maunium.net/go/mautrix/crypto/utils
maunium.net/go/mautrix/crypto/attachment
github.com/gomarkdown/markdown
google.golang.org/protobuf/encoding/prototext
github.com/gorilla/schema
google.golang.org/protobuf/internal/filedesc
github.com/mgutz/ansi
golang.org/x/term
github.com/tidwall/sjson
github.com/blang/semver
maunium.net/go/mautrix/util
database/sql
golang.org/x/crypto/ssh/terminal
github.com/graph-gophers/graphql-go/errors
github.com/matterbridge/logrus-prefixed-formatter
text/scanner
github.com/graph-gophers/graphql-go/log
github.com/opentracing/opentracing-go/log
github.com/go-asn1-ber/asn1-ber
github.com/wiggin77/merror
gopkg.in/natefinch/lumberjack.v2
os/user
github.com/graph-gophers/graphql-go/types
github.com/mattermost/logr/v2
github.com/modern-go/concurrent
github.com/klauspost/compress/s2
github.com/graph-gophers/graphql-go/internal/common
maunium.net/go/mautrix/event
github.com/dyatlov/go-opengraph/opengraph
github.com/mitchellh/mapstructure
crypto/x509
net/textproto
vendor/golang.org/x/net/http/httpproxy
github.com/spf13/pflag
google.golang.org/protobuf/internal/encoding/tag
vendor/golang.org/x/net/http/httpguts
mime/multipart
golang.org/x/net/http/httpguts
google.golang.org/protobuf/internal/impl
github.com/rs/zerolog/internal/json
maunium.net/go/mautrix/pushrules
github.com/francoispqt/gojay
github.com/graph-gophers/graphql-go/internal/exec/packer
github.com/graph-gophers/graphql-go/introspection
github.com/rs/zerolog
github.com/graph-gophers/graphql-go/internal/query
github.com/graph-gophers/graphql-go/internal/exec/resolvable
github.com/graph-gophers/graphql-go/internal/schema
github.com/graph-gophers/graphql-go/internal/exec/selected
github.com/graph-gophers/graphql-go/internal/validation
github.com/google/uuid
github.com/json-iterator/go
github.com/klauspost/cpuid/v2
github.com/minio/minio-go/v7/pkg/s3utils
crypto/tls
github.com/golang-jwt/jwt
archive/tar
golang.org/x/crypto/argon2
github.com/minio/minio-go/v7/pkg/lifecycle
github.com/rs/xid
maunium.net/go/maulogger/v2/maulogadapt
github.com/minio/minio-go/v7/pkg/replication
github.com/minio/minio-go/v7/pkg/sse
github.com/keybase/go-keybase-chat-bot/kbchat/types/stellar1
github.com/minio/minio-go/v7/pkg/tags
github.com/pkg/errors
github.com/mattermost/go-i18n/i18n/language
github.com/pelletier/go-toml
gopkg.in/yaml.v2
github.com/mattermost/mattermost-server/v6/shared/markdown
github.com/minio/md5-simd
github.com/minio/sha256-simd
github.com/mattermost/go-i18n/i18n/translation
github.com/mattermost/mattermost-server/v6/utils/jsonutils
github.com/mattermost/logr/v2/formatters
github.com/minio/minio-go/v7/pkg/set
github.com/pborman/uuid
github.com/tinylib/msgp/msgp
github.com/vmihailenco/msgpack/v5
github.com/minio/minio-go/v7/pkg/notification
github.com/keybase/go-keybase-chat-bot/kbchat/types/chat1
google.golang.org/protobuf/internal/filetype
golang.org/x/crypto/bcrypt
golang.org/x/text/internal/language
compress/lzw
net/mail
google.golang.org/protobuf/runtime/protoimpl
image/gif
github.com/mattn/godown
google.golang.org/protobuf/types/descriptorpb
net/http/httptrace
github.com/lrstanley/girc
net/http
github.com/mattermost/ldap
github.com/wiggin77/srslog
github.com/mattermost/go-i18n/i18n/bundle
github.com/rickb777/plural
golang.org/x/text/internal/language/compact
github.com/mattermost/go-i18n/i18n
github.com/mattermost/logr/v2/targets
github.com/rickb777/date/period
github.com/yaegashi/msgraph.go/jsonx
golang.org/x/text/language
google.golang.org/protobuf/reflect/protodesc
github.com/mattermost/logr/v2/config
gomod.garykim.dev/nc-talk/ocs
github.com/Jeffail/gabs
github.com/apex/log
github.com/shazow/ssh-chat/sshd/terminal
github.com/mattermost/mattermost-server/v6/shared/mlog
golang.org/x/crypto/curve25519
golang.org/x/crypto/ed25519
github.com/Philipp15b/go-steam/cryptoutil
golang.org/x/crypto/ssh
github.com/golang/protobuf/proto
github.com/golang/protobuf/protoc-gen-go/descriptor
github.com/Philipp15b/go-steam/steamid
github.com/russross/blackfriday
github.com/klauspost/compress/fse
github.com/skip2/go-qrcode/bitset
github.com/SevereCloud/vksdk/v2/object
github.com/Rhymen/go-whatsapp/binary/proto
github.com/skip2/go-qrcode/reedsolomon
github.com/Rhymen/go-whatsapp/binary/token
github.com/Rhymen/go-whatsapp/crypto/cbc
github.com/skip2/go-qrcode
github.com/Rhymen/go-whatsapp/crypto/curve25519
github.com/Rhymen/go-whatsapp/crypto/hkdf
github.com/42wim/matterbridge/internal
github.com/klauspost/compress/huff0
github.com/Baozisoftware/qrcode-terminal-go
github.com/d5/tengo/v2/parser
github.com/kyokomi/emoji/v2
github.com/google/gops/internal
os/signal
github.com/harmony-development/shibshib/gen/harmonytypes/v1
layeh.com/gumble/gumble/MumbleProto
github.com/Philipp15b/go-steam/protocol/protobuf
github.com/klauspost/compress/zstd
runtime/pprof
github.com/d5/tengo/v2
github.com/google/gops/agent
layeh.com/gumble/gumble
github.com/shazow/ssh-chat/sshd
github.com/Rhymen/go-whatsapp/binary
layeh.com/gumble/gumbleutil
github.com/d5/tengo/v2/stdlib/json
net/http/httputil
net/http/httptest
github.com/magiconair/properties
github.com/gorilla/websocket
github.com/spf13/afero
golang.org/x/net/http2
golang.org/x/crypto/acme
maunium.net/go/mautrix
github.com/harmony-development/shibshib/gen/auth/v1
github.com/harmony-development/shibshib/gen/emote/v1
github.com/spf13/viper/internal/encoding/javaproperties
golang.org/x/crypto/acme/autocert
github.com/olahol/melody
github.com/bwmarrin/discordgo
github.com/harmony-development/shibshib/gen/profile/v1
github.com/stretchr/testify/assert
github.com/spf13/viper
net/http/cookiejar
github.com/gorilla/mux
github.com/harmony-development/shibshib/gen/chat/v1
golang.org/x/net/publicsuffix
github.com/opentracing/opentracing-go
github.com/slack-go/slack
github.com/minio/minio-go/v7/pkg/signer
github.com/opentracing/opentracing-go/ext
github.com/minio/minio-go/v7/pkg/credentials
github.com/graph-gophers/graphql-go/trace
github.com/stretchr/testify/require
github.com/graph-gophers/graphql-go/internal/exec
github.com/42wim/matterbridge/bridge/config
maunium.net/go/mautrix/appservice
github.com/42wim/matterbridge/bridge
github.com/42wim/matterbridge/bridge/helper
github.com/minio/minio-go/v7/pkg/encrypt
github.com/graph-gophers/graphql-go
github.com/keybase/go-keybase-chat-bot/kbchat
github.com/mattermost/mattermost-server/v6/shared/i18n
github.com/minio/minio-go/v7
golang.org/x/net/http2/h2c
github.com/42wim/matterbridge/bridge/irc
github.com/42wim/matterbridge/bridge/matrix
github.com/labstack/echo/v4
github.com/42wim/matterbridge/bridge/discord/transmitter
golang.org/x/oauth2/internal
golang.org/x/oauth2
github.com/42wim/matterbridge/bridge/keybase
github.com/vincent-petithory/dataurl
github.com/42wim/matterbridge/bridge/discord
github.com/harmony-development/shibshib
github.com/yaegashi/msgraph.go/beta
golang.org/x/oauth2/clientcredentials
golang.org/x/oauth2/microsoft
github.com/42wim/matterbridge/matterhook
github.com/42wim/matterbridge/bridge/mumble
github.com/42wim/matterbridge/hook/rockethook
github.com/monaco-io/request
github.com/yaegashi/msgraph.go/msauth
golang.org/x/net/websocket
github.com/matterbridge/Rocket.Chat.Go.SDK/rest
github.com/nelsonken/gomf
gomod.garykim.dev/nc-talk/user
github.com/42wim/matterbridge/bridge/harmony
github.com/42wim/matterbridge/bridge/slack
github.com/42wim/matterbridge/bridge/sshchat
github.com/Philipp15b/go-steam/netutil
github.com/gopackage/ddp
gomod.garykim.dev/nc-talk/room
github.com/Philipp15b/go-steam/protocol/steamlang
github.com/matterbridge/telegram-bot-api/v6
github.com/SevereCloud/vksdk/v2/internal
github.com/labstack/echo/v4/middleware
github.com/Rhymen/go-whatsapp
github.com/SevereCloud/vksdk/v2/api
github.com/42wim/matterbridge/bridge/nctalk
github.com/SevereCloud/vksdk/v2/events
github.com/matterbridge/go-xmpp
github.com/matterbridge/Rocket.Chat.Go.SDK/realtime
github.com/42wim/matterbridge/bridge/api
github.com/42wim/matterbridge/bridge/rocketchat
github.com/matterbridge/gozulipbot
github.com/42wim/matterbridge/bridge/xmpp
github.com/mattermost/mattermost-server/v6/shared/filestore
github.com/42wim/matterbridge/gateway/samechannel
github.com/d5/tengo/v2/stdlib
github.com/42wim/matterbridge/bridge/zulip
github.com/42wim/matterbridge/bridge/whatsapp
github.com/mattermost/mattermost-server/v6/model
github.com/42wim/matterbridge/bridge/telegram
github.com/Philipp15b/go-steam/socialcache
github.com/Philipp15b/go-steam/protocol
github.com/SevereCloud/vksdk/v2/longpoll-bot
github.com/Philipp15b/go-steam/protocol/gamecoordinator
github.com/Philipp15b/go-steam
github.com/42wim/matterbridge/bridge/vk
github.com/42wim/matterbridge/bridge/steam
github.com/matterbridge/matterclient
github.com/42wim/matterbridge/bridge/mattermost
github.com/42wim/matterbridge/bridge/msteams
github.com/42wim/matterbridge/gateway/bridgemap
github.com/42wim/matterbridge/gateway
github.com/42wim/matterbridge
root@0dc8a6799ad4:/code# sha256sum matterbridge
80d02ff881901eb5692bca99b4a5a1fc56c2aeabeb8b3138ac0246387f1281e3  matterbridge
root@0dc8a6799ad4:/code# ldd matterbridge
        linux-vdso.so.1 (0x00007ffdf84d6000)
        libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f05a0783000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f05a0761000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f05a058c000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f05a07a3000)

@gabrc52

gabrc52 commented Apr 11, 2023

Copy link
Copy Markdown

How do you enable puppeted users? Messages seem to come from the normal bot user

@poVoq

poVoq commented Apr 11, 2023

Copy link
Copy Markdown

How do you enable puppeted users? Messages seem to come from the normal bot user

This has some hints: https://github.com/42wim/matterbridge/pull/1864/files#diff-0b4fb334dec5e2cf5c073565d97d11ffb59c157269ff451f25df8ef26fac4d9f

But so far I didn't manage to fully configure it due to a lack of time. Probably tomorrow.

@gabrc52

gabrc52 commented Apr 12, 2023

Copy link
Copy Markdown

Here are some notes from my testing:

Because the non-Matrix platform I use is Mattermost, I will say "mattermost", but it likely means any non-Matrix platform that Matterbridge supports.

1: user puppeting

  • If you send a message on mattermost (non-matrix) first, then messages are bridged as a normal user
  • If you send a message on matrix first, then a message on mattermost, messages are correctly bridged as a puppeted user

Steps to reproduce:

  1. Start the bridge
  2. Send a message on the non-Matrix platform
  3. The message is bridged to Matrix as a normal user (bug)
  4. Stop the bridge
  5. Start the bridge
  6. Send a message on Matrix
  7. Send a message on the non-Matrix platform
  8. The message is bridged to Matrix as a puppeted user, as expected

It's probably this item in the todo list:

test if we could force the server to ping the appservice listener on every room, hence solving the "first message" boostraping problem described earlier (by sending some fake event like a typing notification maybe?)

I am not sure why that workaround would be needed. The appservice should be listening to messages on the claimed prefixes, no matter what, and sending messages as bridged users is completely independent from the REST API of the appservice.

Sending messages as bridged users should only involve making the same queries to the Matrix homeserver REST API, but with a new parameter on the query string: ?user_id=@_irc_user:example.org, except instead of logging in with the normal user (bot) account token, you use the as_token.

Might this be a bug in mautrix-go? Would it be worth asking in the Maunium room? (I've never touched the Mautrix library but I've built a bridge in Python without a library).

2: images

PDF file was properly bridged from Mattermost to Matrix
Sending images works on Matrix->Mattermost but not Mattermost->Matrix

  • Attempting to send an image from Mattermost->Matrix without a caption sends 2 empty messages
  • Attempting to send an image from Mattermost->Matrix with a caption sends the caption first then an empty message)
  • It appears that images do not properly upload. It appears that the content of the “image” that is sent is just the string “{}”

Element (seems completely blank):

image

Fluffychat (attempts to load image but fails because it only contains {})

image

3: deletions

  • Bidirectional edits WORK
  • Deletions partially work (Matrix->Mattermost turns into “deleted”, Mattermost->Matrix nothing happens)

@poVoq

poVoq commented Apr 22, 2023

Copy link
Copy Markdown

@gabrc52 can you share your config for the appservice part? I finally got time to try this and the non-appservice part works for Matrix <-> IRC, but even after enabling the appservice it continues sending it as a bot (yes I tried sending from Matrix first). Sadly nothing in the logs either side and matterbridge starts up fine without complaining about a problem with the appservice part.

I am not a big expert with appservice configurations though, so maybe I did something wrong in the config files.

Thanks!

@gabrc52

gabrc52 commented Apr 27, 2023

Copy link
Copy Markdown

@poVoq my file is

id: "matterbridge"
url: "http://127.0.0.1:29777"
as_token: "REDACTED"
hs_token: "REDACTED"
sender_localpart: "matterbridge"
namespaces:
  users:
    - exclusive: true
      regex: "@_mattermost_.*"
  aliases:
    - exclusive: false
      regex: "#_mattermost_.*"
  rooms: []
push_ephemeral: true
de.sorunome.msc2409.push_ephemeral: true

hs_token and as_token can be generated with pwgen -s 64 1 and must be different from each other.

Since it is only listening to rooms starting with #_mattermost_, to have the integration work, you must set their alias to something starting with that (or with the prefix you choose)

Off-topic: Also keep in mind if you just want to bridge IRC and Matrix, you're better off using a dedicated Matrix bridge. https://matrix.org/bridges/#irc. The purpose of this project, at least imho, is to have a powerful multibridge that works with as many platforms as possible. If you just have two platforms in mind you want to bridge, the Matrix ecosystem offers multiple bridges.

@poVoq

poVoq commented Apr 27, 2023

Copy link
Copy Markdown

Thanks a lot for sharing your config!

Since it is only listening to rooms starting with #_mattermost_, to have the integration work, you must set their alias to something starting with that (or with the prefix you choose)

Hmm, that would explain why it fails with the suggested config as well:

aliases:
   - exclusive: false
     regex: "#__bridge_.*"

But I am a bit surprised about this as Matterbridge is usually used to bridge existing channels that are not named in a special way like this. Can I just remove that part for it to work with any Matrix channel specified in the Matterbridge config file? Or what would be a regex that works with any channel name? Edit: or do I need to create local alias names for each room to be bridged?

Off-topic: Also keep in mind if you just want to bridge IRC and Matrix, you're better off using a dedicated Matrix bridge. https://matrix.org/bridges/#irc. The purpose of this project, at least imho, is to have a powerful multibridge that works with as many platforms as possible. If you just have two platforms in mind you want to bridge, the Matrix ecosystem offers multiple bridges.

Yes I do run an appservice-irc already... the problem arises from double bridging multiple IRC channels (and a specific ToS clause of libera.chat) that requires an alternative bridge for now.

@gabrc52

gabrc52 commented May 1, 2023

Copy link
Copy Markdown

Can I just remove that part for it to work with any Matrix channel specified in the Matterbridge config file? Or what would be a regex that works with any channel name? Edit: or do I need to create local alias names for each room to be bridged?

I believe you can either set aliases to a catch-all regex (.*) or add

rooms:
   - exclusive: false
     regex: ".*"

to bridge all rooms (which would include DMs as well). I have not tested it, though.

Matterbridge is usually used to bridge existing channels that are not named in a special way like this

Yeah, this is showing one of the differences between Matrix app services and bots with accounts. Since this PR is still under development, it could be improved so that for rooms that don't match the regex, it receives messages using the bot method, and sends them using the app service method.

There's other Matrix bridges with puppeted users that let you link any rooms without needing to have any specific alias (such as the Discord one matrix-appservice-discord), so this is not a Matrix restriction per se.

@poVoq

poVoq commented May 30, 2023

Copy link
Copy Markdown

I noticed that Matterbridge fails to start if the Synapse server is not immediately available. This can be of course fixed via adapting the systemd script, but I think given the http nature of Matrix and the inherent slowness of it, a bit more failure resistance would be cool.

@gabrc52

gabrc52 commented Aug 2, 2023

Copy link
Copy Markdown

For those looking for a Mattermost<->Matrix bridge only, I have done another one: https://github.com/gabrc52/mattermost-to-matrix

@poVoq

poVoq commented Aug 5, 2023

Copy link
Copy Markdown

Any news on merging this?

I have been using it for a while now and it seems to work fine.

Edit: it seems to have issues doing the user puppeteering when joining more than one Matrix channel? @nightmared any idea?

@erebion

erebion commented Sep 7, 2023

Copy link
Copy Markdown

Could this then be used to also do puppeting for Rocket.Chat?

Not sure whether it can also act as the home server part for an appservice.

@nightmared

Copy link
Copy Markdown
Contributor Author

Since I've not worked on this in a long time (nearly a year), and that the PR would have to be updated against code changes in "upstream" matterbridge, perhaps it would be best to close this PR?
Considering this PR haven't seen any update in that long period of time, I would think users are currently running multiple bridges (like matrix-appservice-discord and another bridge) when they need to bridge rooms on three or more platforms together.
Is there really any user of matterbridge with this PR?

@poVoq

poVoq commented Feb 25, 2024

Copy link
Copy Markdown

I tried using it, but it didn't work for more than one channel at a time so I went back to other bridging options.

@nightmared

nightmared commented Feb 25, 2024

Copy link
Copy Markdown
Contributor Author

@poVoq Right, that's what I expected given the lack of polish this PR have received so far (which is my fault, for the most part).

I think you were one of the very few people to give it a try, so it is reasonably safe to assume no one relies on it anymore.
For that reason, I'm going to close the PR.

@nightmared nightmared closed this Feb 25, 2024
@poVoq

poVoq commented Jun 7, 2025

Copy link
Copy Markdown

@antonizoon maybe this is something for your fork? It was almost working, just multi-room support was borked in my tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use matrix Application Service API (matrix)

7 participants