From 914b3607208d1623247fbacbc8f85d53af0790d9 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 19 Jun 2023 14:55:43 +0300 Subject: [PATCH] Switch to new beeper batch send endpoint --- backfill.go | 9 ++++----- go.mod | 2 +- go.sum | 4 ++-- guildportal.go | 2 +- portal.go | 8 ++------ puppet.go | 4 ++-- 6 files changed, 12 insertions(+), 17 deletions(-) diff --git a/backfill.go b/backfill.go index 74f1256..2f2b4d5 100644 --- a/backfill.go +++ b/backfill.go @@ -10,7 +10,6 @@ import ( "github.com/bwmarrin/discordgo" "github.com/rs/zerolog" "maunium.net/go/mautrix" - "maunium.net/go/mautrix/bridge/bridgeconfig" "maunium.net/go/mautrix/event" "maunium.net/go/mautrix/id" @@ -197,7 +196,7 @@ func (portal *Portal) backfillUnlimitedMissed(log zerolog.Logger, source *User, } func (portal *Portal) sendBackfillBatch(log zerolog.Logger, source *User, messages []*discordgo.Message, thread *Thread) { - if portal.bridge.Config.Homeserver.Software == bridgeconfig.SoftwareHungry { + if portal.bridge.SpecVersions.Supports(mautrix.BeeperFeatureBatchSending) { log.Debug().Msg("Using hungryserv, sending messages with batch send endpoint") portal.forwardBatchSend(log, source, messages, thread) } else { @@ -215,9 +214,9 @@ func (portal *Portal) forwardBatchSend(log zerolog.Logger, source *User, message return } log.Info().Int("events", len(evts)).Msg("Converted messages to backfill") - resp, err := portal.MainIntent().BatchSend(portal.MXID, &mautrix.ReqBatchSend{ - BeeperNewMessages: true, - Events: evts, + resp, err := portal.MainIntent().BeeperBatchSend(portal.MXID, &mautrix.ReqBeeperBatchSend{ + Forward: true, + Events: evts, }) if err != nil { log.Err(err).Msg("Error sending backfill batch") diff --git a/go.mod b/go.mod index 5ccf1ea..0d93da5 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/yuin/goldmark v1.5.4 golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 maunium.net/go/maulogger/v2 v2.4.1 - maunium.net/go/mautrix v0.15.3 + maunium.net/go/mautrix v0.15.4-0.20230619114441-3e840e962e24 ) require ( diff --git a/go.sum b/go.sum index 61addee..2c1cbba 100644 --- a/go.sum +++ b/go.sum @@ -65,5 +65,5 @@ maunium.net/go/mauflag v1.0.0 h1:YiaRc0tEI3toYtJMRIfjP+jklH45uDHtT80nUamyD4M= maunium.net/go/mauflag v1.0.0/go.mod h1:nLivPOpTpHnpzEh8jEdSL9UqO9+/KBJFmNRlwKfkPeA= maunium.net/go/maulogger/v2 v2.4.1 h1:N7zSdd0mZkB2m2JtFUsiGTQQAdP0YeFWT7YMc80yAL8= maunium.net/go/maulogger/v2 v2.4.1/go.mod h1:omPuYwYBILeVQobz8uO3XC8DIRuEb5rXYlQSuqrbCho= -maunium.net/go/mautrix v0.15.3 h1:C9BHSUM0gYbuZmAtopuLjIcH5XHLb/ZjTEz7nN+0jN0= -maunium.net/go/mautrix v0.15.3/go.mod h1:zLrQqdxJlLkurRCozTc9CL6FySkgZlO/kpCYxBILSLE= +maunium.net/go/mautrix v0.15.4-0.20230619114441-3e840e962e24 h1:caWWJEYs2G4eLbQ5y7RIrCPUgPU8m1nj6jeyGZAuYVM= +maunium.net/go/mautrix v0.15.4-0.20230619114441-3e840e962e24/go.mod h1:zLrQqdxJlLkurRCozTc9CL6FySkgZlO/kpCYxBILSLE= diff --git a/guildportal.go b/guildportal.go index 6f00355..8230361 100644 --- a/guildportal.go +++ b/guildportal.go @@ -298,7 +298,7 @@ func (guild *Guild) cleanup() { return } intent := guild.bridge.Bot - if guild.bridge.SpecVersions.UnstableFeatures["com.beeper.room_yeeting"] { + if guild.bridge.SpecVersions.Supports(mautrix.BeeperFeatureRoomYeeting) { err := intent.BeeperDeleteRoom(guild.MXID) if err != nil && !errors.Is(err, mautrix.MNotFound) { guild.log.Errorfln("Failed to delete %s using hungryserv yeet endpoint: %v", guild.MXID, err) diff --git a/portal.go b/portal.go index 6dcce43..9c141ba 100644 --- a/portal.go +++ b/portal.go @@ -708,12 +708,8 @@ func (portal *Portal) getReplyTarget(source *User, threadID string, ref *discord if ref == nil { return nil } - isHungry := portal.bridge.Config.Homeserver.Software == bridgeconfig.SoftwareHungry - if !isHungry { - allowNonExistent = false - } // TODO add config option for cross-room replies - crossRoomReplies := isHungry + crossRoomReplies := portal.bridge.Config.Homeserver.Software == bridgeconfig.SoftwareHungry targetPortal := portal if ref.ChannelID != portal.Key.ChannelID && ref.ChannelID != threadID && crossRoomReplies { @@ -1703,7 +1699,7 @@ func (portal *Portal) cleanup(puppetsOnly bool) { return } intent := portal.MainIntent() - if portal.bridge.SpecVersions.UnstableFeatures["com.beeper.room_yeeting"] { + if portal.bridge.SpecVersions.Supports(mautrix.BeeperFeatureRoomYeeting) { err := intent.BeeperDeleteRoom(portal.MXID) if err != nil && !errors.Is(err, mautrix.MNotFound) { portal.log.Err(err).Msg("Failed to delete room using hungryserv yeet endpoint") diff --git a/puppet.go b/puppet.go index 9f4bd1c..0227759 100644 --- a/puppet.go +++ b/puppet.go @@ -9,9 +9,9 @@ import ( "github.com/bwmarrin/discordgo" "github.com/rs/zerolog" + "maunium.net/go/mautrix" "maunium.net/go/mautrix/appservice" "maunium.net/go/mautrix/bridge" - "maunium.net/go/mautrix/bridge/bridgeconfig" "maunium.net/go/mautrix/id" "go.mau.fi/mautrix-discord/database" @@ -347,7 +347,7 @@ func (puppet *Puppet) UpdateContactInfo(info *discordgo.User) bool { } func (puppet *Puppet) ResendContactInfo() { - if puppet.bridge.Config.Homeserver.Software != bridgeconfig.SoftwareHungry || puppet.ContactInfoSet { + if !puppet.bridge.SpecVersions.Supports(mautrix.BeeperFeatureArbitraryProfileMeta) || puppet.ContactInfoSet { return } contactInfo := map[string]any{