From 464914a5a8cedf7208a88c39b4fbd3dad5bd2de3 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 25 Jan 2024 17:41:55 +0200 Subject: [PATCH] Don't make recursive contexts in loop --- backfill.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backfill.go b/backfill.go index 03bbc7a..1408987 100644 --- a/backfill.go +++ b/backfill.go @@ -466,13 +466,14 @@ func (portal *Portal) convertAndSendBackfill(ctx context.Context, source *User, } else { ctx = context.WithValue(ctx, msgconvContextKeyBackfill, backfillTypeHistorical) } + sendReactionsInBatch := portal.bridge.SpecVersions.Supports(mautrix.BeeperFeatureBatchSending) for _, msg := range messages { intent := portal.bridge.GetPuppetByID(msg.SenderId).IntentFor(portal) if intent == nil { log.Warn().Int64("sender_id", msg.SenderId).Msg("Failed to get intent for sender") continue } - ctx = context.WithValue(ctx, msgconvContextKeyIntent, intent) + ctx := context.WithValue(ctx, msgconvContextKeyIntent, intent) converted := portal.MsgConv.ToMatrix(ctx, msg) if portal.bridge.Config.Bridge.CaptionInMessage { converted.MergeCaption() @@ -482,7 +483,6 @@ func (portal *Portal) convertAndSendBackfill(ctx context.Context, source *User, continue } var reactionsToSendSeparately []*table.LSUpsertReaction - sendReactionsInBatch := portal.bridge.SpecVersions.Supports(mautrix.BeeperFeatureBatchSending) if !sendReactionsInBatch { reactionsToSendSeparately = msg.Reactions }