Tweak MissingAuthPrevEvents

This commit is contained in:
Neil Alexander 2022-02-23 14:54:23 +00:00
parent 52581e467a
commit 2c92171988
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -677,8 +677,12 @@ func (d *Database) GetPublishedRooms(ctx context.Context) ([]string, error) {
func (d *Database) MissingAuthPrevEvents( func (d *Database) MissingAuthPrevEvents(
ctx context.Context, e *gomatrixserverlib.Event, ctx context.Context, e *gomatrixserverlib.Event,
) (missingAuth, missingPrev []string, err error) { ) (missingAuth, missingPrev []string, err error) {
authEventNIDs, err := d.EventNIDs(ctx, e.AuthEventIDs())
if err != nil {
return nil, nil, fmt.Errorf("d.EventNIDs: %w", err)
}
for _, authEventID := range e.AuthEventIDs() { for _, authEventID := range e.AuthEventIDs() {
if nids, err := d.EventNIDs(ctx, []string{authEventID}); err != nil || len(nids) == 0 { if _, ok := authEventNIDs[authEventID]; !ok {
missingAuth = append(missingAuth, authEventID) missingAuth = append(missingAuth, authEventID)
} }
} }