add persona attribute conversion logic

This commit is contained in:
Christian Grothoff 2023-01-27 22:47:42 +01:00
parent 0eb6f73176
commit 35d50ba36a
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC

View File

@ -868,12 +868,9 @@ proof_generic_reply (struct TALER_KYCLOGIC_ProofHandle *ph,
{ {
struct MHD_Response *resp; struct MHD_Response *resp;
enum GNUNET_GenericReturnValue ret; enum GNUNET_GenericReturnValue ret;
struct GNUNET_TIME_Absolute expiration;
if (TALER_KYCLOGIC_STATUS_SUCCESS == status) /* This API is not usable for successful replies */
expiration = GNUNET_TIME_relative_to_absolute (ph->pd->validity); GNUNET_assert (TALER_KYCLOGIC_STATUS_SUCCESS != status);
else
expiration = GNUNET_TIME_UNIT_ZERO_ABS;
ret = TALER_TEMPLATING_build (ph->connection, ret = TALER_TEMPLATING_build (ph->connection,
&http_status, &http_status,
template, template,
@ -891,8 +888,8 @@ proof_generic_reply (struct TALER_KYCLOGIC_ProofHandle *ph,
status, status,
account_id, account_id,
inquiry_id, inquiry_id,
expiration, GNUNET_TIME_UNIT_ZERO_ABS,
NULL, /* FIXME: return attributes! */ NULL,
http_status, http_status,
resp); resp);
} }
@ -1626,6 +1623,7 @@ persona_webhook_cancel (struct TALER_KYCLOGIC_WebhookHandle *wh)
* @param status status to return * @param status status to return
* @param account_id account to return * @param account_id account to return
* @param inquiry_id inquiry ID to supply * @param inquiry_id inquiry ID to supply
* @param attr KYC attribute data for the client
* @param http_status HTTP status to use * @param http_status HTTP status to use
*/ */
static void static void
@ -1633,11 +1631,11 @@ webhook_generic_reply (struct TALER_KYCLOGIC_WebhookHandle *wh,
enum TALER_KYCLOGIC_KycStatus status, enum TALER_KYCLOGIC_KycStatus status,
const char *account_id, const char *account_id,
const char *inquiry_id, const char *inquiry_id,
const json_t *attr,
unsigned int http_status) unsigned int http_status)
{ {
struct MHD_Response *resp; struct MHD_Response *resp;
struct GNUNET_TIME_Absolute expiration; struct GNUNET_TIME_Absolute expiration;
json_t *attr;
if (TALER_KYCLOGIC_STATUS_SUCCESS == status) if (TALER_KYCLOGIC_STATUS_SUCCESS == status)
expiration = GNUNET_TIME_relative_to_absolute (wh->pd->validity); expiration = GNUNET_TIME_relative_to_absolute (wh->pd->validity);
@ -1647,9 +1645,6 @@ webhook_generic_reply (struct TALER_KYCLOGIC_WebhookHandle *wh,
"", "",
MHD_RESPMEM_PERSISTENT); MHD_RESPMEM_PERSISTENT);
TALER_MHD_add_global_headers (resp); TALER_MHD_add_global_headers (resp);
attr = json_object ();
// FIXME: fetch attributes!
GNUNET_assert (NULL != attr);
wh->cb (wh->cb_cls, wh->cb (wh->cb_cls,
wh->process_row, wh->process_row,
&wh->h_payto, &wh->h_payto,
@ -1661,7 +1656,6 @@ webhook_generic_reply (struct TALER_KYCLOGIC_WebhookHandle *wh,
attr, attr,
http_status, http_status,
resp); resp);
json_decref (attr);
} }
@ -1681,13 +1675,14 @@ webhook_reply_error (struct TALER_KYCLOGIC_WebhookHandle *wh,
TALER_KYCLOGIC_STATUS_PROVIDER_FAILED, TALER_KYCLOGIC_STATUS_PROVIDER_FAILED,
NULL, /* user id */ NULL, /* user id */
inquiry_id, inquiry_id,
NULL, /* attributes */
http_status); http_status);
} }
/** /**
* Function called when we're done processing the * Function called when we're done processing the
* HTTP "/verifications/{verification_id}" request. * HTTP "/api/v1/inquiries/{inquiry_id}" request.
* *
* @param cls the `struct TALER_KYCLOGIC_WebhookHandle` * @param cls the `struct TALER_KYCLOGIC_WebhookHandle`
* @param response_code HTTP response code, 0 on error * @param response_code HTTP response code, 0 on error
@ -1702,6 +1697,8 @@ handle_webhook_finished (void *cls,
const json_t *j = response; const json_t *j = response;
const json_t *data = json_object_get (j, const json_t *data = json_object_get (j,
"data"); "data");
const json_t *included = json_object_get (j,
"included");
wh->job = NULL; wh->job = NULL;
switch (response_code) switch (response_code)
@ -1755,6 +1752,7 @@ handle_webhook_finished (void *cls,
NULL), NULL),
GNUNET_JSON_spec_end () GNUNET_JSON_spec_end ()
}; };
json_t *attr;
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_JSON_parse (attributes, GNUNET_JSON_parse (attributes,
@ -1822,6 +1820,7 @@ handle_webhook_finished (void *cls,
TALER_KYCLOGIC_STATUS_FAILED, TALER_KYCLOGIC_STATUS_FAILED,
account_id, account_id,
inquiry_id, inquiry_id,
NULL,
MHD_HTTP_OK); MHD_HTTP_OK);
GNUNET_JSON_parse_free (ispec); GNUNET_JSON_parse_free (ispec);
GNUNET_JSON_parse_free (spec); GNUNET_JSON_parse_free (spec);
@ -1840,11 +1839,14 @@ handle_webhook_finished (void *cls,
break; break;
} }
attr = extract_attributes (included);
webhook_generic_reply (wh, webhook_generic_reply (wh,
TALER_KYCLOGIC_STATUS_SUCCESS, TALER_KYCLOGIC_STATUS_SUCCESS,
account_id, account_id,
inquiry_id, inquiry_id,
attr,
MHD_HTTP_OK); MHD_HTTP_OK);
json_decref (attr);
GNUNET_JSON_parse_free (ispec); GNUNET_JSON_parse_free (ispec);
} }
GNUNET_JSON_parse_free (spec); GNUNET_JSON_parse_free (spec);