Commit Graph
1 Commits
  • fix(client): stop duplicate client entries accumulating in inbound settings
    Adding a user to multi-node inbounds could leave 3-6 identical entries
    in one inbound's settings.clients array: addInboundClient appended
    incoming clients unconditionally, and the duplicate-email precheck
    exempts a matching subId (so one identity can span several inbounds),
    so a retried or raced add of the same client re-appended it to an
    inbound that already carried it - on the master and, since nodes run
    the same code, on every node, whose snapshot adoption then copied the
    duplicates back verbatim. The normalized clients/client_inbounds tables
    stayed clean (unique constraints), which is why the phantom rows only
    showed in settings-driven views like the Detach clients modal, where
    duplicate React keys also broke the selection counter.
    
    Three layers: addInboundClient now skips incoming clients whose email
    is already on the target inbound (idempotent re-adds instead of
    duplication), node snapshot adoption collapses duplicate emails before
    writing the central row, and an idempotent startup repair rewrites any
    inbound whose settings still carry duplicates from older builds.
    
    Closes #5770