aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb/exchange_do_insert_kyc_attributes.sql
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-08-04 17:07:04 +0200
committerChristian Grothoff <christian@grothoff.org>2024-08-04 17:07:04 +0200
commit7d5e5978add17a6ba280d1e9998f1ee9f2cd4ede (patch)
tree56828a40ccf85bf819708ff9b7d30b1ed798e948 /src/exchangedb/exchange_do_insert_kyc_attributes.sql
parentba29af74ce7f39185316be05541596bce4bb73d3 (diff)
fix misc bugs
Diffstat (limited to 'src/exchangedb/exchange_do_insert_kyc_attributes.sql')
-rw-r--r--src/exchangedb/exchange_do_insert_kyc_attributes.sql14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/exchangedb/exchange_do_insert_kyc_attributes.sql b/src/exchangedb/exchange_do_insert_kyc_attributes.sql
index 12f76c17d..0c907f279 100644
--- a/src/exchangedb/exchange_do_insert_kyc_attributes.sql
+++ b/src/exchangedb/exchange_do_insert_kyc_attributes.sql
@@ -41,6 +41,14 @@ DECLARE
ini_event TEXT;
BEGIN
+
+UPDATE legitimization_outcomes
+ SET is_active=FALSE
+ WHERE h_payto=in_h_payto
+ -- this clause is a minor optimization to avoid
+ -- updating outcomes that have long expired.
+ AND expiration_time >= in_collection_time_ts;
+
INSERT INTO legitimization_outcomes
(h_payto
,decision_time
@@ -107,7 +115,6 @@ UPDATE reserves
((current_balance).val > 0 ) )
AND (expiration_date > in_collection_time_ts);
-
IF in_to_investigate
THEN
INSERT INTO aml_status
@@ -135,13 +142,12 @@ EXECUTE FORMAT (
'NOTIFY %s'
,in_kyc_completed_notify_s);
-
INSERT INTO kyc_alerts
(h_payto
,trigger_type)
VALUES
- (in_h_payto,1);
-
+ (in_h_payto,1)
+ ON CONFLICT DO NOTHING;
END $$;