Skip to content

Commit

Permalink
Don't make recursive contexts in loop
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Jan 25, 2024
1 parent 6cc145d commit 464914a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions backfill.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
}
Expand Down

0 comments on commit 464914a

Please sign in to comment.