diff options
Diffstat (limited to 'src/backend/taler-merchant-httpd_private-post-instances.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_private-post-instances.c | 149 |
1 files changed, 1 insertions, 148 deletions
diff --git a/src/backend/taler-merchant-httpd_private-post-instances.c b/src/backend/taler-merchant-httpd_private-post-instances.c index 6c9727e9..398a846d 100644 --- a/src/backend/taler-merchant-httpd_private-post-instances.c +++ b/src/backend/taler-merchant-httpd_private-post-instances.c @@ -37,56 +37,6 @@ /** - * Check if the array of @a payto_uris contains exactly the same - * URIs as those already in @a mi (possibly in a different order). - * - * @param mi a merchant instance with accounts - * @param accounts a JSON array with accounts (presumably) - * @return true if they are 'equal', false if not or of payto_uris is not an array - */ -static bool -accounts_equal (const struct TMH_MerchantInstance *mi, - const json_t *accounts) -{ - if (! json_is_array (accounts)) - return false; - { - unsigned int len = json_array_size (accounts); - enum GNUNET_GenericReturnValue matches[GNUNET_NZL (len)]; - - for (unsigned int i = 0; i<len; i++) - matches[i] = GNUNET_SYSERR; - for (struct TMH_WireMethod *wm = mi->wm_head; - NULL != wm; - wm = wm->next) - { - for (unsigned int i = 0; i<len; i++) - { - json_t *account = json_array_get (accounts, - i); - enum GNUNET_GenericReturnValue ret; - - ret = TMH_cmp_wire_account (account, - wm); - if (GNUNET_SYSERR == ret) - continue; - if (GNUNET_SYSERR != matches[i]) - { - GNUNET_break (0); - return false; /* duplicate entry!? */ - } - matches[i] = ret; - } - } - for (unsigned int i = 0; i<len; i++) - if (GNUNET_YES != matches[i]) - return false; - } - return true; -} - - -/** * Generate an instance, given its configuration. * * @param rh context of the handler @@ -101,15 +51,12 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh, { struct TALER_MERCHANTDB_InstanceSettings is; struct TALER_MERCHANTDB_InstanceAuthSettings ias; - const json_t *accounts; const char *auth_token = NULL; const char *uts = "business"; struct TMH_WireMethod *wm_head = NULL; struct TMH_WireMethod *wm_tail = NULL; const json_t *jauth; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_array_const ("accounts", - &accounts), GNUNET_JSON_spec_string ("id", (const char **) &is.id), GNUNET_JSON_spec_string ("name", @@ -179,16 +126,6 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh, return (GNUNET_NO == ret) ? MHD_YES : MHD_NO; } - /* check accounts for well-formedness */ - if (! TMH_accounts_array_valid (accounts)) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_GENERIC_PAYTO_URI_MALFORMED, - NULL); - } - /* check 'id' well-formed */ { static bool once; @@ -292,9 +229,7 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh, is.default_wire_transfer_delay)) && (GNUNET_TIME_relative_cmp (mi->settings.default_pay_delay, ==, - is.default_pay_delay)) && - (accounts_equal (mi, - accounts)) ) + is.default_pay_delay)) ) { return TALER_MHD_reply_static (connection, MHD_HTTP_NO_CONTENT, @@ -312,50 +247,6 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh, } } - /* convert provided payto URIs into internal data structure with salts */ - { - unsigned int len = json_array_size (accounts); - - for (unsigned int i = 0; i<len; i++) - { - json_t *account = json_array_get (accounts, - i); - const char *credit_facade_url = NULL; - const json_t *credit_facade_credentials = NULL; - const char *uri; - struct TMH_WireMethod *wm; - struct GNUNET_JSON_Specification ispec[] = { - GNUNET_JSON_spec_string ("payto_uri", - &uri), - GNUNET_JSON_spec_mark_optional ( - GNUNET_JSON_spec_string ("credit_facade_url", - &credit_facade_url), - NULL), - GNUNET_JSON_spec_mark_optional ( - GNUNET_JSON_spec_object_const ("credit_facade_credentials", - &credit_facade_credentials), - NULL), - GNUNET_JSON_spec_end () - }; - enum GNUNET_GenericReturnValue res; - - res = TALER_MHD_parse_json_data (connection, - account, - ispec); - if (GNUNET_OK != res) - return (GNUNET_NO == res) - ? MHD_YES - : MHD_NO; - wm = TMH_setup_wire_account (uri, - credit_facade_url, - credit_facade_credentials); - GNUNET_assert (NULL != wm); - GNUNET_CONTAINER_DLL_insert (wm_head, - wm_tail, - wm); - } - } - /* handle authentication token setup */ if (NULL == auth_token) { @@ -431,44 +322,6 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh, TMH_instance_decref (mi); return ret; } - for (struct TMH_WireMethod *wm = wm_head; - NULL != wm; - wm = wm->next) - { - struct TALER_MERCHANTDB_AccountDetails ad = { - .payto_uri = wm->payto_uri, - .salt = wm->wire_salt, - .h_wire = wm->h_wire, - .credit_facade_url = wm->credit_facade_url, - .credit_facade_credentials = wm->credit_facade_credentials, - .active = wm->active - }; - - qs = TMH_db->insert_account (TMH_db->cls, - mi->settings.id, - &ad); - if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) - break; - } - if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) - { - GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); - TMH_db->rollback (TMH_db->cls); - if (GNUNET_DB_STATUS_HARD_ERROR == qs) - break; - goto retry; - } - { - struct GNUNET_DB_EventHeaderP es = { - .size = htons (sizeof (es)), - .type = htons (TALER_DBEVENT_MERCHANT_ACCOUNTS_CHANGED) - }; - - TMH_db->event_notify (TMH_db->cls, - &es, - NULL, - 0); - } qs = TMH_db->commit (TMH_db->cls); if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; |