LCOV - code coverage report
Current view: top level - backend - taler-merchant-httpd_delete-private-accounts-H_WIRE.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 66.7 % 30 20
Test Date: 2026-09-04 23:42:01 Functions: 100.0 % 1 1

            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 src/backend/taler-merchant-httpd_delete-private-accounts-H_WIRE.c
      18              :  * @brief implement DELETE /account/$H_WIRE
      19              :  * @author Christian Grothoff
      20              :  */
      21              : #include "platform.h"
      22              : #include "taler-merchant-httpd_delete-private-accounts-H_WIRE.h"
      23              : #include <taler/taler_json_lib.h>
      24              : #include <taler/taler_dbevents.h>
      25              : #include "taler-merchant-httpd_mfa.h"
      26              : #include "merchant-database/update_to_account_inactive.h"
      27              : #include "merchant-database/event_notify.h"
      28              : 
      29              : 
      30              : enum MHD_Result
      31            1 : TMH_private_delete_account_ID (const struct TMH_RequestHandler *rh,
      32              :                                struct MHD_Connection *connection,
      33              :                                struct TMH_HandlerContext *hc)
      34              : {
      35            1 :   struct TMH_MerchantInstance *mi = hc->instance;
      36              :   struct TALER_MerchantWireHashP h_wire;
      37              :   enum GNUNET_DB_QueryStatus qs;
      38              : 
      39              :   (void) rh;
      40            1 :   if (GNUNET_OK !=
      41            1 :       GNUNET_STRINGS_string_to_data (hc->infix,
      42            1 :                                      strlen (hc->infix),
      43              :                                      &h_wire,
      44              :                                      sizeof (h_wire)))
      45              :   {
      46            0 :     GNUNET_break_op (0);
      47            0 :     return TALER_MHD_reply_with_error (connection,
      48              :                                        MHD_HTTP_BAD_REQUEST,
      49              :                                        TALER_EC_GENERIC_PARAMETER_MALFORMED,
      50              :                                        "h_wire");
      51              :   }
      52            1 :   GNUNET_assert (NULL != mi);
      53              :   {
      54              :     /* MFA needed: deleting a bank account changes the
      55              :        account configuration of the instance. */
      56              :     enum GNUNET_GenericReturnValue ret;
      57              : 
      58            1 :     ret = TMH_mfa_check_simple (
      59              :       hc,
      60              :       TALER_MERCHANT_MFA_CO_ACCOUNT_CONFIGURATION,
      61              :       mi);
      62            1 :     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
      63              :                 "Account deletion MFA check returned %d\n",
      64              :                 (int) ret);
      65            1 :     if (GNUNET_OK != ret)
      66              :     {
      67              :       return (GNUNET_NO == ret)
      68              :         ? MHD_YES
      69            0 :         : MHD_NO;
      70              :     }
      71              :   }
      72            1 :   qs = TALER_MERCHANTDB_update_to_account_inactive (TMH_db,
      73            1 :                                                     mi->settings.id,
      74              :                                                     &h_wire);
      75            1 :   switch (qs)
      76              :   {
      77            0 :   case GNUNET_DB_STATUS_HARD_ERROR:
      78            0 :     return TALER_MHD_reply_with_error (connection,
      79              :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
      80              :                                        TALER_EC_GENERIC_DB_STORE_FAILED,
      81              :                                        "update_to_account_inactive");
      82            0 :   case GNUNET_DB_STATUS_SOFT_ERROR:
      83            0 :     GNUNET_break (0);
      84            0 :     return TALER_MHD_reply_with_error (connection,
      85              :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
      86              :                                        TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
      87              :                                        NULL);
      88            0 :   case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
      89            0 :     return TALER_MHD_reply_with_error (connection,
      90              :                                        MHD_HTTP_NOT_FOUND,
      91              :                                        TALER_EC_MERCHANT_PRIVATE_ACCOUNT_DELETE_UNKNOWN_ACCOUNT,
      92              :                                        "account unknown");
      93            1 :   case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
      94            1 :     break;
      95              :   }
      96              :   {
      97            1 :     struct GNUNET_DB_EventHeaderP es = {
      98            1 :       .size = htons (sizeof (es)),
      99            1 :       .type = htons (TALER_DBEVENT_MERCHANT_ACCOUNTS_CHANGED)
     100              :     };
     101              : 
     102            1 :     TALER_MERCHANTDB_event_notify (TMH_db,
     103              :                                    &es,
     104              :                                    NULL,
     105              :                                    0);
     106              :   }
     107            1 :   TMH_reload_instances (mi->settings.id);
     108            1 :   return TALER_MHD_reply_static (connection,
     109              :                                  MHD_HTTP_NO_CONTENT,
     110              :                                  NULL,
     111              :                                  NULL,
     112              :                                  0);
     113              : }
     114              : 
     115              : 
     116              : /* end of taler-merchant-httpd_delete-private-accounts-H_WIRE.c */
        

Generated by: LCOV version 2.0-1