forked from mirror/mautrix-discord
Switch to new beeper batch send endpoint
This commit is contained in:
parent
11b91dc299
commit
914b360720
6 changed files with 12 additions and 17 deletions
|
@ -10,7 +10,6 @@ import (
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"maunium.net/go/mautrix"
|
"maunium.net/go/mautrix"
|
||||||
"maunium.net/go/mautrix/bridge/bridgeconfig"
|
|
||||||
"maunium.net/go/mautrix/event"
|
"maunium.net/go/mautrix/event"
|
||||||
"maunium.net/go/mautrix/id"
|
"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) {
|
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")
|
log.Debug().Msg("Using hungryserv, sending messages with batch send endpoint")
|
||||||
portal.forwardBatchSend(log, source, messages, thread)
|
portal.forwardBatchSend(log, source, messages, thread)
|
||||||
} else {
|
} else {
|
||||||
|
@ -215,9 +214,9 @@ func (portal *Portal) forwardBatchSend(log zerolog.Logger, source *User, message
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Info().Int("events", len(evts)).Msg("Converted messages to backfill")
|
log.Info().Int("events", len(evts)).Msg("Converted messages to backfill")
|
||||||
resp, err := portal.MainIntent().BatchSend(portal.MXID, &mautrix.ReqBatchSend{
|
resp, err := portal.MainIntent().BeeperBatchSend(portal.MXID, &mautrix.ReqBeeperBatchSend{
|
||||||
BeeperNewMessages: true,
|
Forward: true,
|
||||||
Events: evts,
|
Events: evts,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Err(err).Msg("Error sending backfill batch")
|
log.Err(err).Msg("Error sending backfill batch")
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -16,7 +16,7 @@ require (
|
||||||
github.com/yuin/goldmark v1.5.4
|
github.com/yuin/goldmark v1.5.4
|
||||||
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1
|
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1
|
||||||
maunium.net/go/maulogger/v2 v2.4.1
|
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 (
|
require (
|
||||||
|
|
4
go.sum
4
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/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 h1:N7zSdd0mZkB2m2JtFUsiGTQQAdP0YeFWT7YMc80yAL8=
|
||||||
maunium.net/go/maulogger/v2 v2.4.1/go.mod h1:omPuYwYBILeVQobz8uO3XC8DIRuEb5rXYlQSuqrbCho=
|
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.4-0.20230619114441-3e840e962e24 h1:caWWJEYs2G4eLbQ5y7RIrCPUgPU8m1nj6jeyGZAuYVM=
|
||||||
maunium.net/go/mautrix v0.15.3/go.mod h1:zLrQqdxJlLkurRCozTc9CL6FySkgZlO/kpCYxBILSLE=
|
maunium.net/go/mautrix v0.15.4-0.20230619114441-3e840e962e24/go.mod h1:zLrQqdxJlLkurRCozTc9CL6FySkgZlO/kpCYxBILSLE=
|
||||||
|
|
|
@ -298,7 +298,7 @@ func (guild *Guild) cleanup() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
intent := guild.bridge.Bot
|
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)
|
err := intent.BeeperDeleteRoom(guild.MXID)
|
||||||
if err != nil && !errors.Is(err, mautrix.MNotFound) {
|
if err != nil && !errors.Is(err, mautrix.MNotFound) {
|
||||||
guild.log.Errorfln("Failed to delete %s using hungryserv yeet endpoint: %v", guild.MXID, err)
|
guild.log.Errorfln("Failed to delete %s using hungryserv yeet endpoint: %v", guild.MXID, err)
|
||||||
|
|
|
@ -708,12 +708,8 @@ func (portal *Portal) getReplyTarget(source *User, threadID string, ref *discord
|
||||||
if ref == nil {
|
if ref == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
isHungry := portal.bridge.Config.Homeserver.Software == bridgeconfig.SoftwareHungry
|
|
||||||
if !isHungry {
|
|
||||||
allowNonExistent = false
|
|
||||||
}
|
|
||||||
// TODO add config option for cross-room replies
|
// TODO add config option for cross-room replies
|
||||||
crossRoomReplies := isHungry
|
crossRoomReplies := portal.bridge.Config.Homeserver.Software == bridgeconfig.SoftwareHungry
|
||||||
|
|
||||||
targetPortal := portal
|
targetPortal := portal
|
||||||
if ref.ChannelID != portal.Key.ChannelID && ref.ChannelID != threadID && crossRoomReplies {
|
if ref.ChannelID != portal.Key.ChannelID && ref.ChannelID != threadID && crossRoomReplies {
|
||||||
|
@ -1703,7 +1699,7 @@ func (portal *Portal) cleanup(puppetsOnly bool) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
intent := portal.MainIntent()
|
intent := portal.MainIntent()
|
||||||
if portal.bridge.SpecVersions.UnstableFeatures["com.beeper.room_yeeting"] {
|
if portal.bridge.SpecVersions.Supports(mautrix.BeeperFeatureRoomYeeting) {
|
||||||
err := intent.BeeperDeleteRoom(portal.MXID)
|
err := intent.BeeperDeleteRoom(portal.MXID)
|
||||||
if err != nil && !errors.Is(err, mautrix.MNotFound) {
|
if err != nil && !errors.Is(err, mautrix.MNotFound) {
|
||||||
portal.log.Err(err).Msg("Failed to delete room using hungryserv yeet endpoint")
|
portal.log.Err(err).Msg("Failed to delete room using hungryserv yeet endpoint")
|
||||||
|
|
|
@ -9,9 +9,9 @@ import (
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
|
|
||||||
|
"maunium.net/go/mautrix"
|
||||||
"maunium.net/go/mautrix/appservice"
|
"maunium.net/go/mautrix/appservice"
|
||||||
"maunium.net/go/mautrix/bridge"
|
"maunium.net/go/mautrix/bridge"
|
||||||
"maunium.net/go/mautrix/bridge/bridgeconfig"
|
|
||||||
"maunium.net/go/mautrix/id"
|
"maunium.net/go/mautrix/id"
|
||||||
|
|
||||||
"go.mau.fi/mautrix-discord/database"
|
"go.mau.fi/mautrix-discord/database"
|
||||||
|
@ -347,7 +347,7 @@ func (puppet *Puppet) UpdateContactInfo(info *discordgo.User) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (puppet *Puppet) ResendContactInfo() {
|
func (puppet *Puppet) ResendContactInfo() {
|
||||||
if puppet.bridge.Config.Homeserver.Software != bridgeconfig.SoftwareHungry || puppet.ContactInfoSet {
|
if !puppet.bridge.SpecVersions.Supports(mautrix.BeeperFeatureArbitraryProfileMeta) || puppet.ContactInfoSet {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
contactInfo := map[string]any{
|
contactInfo := map[string]any{
|
||||||
|
|
Loading…
Reference in a new issue