mirror of
https://github.com/matrix-org/dendrite.git
synced 2024-11-26 08:11:55 -06:00
Fix prev event lookup in syncapi (#3141)
The syncapi operates using userID's so when querying for the previous state event we need to lookup the userID from the given senderID before the state query.
This commit is contained in:
parent
d507c5fc95
commit
3a125fd8fa
|
@ -558,29 +558,28 @@ func (s *OutputRoomEventConsumer) updateStateEvent(event *rstypes.HeaderedEvent)
|
||||||
var succeeded bool
|
var succeeded bool
|
||||||
defer sqlutil.EndTransactionWithCheck(snapshot, &succeeded, &err)
|
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())
|
validRoomID, err := spec.NewRoomID(event.RoomID())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return event, err
|
return event, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if event.StateKey() != nil {
|
sKeyUser := ""
|
||||||
if *event.StateKey() != "" {
|
if stateKey != "" {
|
||||||
var sku *spec.UserID
|
var sku *spec.UserID
|
||||||
sku, err = s.rsAPI.QueryUserIDForSender(s.ctx, *validRoomID, spec.SenderID(stateKey))
|
sku, err = s.rsAPI.QueryUserIDForSender(s.ctx, *validRoomID, spec.SenderID(stateKey))
|
||||||
if err == nil && sku != nil {
|
if err == nil && sku != nil {
|
||||||
sKey := sku.String()
|
sKeyUser = sku.String()
|
||||||
event.StateKeyResolved = &sKey
|
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())
|
userID, err := s.rsAPI.QueryUserIDForSender(s.ctx, *validRoomID, event.SenderID())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return event, err
|
return event, err
|
||||||
|
|
Loading…
Reference in a new issue