mirror of
https://github.com/mautrix/signal.git
synced 2025-03-14 14:15:36 +00:00
signalmeow/store: add logs for recipient updates
This commit is contained in:
parent
0ca656a5e1
commit
f07723070d
1 changed files with 13 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue