mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-27 07:28:27 +00:00
Check missing state if not an outlier before storing the event
This commit is contained in:
parent
110ab7b8f3
commit
eff348bb69
1 changed files with 25 additions and 24 deletions
|
@ -82,6 +82,11 @@ func (r *Inputer) processRoomEvent(
|
|||
"room_id": event.RoomID(),
|
||||
"type": event.Type(),
|
||||
})
|
||||
|
||||
if input.Origin == "" {
|
||||
input.Origin = event.Origin()
|
||||
}
|
||||
|
||||
logger.Println("XXX: Processing event")
|
||||
|
||||
// if we have already got this event then do not process it again, if the input kind is an outlier.
|
||||
|
@ -166,6 +171,26 @@ func (r *Inputer) processRoomEvent(
|
|||
}
|
||||
}
|
||||
|
||||
if input.Kind != api.KindOutlier && len(missingRes.MissingPrevEventIDs) > 0 {
|
||||
missingState := missingStateReq{
|
||||
origin: input.Origin,
|
||||
inputer: r,
|
||||
queryer: r.Queryer,
|
||||
db: r.DB,
|
||||
federation: r.FSAPI,
|
||||
keys: r.KeyRing,
|
||||
roomsMu: internal.NewMutexByRoom(),
|
||||
servers: []gomatrixserverlib.ServerName{input.Origin},
|
||||
hadEvents: map[string]bool{},
|
||||
haveEvents: map[string]*gomatrixserverlib.HeaderedEvent{},
|
||||
}
|
||||
if err = missingState.processEventWithMissingState(ctx, input.Event.Unwrap(), input.Event.RoomVersion); err != nil {
|
||||
//return fmt.Errorf("r.checkForMissingPrevEvents: %w", err)
|
||||
softfail = true
|
||||
rejectionErr = fmt.Errorf("missingState.processEventWithMissingState: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Store the event.
|
||||
_, _, stateAtEvent, redactionEvent, redactedEventID, err := r.DB.StoreEvent(ctx, event, authEventNIDs, isRejected)
|
||||
if err != nil {
|
||||
|
@ -197,30 +222,6 @@ func (r *Inputer) processRoomEvent(
|
|||
return fmt.Errorf("r.DB.RoomInfo missing for room %s", event.RoomID())
|
||||
}
|
||||
|
||||
if input.Origin == "" {
|
||||
input.Origin = event.Origin()
|
||||
}
|
||||
|
||||
if len(missingRes.MissingPrevEventIDs) > 0 {
|
||||
missingState := missingStateReq{
|
||||
origin: input.Origin,
|
||||
inputer: r,
|
||||
queryer: r.Queryer,
|
||||
db: r.DB,
|
||||
federation: r.FSAPI,
|
||||
keys: r.KeyRing,
|
||||
roomsMu: internal.NewMutexByRoom(),
|
||||
servers: []gomatrixserverlib.ServerName{input.Origin},
|
||||
hadEvents: map[string]bool{},
|
||||
haveEvents: map[string]*gomatrixserverlib.HeaderedEvent{},
|
||||
}
|
||||
if err = missingState.processEventWithMissingState(ctx, input.Event.Unwrap(), roomInfo.RoomVersion); err != nil {
|
||||
// return fmt.Errorf("r.checkForMissingPrevEvents: %w", err)
|
||||
softfail = true
|
||||
rejectionErr = fmt.Errorf("event %s has missing state %+v due to error: %s", input.Event.EventID(), missingRes.MissingPrevEventIDs, err)
|
||||
}
|
||||
}
|
||||
|
||||
if stateAtEvent.BeforeStateSnapshotNID == 0 {
|
||||
// We haven't calculated a state for this event yet.
|
||||
// Lets calculate one.
|
||||
|
|
Loading…
Reference in a new issue