commit 47243224aad04017464e5d77c1631b8354e13132
parent 68abf5e4d91928b2064b443ac0923eb4f61a600a
Author: Christian Grothoff <christian@grothoff.org>
Date: Wed, 23 Apr 2025 20:36:41 +0200
preserve custom measures when injecting new custom measure for address validation, fix capitzliation of attributes
Diffstat:
2 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/src/kyclogic/taler-exchange-helper-measure-tops-address-check b/src/kyclogic/taler-exchange-helper-measure-tops-address-check
@@ -65,7 +65,7 @@ do
exit 0
;;
v)
- echo "$0 v0.0.1"
+ echo "$0 v0.0.2"
exit 0
;;
V)
@@ -120,7 +120,7 @@ ADDRESS=$(jq -n \
--argjson contact_name \""$CONTACT_NAME"\" \
--argjson address_lines "$ADDRESS_LINES" \
--argjson address_country "$ADDRESS_COUNTRY" \
- '{"contact_name":$contact_name,"address_lines":$address_lines,"address_country":$address_country,"read_only":true}')
+ '{"CONTACT_NAME":$contact_name,"ADDRESS_LINES":$address_lines,"ADDRESS_COUNTRY":$address_country,"read_only":true}')
# Get current rules.
CURRENT_RULES=$(echo "$INPUTS" | jq '.current_rules // null')
@@ -128,9 +128,10 @@ CURRENT_RULES=$(echo "$INPUTS" | jq '.current_rules // null')
EXPIRATION_TIME=$(echo "$INPUTS" | jq '.context.expiration_time // .current_rules.expiration_time // null')
# Preserve successor measure.
SUCCESSOR_MEASURE=$(echo "$INPUTS" | jq '.current_rules.successor_measure // null')
+CUSTOM_MEASURES=$(echo "$INPUTS" | jq '.context.custom_measures // null')
# Define custom measure for address validation
-CUSTOM_MEASURES=$(jq -n \
+CUSTOM_AMEASURES=$(jq -n \
--argjson address "$ADDRESS" \
'{"custom-address-investigation":{"context":{"initial_address":$address},"check_name":"postal-registration","prog_name":"inform-investigate","operation_type":"DEPOSIT"}}')
@@ -148,8 +149,9 @@ jq -n \
--argjson et "$EXPIRATION_TIME" \
--argjson sm "$SUCCESSOR_MEASURE" \
--argjson nm '"custom-address-investigation"' \
- --argjson cm "$CUSTOM_MEASURES" \
+ --argjson cm "$CUSTOM_AMEASURES" \
+ --argjson cma "$CUSTOM_AMEASURES" \
--argjson nr "$NEW_RULES" \
- '{"new_measures":$nm,"new_rules":($nr+{"expiration_time":$et,"successor_measure":$sm,"custom_measures":({}+$nr.custom_measures+$cm)})}|del(..|nulls)'
+ '{"new_measures":$nm,"new_rules":($nr+{"expiration_time":$et,"successor_measure":$sm,"custom_measures":({}+$nr.custom_measures+$cm+$cma)})}|del(..|nulls)'
exit 0
diff --git a/src/kyclogic/taler-exchange-helper-measure-tops-sms-check b/src/kyclogic/taler-exchange-helper-measure-tops-sms-check
@@ -64,7 +64,7 @@ do
exit 0
;;
v)
- echo "$0 v0.0.1"
+ echo "$0 v0.0.2"
exit 0
;;
V)
@@ -114,6 +114,17 @@ else
TO_INVESTIGATE="true"
fi
+# Convert phone data to Challenger format as best we can.
+ADDRESS=$(jq -n \
+ --argjson phone_number \""$PHONE_NUMBER"\" \
+ '{"CONTACT_PHONE":$phone_number,"read_only":true}')
+
+
+# Define custom measure for address validation
+CUSTOM_PMEASURES=$(jq -n \
+ --argjson address "$ADDRESS" \
+ '{"custom-phone-investigation":{"context":{"initial_address":$address},"check_name":"sms-registration","prog_name":"inform-investigate","operation_type":"MERGE"}}')
+
# Finally, output the new rules.
# See https://docs.taler.net/taler-kyc-manual.html#tsref-type-AmlOutcome
@@ -123,6 +134,8 @@ exec jq -n \
--argjson et "$EXPIRATION_TIME" \
--argjson sm "$SUCCESSOR_MEASURE" \
--argjson cm "$CUSTOM_MEASURES" \
+ --argjson nm '"custom-address-investigation"' \
+ --argjson cmp "$CUSTOM_PMEASURES" \
--argjson nr "$NEW_RULES" \
--argjson inv "$TO_INVESTIGATE" \
- '{"new_rules":($nr+{"expiration_time":$et,"successor_measure":$sm,"custom_measures":({}+$nr.custom_measures+$cm)}),"to_investigate":$inv}|del(..|nulls)'
+ '{"new_measures":$nm,"new_rules":($nr+{"expiration_time":$et,"successor_measure":$sm,"custom_measures":({}+$nr.custom_measures+$cm+$cmp)}),"to_investigate":$inv}|del(..|nulls)'