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

@ -62,6 +62,7 @@ import (
//
// A BC * -> positions of each consumer (* = ephemeral)
// ⌄ ⌄⌄ ⌄
//
// ABAABCAABCAA -> newest (letter = subject for each message)
//
// 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)
}
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())
}
@ -341,7 +341,7 @@ func (r *Inputer) processRoomEvent(
if err != nil {
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())
}

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
// new reference from the database.
if roomInfoFromDB != nil {
if err == nil && roomInfoFromDB != nil {
d.Cache.StoreRoomInfo(roomID, roomInfoFromDB)
d.Cache.StoreRoomServerRoomID(roomInfoFromDB.RoomNID, roomID)
}
@ -842,6 +842,7 @@ func extractRoomVersionFromCreateEvent(event *gomatrixserverlib.Event) (
// These cases are:
// - 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.
//
// 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:
// if there is then apply the redactions and set validated=TRUE.