mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-29 17:53:09 -06:00
Tidy up that create check further
This commit is contained in:
parent
42e995792d
commit
c5c4381f3d
|
|
@ -150,7 +150,7 @@ func (r *Queryer) QueryMissingAuthPrevEvents(
|
|||
|
||||
for _, prevEventID := range request.PrevEventIDs {
|
||||
state, err := r.DB.StateAtEventIDs(ctx, []string{prevEventID})
|
||||
if err != nil || len(state) == 0 || ((state[0].EventTypeNID != types.MRoomCreateNID || state[0].EventStateKeyNID != types.EmptyStateKeyNID) && state[0].BeforeStateSnapshotNID == 0) {
|
||||
if err != nil || len(state) == 0 || (!state[0].IsCreate() && state[0].BeforeStateSnapshotNID == 0) {
|
||||
response.MissingPrevEventIDs = append(response.MissingPrevEventIDs, prevEventID)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,6 +83,10 @@ type StateKeyTuple struct {
|
|||
EventStateKeyNID EventStateKeyNID
|
||||
}
|
||||
|
||||
func (a StateKeyTuple) IsCreate() bool {
|
||||
return a.EventTypeNID == MRoomCreateNID && a.EventStateKeyNID == EmptyStateKeyNID
|
||||
}
|
||||
|
||||
// LessThan returns true if this state key is less than the other state key.
|
||||
// The ordering is arbitrary and is used to implement binary search and to efficiently deduplicate entries.
|
||||
func (a StateKeyTuple) LessThan(b StateKeyTuple) bool {
|
||||
|
|
|
|||
Loading…
Reference in a new issue