mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-02 14:12:47 +00:00
Various roominfo tweaks (#2607)
This commit is contained in:
parent
eab87ef07d
commit
ca3fa58388
5 changed files with 50 additions and 16 deletions
|
@ -217,6 +217,14 @@ func (u *RoomUpdater) SetLatestEvents(
|
|||
roomNID types.RoomNID, latest []types.StateAtEventAndReference, lastEventNIDSent types.EventNID,
|
||||
currentStateSnapshotNID types.StateSnapshotNID,
|
||||
) error {
|
||||
switch {
|
||||
case len(latest) == 0:
|
||||
return fmt.Errorf("cannot set latest events with no latest event references")
|
||||
case currentStateSnapshotNID == 0:
|
||||
return fmt.Errorf("cannot set latest events with invalid state snapshot NID")
|
||||
case lastEventNIDSent == 0:
|
||||
return fmt.Errorf("cannot set latest events with invalid latest event NID")
|
||||
}
|
||||
eventNIDs := make([]types.EventNID, len(latest))
|
||||
for i := range latest {
|
||||
eventNIDs[i] = latest[i].EventNID
|
||||
|
@ -229,8 +237,10 @@ func (u *RoomUpdater) SetLatestEvents(
|
|||
// Since it's entirely possible that this types.RoomInfo came from the
|
||||
// cache, we should make sure to update that entry so that the next run
|
||||
// works from live data.
|
||||
u.roomInfo.SetStateSnapshotNID(currentStateSnapshotNID)
|
||||
u.roomInfo.SetIsStub(false)
|
||||
if u.roomInfo != nil {
|
||||
u.roomInfo.SetStateSnapshotNID(currentStateSnapshotNID)
|
||||
u.roomInfo.SetIsStub(false)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue