From 2e97daabc58a857a42ab6591b981e2a983a78266 Mon Sep 17 00:00:00 2001 From: Daniel Cadenas Date: Fri, 18 Oct 2024 09:54:31 -0300 Subject: [PATCH] Should ignore non-matching pubkeys --- service/adapters/sqlite/public_key_repository.go | 2 +- .../adapters/sqlite/public_key_repository_test.go | 14 ++++++++++++++ service/app/vanish_subscriber.go | 4 ++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/service/adapters/sqlite/public_key_repository.go b/service/adapters/sqlite/public_key_repository.go index 907ed59..7876938 100644 --- a/service/adapters/sqlite/public_key_repository.go +++ b/service/adapters/sqlite/public_key_repository.go @@ -58,7 +58,7 @@ func (m *PublicKeyRepository) DeleteByPublicKey(publicKey domain.PublicKey) erro err := row.Scan(&accountID) if err != nil { if errors.Is(err, sql.ErrNoRows) { - return errors.New("no account found with the provided public key") + return nil } return errors.Wrap(err, "error retrieving account_id") } diff --git a/service/adapters/sqlite/public_key_repository_test.go b/service/adapters/sqlite/public_key_repository_test.go index 1b1e83e..443ddf1 100644 --- a/service/adapters/sqlite/public_key_repository_test.go +++ b/service/adapters/sqlite/public_key_repository_test.go @@ -302,3 +302,17 @@ func TestPublicKeyRepository_DeleteByPublicKey(t *testing.T) { }) require.NoError(t, err) } + +func TestPublicKeyRepository_DeleteByPublicKey_NonExistent(t *testing.T) { + ctx := fixtures.TestContext(t) + adapters := NewTestAdapters(ctx, t) + + publicKey := fixtures.SomePublicKey() + + err := adapters.TransactionProvider.Transact(ctx, func(ctx context.Context, adapters sqlite.TestAdapters) error { + err := adapters.PublicKeyRepository.DeleteByPublicKey(publicKey) + require.NoError(t, err) + return nil + }) + require.NoError(t, err) +} diff --git a/service/app/vanish_subscriber.go b/service/app/vanish_subscriber.go index 08ef9fa..8d84e45 100644 --- a/service/app/vanish_subscriber.go +++ b/service/app/vanish_subscriber.go @@ -81,13 +81,13 @@ func (f *VanishSubscriber) Run(ctx context.Context) error { pubkey, err := domain.NewPublicKeyFromHex(entry.Values["pubkey"].(string)) if err != nil { - f.logger.Error().Message("Error parsing pubkey") + f.logger.Error().WithError(err).Message("Error parsing pubkey") break } err = f.removePubkeyInfo(ctx, pubkey) if err != nil { - f.logger.Error().WithField("streamId", streamID).Message("Failed to process entry") + f.logger.Error().WithError(err).WithField("streamId", streamID).Message("Failed to process entry") continue }