Line data Source code
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 1 : TMH_private_delete_account_ID (const struct TMH_RequestHandler *rh, 29 : struct MHD_Connection *connection, 30 : struct TMH_HandlerContext *hc) 31 : { 32 1 : struct TMH_MerchantInstance *mi = hc->instance; 33 : struct TALER_MerchantWireHashP h_wire; 34 : enum GNUNET_DB_QueryStatus qs; 35 : 36 : (void) rh; 37 1 : if (GNUNET_OK != 38 1 : GNUNET_STRINGS_string_to_data (hc->infix, 39 1 : strlen (hc->infix), 40 : &h_wire, 41 : sizeof (h_wire))) 42 : { 43 0 : GNUNET_break_op (0); 44 0 : return TALER_MHD_reply_with_error (connection, 45 : MHD_HTTP_BAD_REQUEST, 46 : TALER_EC_GENERIC_PARAMETER_MALFORMED, 47 : "h_wire"); 48 : } 49 1 : GNUNET_assert (NULL != mi); 50 1 : qs = TMH_db->inactivate_account (TMH_db->cls, 51 1 : mi->settings.id, 52 : &h_wire); 53 1 : switch (qs) 54 : { 55 0 : case GNUNET_DB_STATUS_HARD_ERROR: 56 0 : return TALER_MHD_reply_with_error (connection, 57 : MHD_HTTP_INTERNAL_SERVER_ERROR, 58 : TALER_EC_GENERIC_DB_STORE_FAILED, 59 : "inactivate_account"); 60 0 : case GNUNET_DB_STATUS_SOFT_ERROR: 61 0 : GNUNET_break (0); 62 0 : return TALER_MHD_reply_with_error (connection, 63 : MHD_HTTP_INTERNAL_SERVER_ERROR, 64 : TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, 65 : NULL); 66 0 : case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: 67 0 : 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 1 : case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: 72 1 : break; 73 : } 74 : { 75 1 : struct GNUNET_DB_EventHeaderP es = { 76 1 : .size = htons (sizeof (es)), 77 1 : .type = htons (TALER_DBEVENT_MERCHANT_ACCOUNTS_CHANGED) 78 : }; 79 : 80 1 : TMH_db->event_notify (TMH_db->cls, 81 : &es, 82 : NULL, 83 : 0); 84 : } 85 1 : TMH_reload_instances (mi->settings.id); 86 1 : 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 */