LCOV - code coverage report
Current view: top level - backend - taler-merchant-httpd_private-post-reports.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 24 0
Test Date: 2025-12-29 21:26:17 Functions: 0.0 % 1 0

            Line data    Source code
       1              : /*
       2              :   This file is part of TALER
       3              :   (C) 2025 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 Affero General Public License for more
      12              :   details.
      13              : 
      14              :   You should have received a copy of the GNU Affero General Public License
      15              :   along with TALER; see the file COPYING.  If not, see
      16              :   <http://www.gnu.org/licenses/>
      17              : */
      18              : /**
      19              :  * @file merchant/backend/taler-merchant-httpd_private-post-reports.c
      20              :  * @brief implementation of POST /private/reports
      21              :  * @author Christian Grothoff
      22              :  */
      23              : #include "platform.h"
      24              : #include "taler-merchant-httpd_private-post-reports.h"
      25              : #include <taler/taler_json_lib.h>
      26              : #include <taler/taler_dbevents.h>
      27              : 
      28              : MHD_RESULT
      29            0 : TMH_private_post_reports (const struct TMH_RequestHandler *rh,
      30              :                           struct MHD_Connection *connection,
      31              :                           struct TMH_HandlerContext *hc)
      32              : {
      33              :   const char *description;
      34              :   const char *program_section;
      35              :   const char *mime_type;
      36              :   const char *data_source;
      37              :   const char *target_address;
      38              :   struct GNUNET_TIME_Relative frequency;
      39              :   struct GNUNET_TIME_Relative frequency_shift;
      40              :   enum GNUNET_DB_QueryStatus qs;
      41              :   struct GNUNET_JSON_Specification spec[] = {
      42            0 :     GNUNET_JSON_spec_string ("description",
      43              :                              &description),
      44            0 :     GNUNET_JSON_spec_string ("program_section",
      45              :                              &program_section),
      46            0 :     GNUNET_JSON_spec_string ("mime_type",
      47              :                              &mime_type),
      48            0 :     GNUNET_JSON_spec_string ("data_source",
      49              :                              &data_source),
      50            0 :     GNUNET_JSON_spec_string ("target_address",
      51              :                              &target_address),
      52            0 :     GNUNET_JSON_spec_relative_time ("report_frequency",
      53              :                                     &frequency),
      54            0 :     GNUNET_JSON_spec_relative_time ("report_frequency_shift",
      55              :                                     &frequency_shift),
      56            0 :     GNUNET_JSON_spec_end ()
      57              :   };
      58              :   uint64_t report_id;
      59              : 
      60              :   (void) rh;
      61              : 
      62              :   {
      63              :     enum GNUNET_GenericReturnValue res;
      64              : 
      65            0 :     res = TALER_MHD_parse_json_data (connection,
      66            0 :                                      hc->request_body,
      67              :                                      spec);
      68            0 :     if (GNUNET_OK != res)
      69              :     {
      70            0 :       GNUNET_break_op (0);
      71              :       return (GNUNET_NO == res)
      72              :              ? MHD_YES
      73            0 :              : MHD_NO;
      74              :     }
      75              :   }
      76              : 
      77            0 :   qs = TMH_db->insert_report (TMH_db->cls,
      78            0 :                               hc->instance->settings.id,
      79              :                               program_section,
      80              :                               description,
      81              :                               mime_type,
      82              :                               data_source,
      83              :                               target_address,
      84              :                               frequency,
      85              :                               frequency_shift,
      86              :                               &report_id);
      87            0 :   if (qs < 0)
      88              :   {
      89            0 :     GNUNET_break (0);
      90            0 :     return TALER_MHD_reply_with_error (connection,
      91              :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
      92              :                                        TALER_EC_GENERIC_DB_STORE_FAILED,
      93              :                                        "insert_report");
      94              :   }
      95              : 
      96              :   /* FIXME-Optimization: do trigger inside of transaction above... */
      97              :   {
      98            0 :     struct GNUNET_DB_EventHeaderP ev = {
      99            0 :       .size = htons (sizeof (ev)),
     100            0 :       .type = htons (TALER_DBEVENT_MERCHANT_REPORT_UPDATE)
     101              :     };
     102              : 
     103            0 :     TMH_db->event_notify (TMH_db->cls,
     104              :                           &ev,
     105              :                           NULL,
     106              :                           0);
     107              :   }
     108              : 
     109            0 :   return TALER_MHD_REPLY_JSON_PACK (
     110              :     connection,
     111              :     MHD_HTTP_OK,
     112              :     GNUNET_JSON_pack_uint64 ("report_serial_id",
     113              :                              report_id));
     114              : }
        

Generated by: LCOV version 2.0-1