From 2c9217198867a5db27f7c20396026465c4ef14d3 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 23 Feb 2022 14:54:23 +0000 Subject: [PATCH] Tweak `MissingAuthPrevEvents` --- roomserver/storage/shared/storage.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/roomserver/storage/shared/storage.go b/roomserver/storage/shared/storage.go index b300823c9..6e84b2832 100644 --- a/roomserver/storage/shared/storage.go +++ b/roomserver/storage/shared/storage.go @@ -677,8 +677,12 @@ func (d *Database) GetPublishedRooms(ctx context.Context) ([]string, error) { func (d *Database) MissingAuthPrevEvents( ctx context.Context, e *gomatrixserverlib.Event, ) (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() { - if nids, err := d.EventNIDs(ctx, []string{authEventID}); err != nil || len(nids) == 0 { + if _, ok := authEventNIDs[authEventID]; !ok { missingAuth = append(missingAuth, authEventID) } }