From 748536ad26e295bfe8c9ed2a36cbc18257c1f80a Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Fri, 8 Nov 2024 20:22:06 +0100 Subject: finish other legi measures when inserting new one --- src/exchangedb/exchange_do_trigger_kyc_rule_for_account.sql | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/exchangedb/exchange_do_trigger_kyc_rule_for_account.sql b/src/exchangedb/exchange_do_trigger_kyc_rule_for_account.sql index 707b2c718..4d9fa79b0 100644 --- a/src/exchangedb/exchange_do_trigger_kyc_rule_for_account.sql +++ b/src/exchangedb/exchange_do_trigger_kyc_rule_for_account.sql @@ -90,6 +90,7 @@ THEN out_bad_kyc_auth = FALSE; END IF; END IF; + -- First check if a perfectly equivalent legi measure -- already exists, to avoid creating tons of duplicates. UPDATE legitimization_measures @@ -116,6 +117,13 @@ THEN legitimization_measure_serial_id INTO out_legitimization_measure_serial_id; + + -- mark all other active measures finished! + UPDATE legitimization_measures + SET is_finished=TRUE + WHERE access_token=my_access_token + AND NOT is_finished + AND legitimization_measure_serial_id != out_legitimization_measure_serial_id; END IF; EXECUTE FORMAT ( -- cgit v1.2.3