From f07723070d8ae4d07347cc4b989f78f9def082a6 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 30 Jan 2025 18:11:06 +0200 Subject: [PATCH] signalmeow/store: add logs for recipient updates --- pkg/signalmeow/store/recipient_store.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/signalmeow/store/recipient_store.go b/pkg/signalmeow/store/recipient_store.go index bdcd0c0a..84f9af9f 100644 --- a/pkg/signalmeow/store/recipient_store.go +++ b/pkg/signalmeow/store/recipient_store.go @@ -25,6 +25,7 @@ import ( "time" "github.com/google/uuid" + "github.com/rs/zerolog" "go.mau.fi/util/dbutil" "go.mau.fi/mautrix-signal/pkg/libsignalgo" @@ -166,6 +167,10 @@ func (s *sqlStore) mergeRecipients(ctx context.Context, first, second *types.Rec first, second = second, first } first.PNI = second.PNI + zerolog.Ctx(ctx).Debug(). + Stringer("aci", first.ACI). + Stringer("pni", first.PNI). + Msg("Merging recipient entries in database") if second.E164 != "" { first.E164 = second.E164 } @@ -247,6 +252,10 @@ func (s *sqlStore) LoadAndUpdateRecipient(ctx context.Context, aci, pni uuid.UUI // SQL only supports one ON CONFLICT clause, which means StoreRecipient will key on the ACI if it's present. // If we're adding an ACI to a PNI row, just delete the PNI row first to avoid conflicts on the PNI key. if outRecipient.PNI != uuid.Nil && outRecipient.ACI == uuid.Nil && aci != uuid.Nil { + zerolog.Ctx(ctx).Debug(). + Stringer("aci", outRecipient.ACI). + Stringer("pni", outRecipient.PNI). + Msg("Deleting old PNI-only row before inserting row with both IDs") err = s.DeleteRecipientByPNI(ctx, outRecipient.PNI) if err != nil { return fmt.Errorf("failed to delete old PNI row: %w", err) @@ -261,6 +270,10 @@ func (s *sqlStore) LoadAndUpdateRecipient(ctx context.Context, aci, pni uuid.UUI changed = true } if changed || len(entries) == 0 { + zerolog.Ctx(ctx).Trace(). + Stringer("aci", outRecipient.ACI). + Stringer("pni", outRecipient.PNI). + Msg("Saving recipient row") err = s.StoreRecipient(ctx, outRecipient) if err != nil { return fmt.Errorf("failed to store updated recipient row: %w", err)