Add IsStateEvent utility method for checking if EventStateKeyNID is 0

This commit is contained in:
Mark Haines 2017-02-14 17:21:55 +00:00
parent 8526277736
commit 2a33b17ee1
2 changed files with 6 additions and 1 deletions

View file

@ -124,7 +124,7 @@ func calculateAndStoreStateMany(db RoomEventDatabase, roomNID types.RoomNID, pre
} }
fullState = append(fullState, entries...) fullState = append(fullState, entries...)
} }
if prevState.EventStateKeyNID != 0 { if prevState.IsStateEvent() {
// If the prev event was a state event then add an entry for the event itself // If the prev event was a state event then add an entry for the event itself
// so that we get the state after the event rather than the state before. // so that we get the state after the event rather than the state before.
fullState = append(fullState, prevState.StateEntry) fullState = append(fullState, prevState.StateEntry)

View file

@ -74,6 +74,11 @@ type StateAtEvent struct {
StateEntry StateEntry
} }
// IsStateEvent returns whether the event the state is at is a state event.
func (s StateAtEvent) IsStateEvent() bool {
return s.EventStateKeyNID != 0
}
// An Event is a gomatrixserverlib.Event with the numeric event ID attached. // An Event is a gomatrixserverlib.Event with the numeric event ID attached.
// It is when performing bulk event lookup in the database. // It is when performing bulk event lookup in the database.
type Event struct { type Event struct {