Skip to content

Commit f077230

Browse files
committed
signalmeow/store: add logs for recipient updates
1 parent 0ca656a commit f077230

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pkg/signalmeow/store/recipient_store.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"time"
2626

2727
"github.com/google/uuid"
28+
"github.com/rs/zerolog"
2829
"go.mau.fi/util/dbutil"
2930

3031
"go.mau.fi/mautrix-signal/pkg/libsignalgo"
@@ -166,6 +167,10 @@ func (s *sqlStore) mergeRecipients(ctx context.Context, first, second *types.Rec
166167
first, second = second, first
167168
}
168169
first.PNI = second.PNI
170+
zerolog.Ctx(ctx).Debug().
171+
Stringer("aci", first.ACI).
172+
Stringer("pni", first.PNI).
173+
Msg("Merging recipient entries in database")
169174
if second.E164 != "" {
170175
first.E164 = second.E164
171176
}
@@ -247,6 +252,10 @@ func (s *sqlStore) LoadAndUpdateRecipient(ctx context.Context, aci, pni uuid.UUI
247252
// SQL only supports one ON CONFLICT clause, which means StoreRecipient will key on the ACI if it's present.
248253
// If we're adding an ACI to a PNI row, just delete the PNI row first to avoid conflicts on the PNI key.
249254
if outRecipient.PNI != uuid.Nil && outRecipient.ACI == uuid.Nil && aci != uuid.Nil {
255+
zerolog.Ctx(ctx).Debug().
256+
Stringer("aci", outRecipient.ACI).
257+
Stringer("pni", outRecipient.PNI).
258+
Msg("Deleting old PNI-only row before inserting row with both IDs")
250259
err = s.DeleteRecipientByPNI(ctx, outRecipient.PNI)
251260
if err != nil {
252261
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
261270
changed = true
262271
}
263272
if changed || len(entries) == 0 {
273+
zerolog.Ctx(ctx).Trace().
274+
Stringer("aci", outRecipient.ACI).
275+
Stringer("pni", outRecipient.PNI).
276+
Msg("Saving recipient row")
264277
err = s.StoreRecipient(ctx, outRecipient)
265278
if err != nil {
266279
return fmt.Errorf("failed to store updated recipient row: %w", err)

0 commit comments

Comments
 (0)