taler-merchant-httpd_private-delete-account-ID.c (3593B)
1 /* 2 This file is part of TALER 3 (C) 2023 Taler Systems SA 4 5 TALER is free software; you can redistribute it and/or modify it under the 6 terms of the GNU Affero General Public License as published by the Free Software 7 Foundation; either version 3, or (at your option) any later version. 8 9 TALER is distributed in the hope that it will be useful, but WITHOUT ANY 10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 13 You should have received a copy of the GNU General Public License along with 14 TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 */ 16 /** 17 * @file taler-merchant-httpd_private-delete-account-ID.c 18 * @brief implement DELETE /account/$H_WIRE 19 * @author Christian Grothoff 20 */ 21 #include "platform.h" 22 #include "taler-merchant-httpd_private-delete-account-ID.h" 23 #include <taler/taler_json_lib.h> 24 #include <taler/taler_dbevents.h> 25 26 27 MHD_RESULT 28 TMH_private_delete_account_ID (const struct TMH_RequestHandler *rh, 29 struct MHD_Connection *connection, 30 struct TMH_HandlerContext *hc) 31 { 32 struct TMH_MerchantInstance *mi = hc->instance; 33 struct TALER_MerchantWireHashP h_wire; 34 enum GNUNET_DB_QueryStatus qs; 35 36 (void) rh; 37 if (GNUNET_OK != 38 GNUNET_STRINGS_string_to_data (hc->infix, 39 strlen (hc->infix), 40 &h_wire, 41 sizeof (h_wire))) 42 { 43 GNUNET_break_op (0); 44 return TALER_MHD_reply_with_error (connection, 45 MHD_HTTP_BAD_REQUEST, 46 TALER_EC_GENERIC_PARAMETER_MALFORMED, 47 "h_wire"); 48 } 49 GNUNET_assert (NULL != mi); 50 qs = TMH_db->inactivate_account (TMH_db->cls, 51 mi->settings.id, 52 &h_wire); 53 switch (qs) 54 { 55 case GNUNET_DB_STATUS_HARD_ERROR: 56 return TALER_MHD_reply_with_error (connection, 57 MHD_HTTP_INTERNAL_SERVER_ERROR, 58 TALER_EC_GENERIC_DB_STORE_FAILED, 59 "inactivate_account"); 60 case GNUNET_DB_STATUS_SOFT_ERROR: 61 GNUNET_break (0); 62 return TALER_MHD_reply_with_error (connection, 63 MHD_HTTP_INTERNAL_SERVER_ERROR, 64 TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, 65 NULL); 66 case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: 67 return TALER_MHD_reply_with_error (connection, 68 MHD_HTTP_NOT_FOUND, 69 TALER_EC_MERCHANT_PRIVATE_ACCOUNT_DELETE_UNKNOWN_ACCOUNT, 70 "account unknown"); 71 case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: 72 break; 73 } 74 { 75 struct GNUNET_DB_EventHeaderP es = { 76 .size = htons (sizeof (es)), 77 .type = htons (TALER_DBEVENT_MERCHANT_ACCOUNTS_CHANGED) 78 }; 79 80 TMH_db->event_notify (TMH_db->cls, 81 &es, 82 NULL, 83 0); 84 } 85 TMH_reload_instances (mi->settings.id); 86 return TALER_MHD_reply_static (connection, 87 MHD_HTTP_NO_CONTENT, 88 NULL, 89 NULL, 90 0); 91 } 92 93 94 /* end of taler-merchant-httpd_private-delete-account-ID.c */