Commit 5eb80ec
committed
fix(clients): avoid duplicate ClientRecord when email is changed on edit
SyncInbound (invoked from UpdateInboundClient during a client edit)
looks up the ClientRecord row by the email present in the inbound's
settings. After an email change the lookup misses the original row,
hits the gorm.ErrRecordNotFound branch, and inserts a fresh
ClientRecord with the new email. The original row stays in place with
its inbound link cleared, so the clients list shows both — the
original as an orphan and the new one as if it had just been created.
Rename the existing ClientRecord row to the new email up front, before
the inbound loop runs. SyncInbound then finds and updates the same
row instead of creating a duplicate. A pre-check rejects renames that
would collide with another client's email so the unique index keeps
its meaning.1 parent 313d041 commit 5eb80ec
1 file changed
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
595 | 595 | | |
596 | 596 | | |
597 | 597 | | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
598 | 619 | | |
599 | 620 | | |
600 | 621 | | |
| |||
0 commit comments