More input tweaks

This commit is contained in:
Neil Alexander 2022-08-03 12:45:24 +01:00
parent 175989e363
commit 8048c77526
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
4 changed files with 19 additions and 17 deletions

View file

@ -60,8 +60,9 @@ import (
// per-room durable consumers will only progress through the stream // per-room durable consumers will only progress through the stream
// as events are processed. // as events are processed.
// //
// A BC * -> positions of each consumer (* = ephemeral) // A BC * -> positions of each consumer (* = ephemeral)
// ⌄ ⌄⌄ ⌄ // ⌄ ⌄⌄ ⌄
//
// ABAABCAABCAA -> newest (letter = subject for each message) // ABAABCAABCAA -> newest (letter = subject for each message)
// //
// In this example, A is still processing an event but has two // In this example, A is still processing an event but has two

View file

@ -137,7 +137,7 @@ func (r *Inputer) processRoomEvent(
return fmt.Errorf("r.DB.RoomInfo: %w", rerr) return fmt.Errorf("r.DB.RoomInfo: %w", rerr)
} }
isCreateEvent := event.Type() == gomatrixserverlib.MRoomCreate && event.StateKeyEquals("") isCreateEvent := event.Type() == gomatrixserverlib.MRoomCreate && event.StateKeyEquals("")
if roomInfo == nil && !isCreateEvent { if !isCreateEvent && (roomInfo == nil || roomInfo.IsStub()) {
return fmt.Errorf("room %s does not exist for event %s", event.RoomID(), event.EventID()) return fmt.Errorf("room %s does not exist for event %s", event.RoomID(), event.EventID())
} }
@ -341,7 +341,7 @@ func (r *Inputer) processRoomEvent(
if err != nil { if err != nil {
return fmt.Errorf("updater.RoomInfo: %w", err) return fmt.Errorf("updater.RoomInfo: %w", err)
} }
if roomInfo == nil { if roomInfo == nil || (!isCreateEvent && roomInfo.IsStub()) {
return fmt.Errorf("updater.RoomInfo missing for room %s", event.RoomID()) return fmt.Errorf("updater.RoomInfo missing for room %s", event.RoomID())
} }

View file

@ -35,17 +35,17 @@ import (
// event to the output log. // event to the output log.
// The latest events are the events that aren't referenced by another event in the database: // The latest events are the events that aren't referenced by another event in the database:
// //
// Time goes down the page. 1 is the m.room.create event (root). // Time goes down the page. 1 is the m.room.create event (root).
// //
// 1 After storing 1 the latest events are {1} // 1 After storing 1 the latest events are {1}
// | After storing 2 the latest events are {2} // | After storing 2 the latest events are {2}
// 2 After storing 3 the latest events are {3} // 2 After storing 3 the latest events are {3}
// / \ After storing 4 the latest events are {3,4} // / \ After storing 4 the latest events are {3,4}
// 3 4 After storing 5 the latest events are {5,4} // 3 4 After storing 5 the latest events are {5,4}
// | | After storing 6 the latest events are {5,6} // | | After storing 6 the latest events are {5,6}
// 5 6 <--- latest After storing 7 the latest events are {6,7} // 5 6 <--- latest After storing 7 the latest events are {6,7}
// | // |
// 7 <----- latest // 7 <----- latest
// //
// Can only be called once at a time // Can only be called once at a time
func (r *Inputer) updateLatestEvents( func (r *Inputer) updateLatestEvents(

View file

@ -178,7 +178,7 @@ func (d *Database) roomInfo(ctx context.Context, txn *sql.Tx, roomID string) (*t
} }
// Otherwise, try to admit the data into the cache and return the // Otherwise, try to admit the data into the cache and return the
// new reference from the database. // new reference from the database.
if roomInfoFromDB != nil { if err == nil && roomInfoFromDB != nil {
d.Cache.StoreRoomInfo(roomID, roomInfoFromDB) d.Cache.StoreRoomInfo(roomID, roomInfoFromDB)
d.Cache.StoreRoomServerRoomID(roomInfoFromDB.RoomNID, roomID) d.Cache.StoreRoomServerRoomID(roomInfoFromDB.RoomNID, roomID)
} }
@ -840,8 +840,9 @@ func extractRoomVersionFromCreateEvent(event *gomatrixserverlib.Event) (
// "servers should not apply or send redactions to clients until both the redaction event and original event have been seen, and are valid." // "servers should not apply or send redactions to clients until both the redaction event and original event have been seen, and are valid."
// https://matrix.org/docs/spec/rooms/v3#authorization-rules-for-events // https://matrix.org/docs/spec/rooms/v3#authorization-rules-for-events
// These cases are: // These cases are:
// - This is a redaction event, redact the event it references if we know about it. // - This is a redaction event, redact the event it references if we know about it.
// - This is a normal event which may have been previously redacted. // - This is a normal event which may have been previously redacted.
//
// In the first case, check if we have the referenced event then apply the redaction, else store it // In the first case, check if we have the referenced event then apply the redaction, else store it
// in the redactions table with validated=FALSE. In the second case, check if there is a redaction for it: // in the redactions table with validated=FALSE. In the second case, check if there is a redaction for it:
// if there is then apply the redactions and set validated=TRUE. // if there is then apply the redactions and set validated=TRUE.