Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Fix prev event lookup in syncapi
Browse files Browse the repository at this point in the history
  • Loading branch information
devonh committed Jul 6, 2023
1 parent d507c5f commit 0dd7ba2
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions syncapi/consumers/roomserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,29 +558,30 @@ func (s *OutputRoomEventConsumer) updateStateEvent(event *rstypes.HeaderedEvent)
var succeeded bool
defer sqlutil.EndTransactionWithCheck(snapshot, &succeeded, &err)

prevEvent, err := snapshot.GetStateEvent(
s.ctx, event.RoomID(), event.Type(), stateKey,
)
if err != nil {
return event, err
}

validRoomID, err := spec.NewRoomID(event.RoomID())
if err != nil {
return event, err
}

sKeyUser := ""
if event.StateKey() != nil {
if *event.StateKey() != "" {
var sku *spec.UserID
sku, err = s.rsAPI.QueryUserIDForSender(s.ctx, *validRoomID, spec.SenderID(stateKey))
if err == nil && sku != nil {
sKey := sku.String()
event.StateKeyResolved = &sKey
sKeyUser = sku.String()
event.StateKeyResolved = &sKeyUser
}
}
}

prevEvent, err := snapshot.GetStateEvent(
s.ctx, event.RoomID(), event.Type(), sKeyUser,
)
if err != nil {
return event, err
}

userID, err := s.rsAPI.QueryUserIDForSender(s.ctx, *validRoomID, event.SenderID())
if err != nil {
return event, err
Expand Down

0 comments on commit 0dd7ba2

Please sign in to comment.