fix(clients): use client_inbounds link to resolve inbound, not stale id

client_traffics.inbound_id is a legacy single-inbound pointer that goes stale when an inbound is deleted and recreated: the email-keyed traffic row survives but references a missing inbound. Code that resolved the owning inbound from it broke several client operations.

- adjustTraffics: 'Start After First Use' (negative expiry) never converted to an absolute deadline on first traffic, so the countdown never started. Now resolves inbounds via the client_inbounds link and computes the new expiry once per email so multi-inbound clients stay consistent.

- GetClientInboundByEmail / GetClientInboundByTrafficID: fall back to client_inbounds when the pointer is dead, fixing reset traffic ('record not found'), client info, and Telegram set-tgId.

- autoRenewClients: resolve renew targets via client_inbounds so scheduled renews are not silently skipped.

- clients page: allow resetting a client with no inbound attachment (the backend already zeroes counters by email).

Add regression test for the delayed-start conversion under a stale inbound_id.
This commit is contained in:
MHSanaei
2026-06-03 13:41:44 +02:00
parent dc57c1e92c
commit df7ccd3a64
3 changed files with 214 additions and 69 deletions
+1 -1
View File
@@ -445,7 +445,7 @@ export default function ClientsPage() {
}
function onResetTraffic(row: ClientRecord) {
if (!row?.email || !Array.isArray(row.inboundIds) || row.inboundIds.length === 0) {
if (!row?.email) {
messageApi.warning(t('pages.clients.resetNotPossible'));
return;
}