LCOV - code coverage report
Current view: top level - auditor - taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-get.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 30 0
Test Date: 2025-12-28 14:06:02 Functions: 0.0 % 2 0

            Line data    Source code
       1              : /*
       2              :    This file is part of TALER
       3              :    Copyright (C) 2024 Taler Systems SA
       4              : 
       5              :    TALER is free software; you can redistribute it and/or modify it under the
       6              :    terms of the GNU 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              : #include "taler/platform.h"
      17              : #include <gnunet/gnunet_util_lib.h>
      18              : #include <gnunet/gnunet_json_lib.h>
      19              : #include <jansson.h>
      20              : #include <microhttpd.h>
      21              : #include <pthread.h>
      22              : #include "taler/taler_json_lib.h"
      23              : #include "taler/taler_mhd_lib.h"
      24              : #include "taler-auditor-httpd.h"
      25              : #include "taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-get.h"
      26              : 
      27              : 
      28              : /**
      29              :  * Add reserve-balance-summary-wrong-inconsistency to the list.
      30              :  *
      31              :  * @param[in,out] cls a `json_t *` array to extend
      32              :  * @param dc struct of inconsistencies
      33              :  * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
      34              :  */
      35              : static enum GNUNET_GenericReturnValue
      36            0 : process_reserve_balance_summary_wrong_inconsistency (
      37              :   void *cls,
      38              :   const struct TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistency *dc)
      39              : {
      40            0 :   json_t *list = cls;
      41              :   json_t *obj;
      42              : 
      43            0 :   obj = GNUNET_JSON_PACK (
      44              :     GNUNET_JSON_pack_int64 ("row_id", dc->row_id),
      45              :     GNUNET_JSON_pack_data_auto ("reserve_pub", &dc->reserve_pub),
      46              :     TALER_JSON_pack_amount ("exchange_amount", &dc->exchange_amount),
      47              :     TALER_JSON_pack_amount ("auditor_amount", &dc->auditor_amount),
      48              :     GNUNET_JSON_pack_bool ("suppressed", dc->suppressed)
      49              :     );
      50            0 :   GNUNET_break (0 ==
      51              :                 json_array_append_new (list,
      52              :                                        obj));
      53            0 :   return GNUNET_OK;
      54              : }
      55              : 
      56              : 
      57              : MHD_RESULT
      58            0 : TAH_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_handler_get (
      59              :   struct TAH_RequestHandler *rh,
      60              :   struct MHD_Connection *connection,
      61              :   void **connection_cls,
      62              :   const char *upload_data,
      63              :   size_t *upload_data_size,
      64              :   const char *const args[])
      65              : {
      66              :   json_t *ja;
      67              :   enum GNUNET_DB_QueryStatus qs;
      68            0 :   int64_t limit = -20;
      69              :   uint64_t offset;
      70            0 :   bool return_suppressed = false;
      71              : 
      72              :   (void) rh;
      73              :   (void) connection_cls;
      74              :   (void) upload_data;
      75              :   (void) upload_data_size;
      76            0 :   if (GNUNET_SYSERR ==
      77            0 :       TAH_plugin->preflight (TAH_plugin->cls))
      78              :   {
      79            0 :     GNUNET_break (0);
      80            0 :     return TALER_MHD_reply_with_error (connection,
      81              :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
      82              :                                        TALER_EC_GENERIC_DB_SETUP_FAILED,
      83              :                                        NULL);
      84              :   }
      85            0 :   TALER_MHD_parse_request_snumber (connection,
      86              :                                    "limit",
      87              :                                    &limit);
      88            0 :   if (limit < 0)
      89            0 :     offset = INT64_MAX;
      90              :   else
      91            0 :     offset = 0;
      92            0 :   TALER_MHD_parse_request_number (connection,
      93              :                                   "offset",
      94              :                                   &offset);
      95              :   {
      96            0 :     const char *ret_s = MHD_lookup_connection_value (connection,
      97              :                                                      MHD_GET_ARGUMENT_KIND,
      98              :                                                      "return_suppressed");
      99              : 
     100            0 :     if (ret_s != NULL && strcmp (ret_s, "true") == 0)
     101              :     {
     102            0 :       return_suppressed = true;
     103              :     }
     104              :   }
     105            0 :   ja = json_array ();
     106            0 :   GNUNET_break (NULL != ja);
     107            0 :   qs = TAH_plugin->get_reserve_balance_summary_wrong_inconsistency (
     108            0 :     TAH_plugin->cls,
     109              :     limit,
     110              :     offset,
     111              :     return_suppressed,
     112              :     &process_reserve_balance_summary_wrong_inconsistency,
     113              :     ja);
     114              : 
     115            0 :   if (0 > qs)
     116              :   {
     117            0 :     GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
     118            0 :     json_decref (ja);
     119            0 :     TALER_LOG_WARNING (
     120              :       "Failed to handle GET /reserve-balance-summary-wrong-inconsistency");
     121            0 :     return TALER_MHD_reply_with_error (
     122              :       connection,
     123              :       MHD_HTTP_INTERNAL_SERVER_ERROR,
     124              :       TALER_EC_GENERIC_DB_FETCH_FAILED,
     125              :       "reserve-balance-summary-wrong-inconsistency");
     126              :   }
     127            0 :   return TALER_MHD_REPLY_JSON_PACK (
     128              :     connection,
     129              :     MHD_HTTP_OK,
     130              :     GNUNET_JSON_pack_array_steal ("reserve_balance_summary_wrong_inconsistency",
     131              :                                   ja));
     132              : }
        

Generated by: LCOV version 2.0-1