Compare commits
12 Commits
megabridge
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 1717ddb30f | |||
|
|
19e26674e6 | ||
|
|
daf6b9420c | ||
|
|
fab784bfd8 | ||
|
|
17c1938b4c | ||
|
|
ca9f032234 | ||
|
|
5c4527f1b2 | ||
|
|
11b1ea5aa6 | ||
|
|
d7292a0706 | ||
|
|
9eaf213091 | ||
|
|
c8c00a42bb | ||
|
|
2182c0d38f |
4
.github/workflows/go.yml
vendored
4
.github/workflows/go.yml
vendored
@@ -8,8 +8,8 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
go-version: ["1.24", "1.25"]
|
||||
name: Lint ${{ matrix.go-version == '1.25' && '(latest)' || '(old)' }}
|
||||
go-version: ["1.25", "1.26"]
|
||||
name: Lint ${{ matrix.go-version == '1.26' && '(latest)' || '(old)' }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
12
CHANGELOG.md
12
CHANGELOG.md
@@ -1,3 +1,15 @@
|
||||
# v0.7.6 (2026-02-16)
|
||||
|
||||
* Bumped minimum Go version to 1.25.
|
||||
* Updated Docker image to Alpine 3.23.
|
||||
* Added support for following tombstones.
|
||||
* Added support for disabling link previews in messages sent to Discord using
|
||||
[MSC4095].
|
||||
* Added support for federation thumbnail endpoint when using direct media.
|
||||
* Disabled using `restricted` join rules by default.
|
||||
|
||||
[MSC4095]: https://github.com/matrix-org/matrix-spec-proposals/pull/4095
|
||||
|
||||
# v0.7.5 (2025-07-16)
|
||||
|
||||
* Fixed federation key response when using direct media.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM golang:1-alpine3.22 AS builder
|
||||
FROM golang:1-alpine3.23 AS builder
|
||||
|
||||
RUN apk add --no-cache git ca-certificates build-base su-exec olm-dev
|
||||
|
||||
@@ -6,7 +6,7 @@ COPY . /build
|
||||
WORKDIR /build
|
||||
RUN go build -o /usr/bin/mautrix-discord
|
||||
|
||||
FROM alpine:3.22
|
||||
FROM alpine:3.23
|
||||
|
||||
ENV UID=1337 \
|
||||
GID=1337
|
||||
@@ -17,5 +17,6 @@ COPY --from=builder /usr/bin/mautrix-discord /usr/bin/mautrix-discord
|
||||
COPY --from=builder /build/example-config.yaml /opt/mautrix-discord/example-config.yaml
|
||||
COPY --from=builder /build/docker-run.sh /docker-run.sh
|
||||
VOLUME /data
|
||||
WORKDIR /data
|
||||
|
||||
CMD ["/docker-run.sh"]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM alpine:3.22
|
||||
FROM alpine:3.23
|
||||
|
||||
ENV UID=1337 \
|
||||
GID=1337
|
||||
@@ -10,5 +10,6 @@ COPY $EXECUTABLE /usr/bin/mautrix-discord
|
||||
COPY ./example-config.yaml /opt/mautrix-discord/example-config.yaml
|
||||
COPY ./docker-run.sh /docker-run.sh
|
||||
VOLUME /data
|
||||
WORKDIR /data
|
||||
|
||||
CMD ["/docker-run.sh"]
|
||||
|
||||
16
commands.go
16
commands.go
@@ -706,9 +706,25 @@ func fnBridge(ce *WrappedCommandEvent) {
|
||||
}
|
||||
portal := ce.User.GetExistingPortalByID(channelID)
|
||||
if portal == nil {
|
||||
// HACK: Before giving up, discover if the user is trying to join a
|
||||
// thread. Then, cause the creation of a portal.
|
||||
// This is for forum channel threads; they don't show up on the
|
||||
// forum channels.
|
||||
ch, err := ce.User.Session.Channel(channelID)
|
||||
if err != nil {
|
||||
ce.Reply("Channel not found")
|
||||
return
|
||||
}
|
||||
|
||||
if ch.Type != discordgo.ChannelTypeGuildPublicThread &&
|
||||
ch.Type != discordgo.ChannelTypeGuildPrivateThread {
|
||||
return
|
||||
}
|
||||
|
||||
ce.ZLog.Debug().Msg("Adding public / private thread as a portal")
|
||||
portal = ce.User.GetPortalByID(channelID, ch.Type)
|
||||
|
||||
}
|
||||
portal.roomCreateLock.Lock()
|
||||
defer portal.roomCreateLock.Unlock()
|
||||
if portal.MXID != "" {
|
||||
|
||||
20
database/json.go
Normal file
20
database/json.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"go.mau.fi/util/dbutil"
|
||||
)
|
||||
|
||||
// Backported from mautrix/go-util@e5cb5e96d15cb87ffe6e5970c2f90ee47980e715.
|
||||
|
||||
// JSONPtr is a convenience function for wrapping a pointer to a value in the JSON utility, but removing typed nils
|
||||
// (i.e. preventing nils from turning into the string "null" in the database).
|
||||
func JSONPtr[T any](val *T) dbutil.JSON {
|
||||
return dbutil.JSON{Data: UntypedNil(val)}
|
||||
}
|
||||
|
||||
func UntypedNil[T any](val *T) any {
|
||||
if val == nil {
|
||||
return nil
|
||||
}
|
||||
return val
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
-- v0 -> v23 (compatible with v19+): Latest revision
|
||||
-- v0 -> v24 (compatible with v19+): Latest revision
|
||||
|
||||
CREATE TABLE guild (
|
||||
dcid TEXT PRIMARY KEY,
|
||||
@@ -92,7 +92,8 @@ CREATE TABLE "user" (
|
||||
space_room TEXT,
|
||||
dm_space_room TEXT,
|
||||
|
||||
read_state_version INTEGER NOT NULL DEFAULT 0
|
||||
read_state_version INTEGER NOT NULL DEFAULT 0,
|
||||
heartbeat_session jsonb
|
||||
);
|
||||
|
||||
CREATE TABLE user_portal (
|
||||
|
||||
2
database/upgrades/24-user-heartbeat-session.sql
Normal file
2
database/upgrades/24-user-heartbeat-session.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
-- v24 (compatible with v19+): Add persisted heartbeat sessions
|
||||
ALTER TABLE "user" ADD COLUMN heartbeat_session jsonb;
|
||||
@@ -3,6 +3,7 @@ package database
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
"github.com/bwmarrin/discordgo"
|
||||
"go.mau.fi/util/dbutil"
|
||||
log "maunium.net/go/maulogger/v2"
|
||||
"maunium.net/go/mautrix/id"
|
||||
@@ -21,18 +22,18 @@ func (uq *UserQuery) New() *User {
|
||||
}
|
||||
|
||||
func (uq *UserQuery) GetByMXID(userID id.UserID) *User {
|
||||
query := `SELECT mxid, dcid, discord_token, management_room, space_room, dm_space_room, read_state_version FROM "user" WHERE mxid=$1`
|
||||
query := `SELECT mxid, dcid, discord_token, management_room, space_room, dm_space_room, read_state_version, heartbeat_session FROM "user" WHERE mxid=$1`
|
||||
return uq.New().Scan(uq.db.QueryRow(query, userID))
|
||||
}
|
||||
|
||||
func (uq *UserQuery) GetByID(id string) *User {
|
||||
query := `SELECT mxid, dcid, discord_token, management_room, space_room, dm_space_room, read_state_version FROM "user" WHERE dcid=$1`
|
||||
query := `SELECT mxid, dcid, discord_token, management_room, space_room, dm_space_room, read_state_version, heartbeat_session FROM "user" WHERE dcid=$1`
|
||||
return uq.New().Scan(uq.db.QueryRow(query, id))
|
||||
}
|
||||
|
||||
func (uq *UserQuery) GetAllWithToken() []*User {
|
||||
query := `
|
||||
SELECT mxid, dcid, discord_token, management_room, space_room, dm_space_room, read_state_version
|
||||
SELECT mxid, dcid, discord_token, management_room, space_room, dm_space_room, read_state_version, heartbeat_session
|
||||
FROM "user" WHERE discord_token IS NOT NULL
|
||||
`
|
||||
rows, err := uq.db.Query(query)
|
||||
@@ -60,13 +61,14 @@ type User struct {
|
||||
ManagementRoom id.RoomID
|
||||
SpaceRoom id.RoomID
|
||||
DMSpaceRoom id.RoomID
|
||||
HeartbeatSession *discordgo.HeartbeatSession
|
||||
|
||||
ReadStateVersion int
|
||||
}
|
||||
|
||||
func (u *User) Scan(row dbutil.Scannable) *User {
|
||||
var discordID, managementRoom, spaceRoom, dmSpaceRoom, discordToken sql.NullString
|
||||
err := row.Scan(&u.MXID, &discordID, &discordToken, &managementRoom, &spaceRoom, &dmSpaceRoom, &u.ReadStateVersion)
|
||||
err := row.Scan(&u.MXID, &discordID, &discordToken, &managementRoom, &spaceRoom, &dmSpaceRoom, &u.ReadStateVersion, dbutil.JSON{Data: &u.HeartbeatSession})
|
||||
if err != nil {
|
||||
if err != sql.ErrNoRows {
|
||||
u.log.Errorln("Database scan failed:", err)
|
||||
@@ -83,8 +85,8 @@ func (u *User) Scan(row dbutil.Scannable) *User {
|
||||
}
|
||||
|
||||
func (u *User) Insert() {
|
||||
query := `INSERT INTO "user" (mxid, dcid, discord_token, management_room, space_room, dm_space_room, read_state_version) VALUES ($1, $2, $3, $4, $5, $6, $7)`
|
||||
_, err := u.db.Exec(query, u.MXID, strPtr(u.DiscordID), strPtr(u.DiscordToken), strPtr(string(u.ManagementRoom)), strPtr(string(u.SpaceRoom)), strPtr(string(u.DMSpaceRoom)), u.ReadStateVersion)
|
||||
query := `INSERT INTO "user" (mxid, dcid, discord_token, management_room, space_room, dm_space_room, read_state_version, heartbeat_session) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)`
|
||||
_, err := u.db.Exec(query, u.MXID, strPtr(u.DiscordID), strPtr(u.DiscordToken), strPtr(string(u.ManagementRoom)), strPtr(string(u.SpaceRoom)), strPtr(string(u.DMSpaceRoom)), u.ReadStateVersion, JSONPtr(u.HeartbeatSession))
|
||||
if err != nil {
|
||||
u.log.Warnfln("Failed to insert %s: %v", u.MXID, err)
|
||||
panic(err)
|
||||
@@ -92,8 +94,8 @@ func (u *User) Insert() {
|
||||
}
|
||||
|
||||
func (u *User) Update() {
|
||||
query := `UPDATE "user" SET dcid=$1, discord_token=$2, management_room=$3, space_room=$4, dm_space_room=$5, read_state_version=$6 WHERE mxid=$7`
|
||||
_, err := u.db.Exec(query, strPtr(u.DiscordID), strPtr(u.DiscordToken), strPtr(string(u.ManagementRoom)), strPtr(string(u.SpaceRoom)), strPtr(string(u.DMSpaceRoom)), u.ReadStateVersion, u.MXID)
|
||||
query := `UPDATE "user" SET dcid=$1, discord_token=$2, management_room=$3, space_room=$4, dm_space_room=$5, read_state_version=$6, heartbeat_session=$7 WHERE mxid=$8`
|
||||
_, err := u.db.Exec(query, strPtr(u.DiscordID), strPtr(u.DiscordToken), strPtr(string(u.ManagementRoom)), strPtr(string(u.SpaceRoom)), strPtr(string(u.DMSpaceRoom)), u.ReadStateVersion, JSONPtr(u.HeartbeatSession), u.MXID)
|
||||
if err != nil {
|
||||
u.log.Warnfln("Failed to update %q: %v", u.MXID, err)
|
||||
panic(err)
|
||||
|
||||
@@ -154,6 +154,7 @@ func newDirectMediaAPI(br *DiscordBridge) *DirectMediaAPI {
|
||||
addRoutes("r0")
|
||||
addRoutes("v1")
|
||||
federationRouter.HandleFunc("/v1/media/download/{mediaID}", dma.DownloadMedia).Methods(http.MethodGet)
|
||||
federationRouter.HandleFunc("/v1/media/thumbnail/{mediaID}", dma.DownloadMedia).Methods(http.MethodGet)
|
||||
federationRouter.HandleFunc("/v1/version", dma.ks.GetServerVersion).Methods(http.MethodGet)
|
||||
mediaRouter.NotFoundHandler = http.HandlerFunc(dma.UnknownEndpoint)
|
||||
mediaRouter.MethodNotAllowedHandler = http.HandlerFunc(dma.UnsupportedMethod)
|
||||
@@ -556,7 +557,7 @@ func (dma *DirectMediaAPI) proxyDownload(ctx context.Context, w http.ResponseWri
|
||||
func (dma *DirectMediaAPI) DownloadMedia(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
log := zerolog.Ctx(ctx)
|
||||
isNewFederation := strings.HasPrefix(r.URL.Path, "/_matrix/federation/v1/media/download/")
|
||||
isNewFederation := strings.HasPrefix(r.URL.Path, "/_matrix/federation/v1/media/")
|
||||
vars := mux.Vars(r)
|
||||
if !isNewFederation && vars["serverName"] != dma.cfg.ServerName {
|
||||
jsonResponse(w, http.StatusNotFound, &mautrix.RespError{
|
||||
|
||||
@@ -130,7 +130,7 @@ bridge:
|
||||
message_error_notices: true
|
||||
# Should the bridge use space-restricted join rules instead of invite-only for guild rooms?
|
||||
# This can avoid unnecessary invite events in guild rooms when members are synced in.
|
||||
restricted_rooms: true
|
||||
restricted_rooms: false
|
||||
# Should the bridge automatically join the user to threads on Discord when the thread is opened on Matrix?
|
||||
# This only works with clients that support thread read receipts (MSC3771 added in Matrix v1.4).
|
||||
autojoin_thread_on_open: true
|
||||
|
||||
7
go.mod
7
go.mod
@@ -1,8 +1,8 @@
|
||||
module go.mau.fi/mautrix-discord
|
||||
|
||||
go 1.24.0
|
||||
go 1.25.0
|
||||
|
||||
toolchain go1.25.0
|
||||
toolchain go1.26.0
|
||||
|
||||
require (
|
||||
github.com/bwmarrin/discordgo v0.27.0
|
||||
@@ -26,6 +26,7 @@ require (
|
||||
require (
|
||||
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
@@ -42,4 +43,4 @@ require (
|
||||
maunium.net/go/mauflag v1.0.0 // indirect
|
||||
)
|
||||
|
||||
replace github.com/bwmarrin/discordgo => github.com/beeper/discordgo v0.0.0-20250607214857-f23a8518ece2
|
||||
replace github.com/bwmarrin/discordgo => github.com/beeper/discordgo v0.0.0-20260215125047-ccf8cbaa0a9f
|
||||
|
||||
6
go.sum
6
go.sum
@@ -1,7 +1,7 @@
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
|
||||
github.com/beeper/discordgo v0.0.0-20250607214857-f23a8518ece2 h1:8lgTjYGSIlS90f0jiFfEC4UwxCq9FiUo4dKwjknbupQ=
|
||||
github.com/beeper/discordgo v0.0.0-20250607214857-f23a8518ece2/go.mod h1:59+AOzzjmL6onAh62nuLXmn7dJCaC/owDLWbGtjTcFA=
|
||||
github.com/beeper/discordgo v0.0.0-20260215125047-ccf8cbaa0a9f h1:A+SRmETpSnFixbP1x6u7sQdoi8cOuYfL5bkDJy9F/Pg=
|
||||
github.com/beeper/discordgo v0.0.0-20260215125047-ccf8cbaa0a9f/go.mod h1:lioivnibvB8j1KcF5TVpLdRLKCKHtcl8A03GpxRCre4=
|
||||
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
|
||||
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
@@ -11,6 +11,8 @@ github.com/gabriel-vasile/mimetype v1.4.9/go.mod h1:WnSQhFKJuBlRyLiKohA/2DtIlPFA
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
|
||||
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
|
||||
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||
|
||||
2
main.go
2
main.go
@@ -187,7 +187,7 @@ func main() {
|
||||
Name: "mautrix-discord",
|
||||
URL: "https://github.com/mautrix/discord",
|
||||
Description: "A Matrix-Discord puppeting bridge.",
|
||||
Version: "0.7.5",
|
||||
Version: "0.7.6",
|
||||
ProtocolName: "Discord",
|
||||
BeeperServiceName: "discordgo",
|
||||
BeeperNetworkName: "discord",
|
||||
|
||||
28
portal.go
28
portal.go
@@ -1522,10 +1522,16 @@ func (portal *Portal) RefererOptIfUser(sess *discordgo.Session, threadID string)
|
||||
}
|
||||
|
||||
func (portal *Portal) handleMatrixMessage(sender *User, evt *event.Event) {
|
||||
if portal.IsPrivateChat() && sender.DiscordID != portal.Key.Receiver {
|
||||
if portal.IsPrivateChat() {
|
||||
if !sender.IsLoggedIn() {
|
||||
go portal.sendMessageMetrics(evt, errUserNotLoggedIn, "Ignoring")
|
||||
return
|
||||
}
|
||||
if sender.DiscordID != portal.Key.Receiver {
|
||||
go portal.sendMessageMetrics(evt, errUserNotReceiver, "Ignoring")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
content, ok := evt.Content.Parsed.(*event.MessageEventContent)
|
||||
if !ok {
|
||||
@@ -1650,13 +1656,18 @@ func (portal *Portal) handleMatrixMessage(sender *User, evt *event.Event) {
|
||||
ID: "0",
|
||||
Filename: filename,
|
||||
Description: description,
|
||||
OriginalContentType: content.Info.MimeType,
|
||||
}
|
||||
sendReq.Attachments = []*discordgo.MessageAttachment{att}
|
||||
isClip := false
|
||||
prep, err := sender.Session.ChannelAttachmentCreate(channelID, &discordgo.ReqPrepareAttachments{
|
||||
Files: []*discordgo.FilePrepare{{
|
||||
Size: len(data),
|
||||
Name: att.Filename,
|
||||
ID: sender.NextDiscordUploadID(),
|
||||
|
||||
IsClip: &isClip,
|
||||
OriginalContentType: att.OriginalContentType,
|
||||
}},
|
||||
}, portal.RefererOpt(threadID))
|
||||
if err != nil {
|
||||
@@ -1918,12 +1929,13 @@ func (portal *Portal) getMatrixUsers() ([]id.UserID, error) {
|
||||
}
|
||||
|
||||
func (portal *Portal) handleMatrixReaction(sender *User, evt *event.Event) {
|
||||
if !sender.IsLoggedIn() {
|
||||
go portal.sendMessageMetrics(evt, errUserNotLoggedIn, "Ignoring")
|
||||
return
|
||||
}
|
||||
if portal.IsPrivateChat() && sender.DiscordID != portal.Key.Receiver {
|
||||
go portal.sendMessageMetrics(evt, errUserNotReceiver, "Ignoring")
|
||||
return
|
||||
} else if !sender.IsLoggedIn() {
|
||||
//go portal.sendMessageMetrics(evt, errReactionUserNotLoggedIn, "Ignoring")
|
||||
return
|
||||
}
|
||||
|
||||
reaction := evt.Content.AsReaction()
|
||||
@@ -2101,10 +2113,16 @@ func (portal *Portal) handleDiscordReaction(user *User, reaction *discordgo.Mess
|
||||
}
|
||||
|
||||
func (portal *Portal) handleMatrixRedaction(sender *User, evt *event.Event) {
|
||||
if portal.IsPrivateChat() && sender.DiscordID != portal.Key.Receiver {
|
||||
if portal.IsPrivateChat() {
|
||||
if !sender.IsLoggedIn() {
|
||||
go portal.sendMessageMetrics(evt, errUserNotLoggedIn, "Ignoring")
|
||||
return
|
||||
}
|
||||
if sender.DiscordID != portal.Key.Receiver {
|
||||
go portal.sendMessageMetrics(evt, errUserNotReceiver, "Ignoring")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
sess := sender.Session
|
||||
if sess == nil && portal.RelayWebhookID == "" {
|
||||
|
||||
18
user.go
18
user.go
@@ -550,6 +550,17 @@ func (user *User) Connect() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if user.HeartbeatSession == nil || user.HeartbeatSession.IsExpired() {
|
||||
user.log.Debug().Msg("Creating new heartbeat session")
|
||||
sess := discordgo.NewHeartbeatSession()
|
||||
user.HeartbeatSession = &sess
|
||||
}
|
||||
user.HeartbeatSession.BumpLastUsed()
|
||||
user.Update()
|
||||
// make discordgo use our session instead of the one it creates automatically
|
||||
session.HeartbeatSession = *user.HeartbeatSession
|
||||
|
||||
if user.bridge.Config.Bridge.Proxy != "" {
|
||||
u, _ := url.Parse(user.bridge.Config.Bridge.Proxy)
|
||||
tlsConf := &tls.Config{
|
||||
@@ -569,7 +580,10 @@ func (user *User) Connect() error {
|
||||
} else {
|
||||
session.LogLevel = discordgo.LogInformational
|
||||
}
|
||||
userDiscordLog := user.log.With().Str("component", "discordgo").Logger()
|
||||
userDiscordLog := user.log.With().
|
||||
Str("component", "discordgo").
|
||||
Str("heartbeat_session", session.HeartbeatSession.ID.String()).
|
||||
Logger()
|
||||
session.Logger = func(msgL, caller int, format string, a ...interface{}) {
|
||||
userDiscordLog.WithLevel(discordToZeroLevel(msgL)).Caller(caller+1).Msgf(strings.TrimSpace(format), a...) // zerolog-allow-msgf
|
||||
}
|
||||
@@ -807,6 +821,7 @@ func (user *User) subscribeGuilds(delay time.Duration) {
|
||||
func (user *User) resumeHandler(_ *discordgo.Resumed) {
|
||||
user.log.Debug().Msg("Discord connection resumed")
|
||||
user.subscribeGuilds(0 * time.Second)
|
||||
user.BridgeState.Send(status.BridgeState{StateEvent: status.StateConnected})
|
||||
}
|
||||
|
||||
func (user *User) addPrivateChannelToSpace(portal *Portal) bool {
|
||||
@@ -1007,7 +1022,6 @@ func (user *User) connectedHandler(_ *discordgo.Connect) {
|
||||
user.log.Debug().Msg("Connected to Discord")
|
||||
if user.wasDisconnected {
|
||||
user.wasDisconnected = false
|
||||
user.BridgeState.Send(status.BridgeState{StateEvent: status.StateConnected})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user