nxtgauge-backend-rust/apps/companies
Ashwin Kumar Sivakumar 617a75971f fix(companies): contact-unlock double-spend and job-quota race
view_contact previously decremented free_contact_views/
purchased_contact_views on every call with no record of which
applications had already had their contact unlocked -- refreshing the
same application's contact panel silently re-spent the allowance every
time, not just under concurrency, and the check-then-act shape also let
concurrent requests both pass the exhausted-quota check before either
UPDATE committed. Now the whole claim (dedup check + conditional
decrement + job_applications.contact_unlocked_at write) runs in one
transaction with company_profiles locked FOR UPDATE, gated on a
WHERE ... > 0 guard on the decrement itself.

create_job had the same shape for the 1-free-job/month rule and
purchased_job_slots: two concurrent requests could both observe
"quota available" before either committed, letting a company publish
2+ free jobs in a month or drive purchased_job_slots negative. Same
fix: lock company_profiles FOR UPDATE for the whole check+mutate+
insert sequence.

Also adds CHECK (>= 0) constraints on all four company_profiles
counters as defense-in-depth, matching the pattern tracecoin_wallets
already uses for balance/reserved.
2026-08-18 00:51:02 +05:30
..
src fix(companies): contact-unlock double-spend and job-quota race 2026-08-18 00:51:02 +05:30
Cargo.toml fix(companies): restore backend build 2026-06-14 06:08:00 +05:30
Dockerfile fix: Update Dockerfiles to use ci.nxtgauge.com registry 2026-07-08 03:37:18 +05:30