Line data Source code
1 : /* 2 : This file is part of TALER 3 : Copyright (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 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 exchangedb/pg_insert_sanction_list_hit.c 18 : * @brief Implementation of the insert_sanction_list_hit function for Postgres 19 : * @author Christian Grothoff 20 : */ 21 : #include "platform.h" 22 : #include "taler_error_codes.h" 23 : #include "taler_dbevents.h" 24 : #include "taler_pq_lib.h" 25 : #include "pg_insert_sanction_list_hit.h" 26 : #include "pg_helper.h" 27 : 28 : 29 : enum GNUNET_DB_QueryStatus 30 0 : TEH_PG_insert_sanction_list_hit ( 31 : void *cls, 32 : const struct TALER_NormalizedPaytoHashP *h_payto, 33 : bool to_investigate, 34 : const json_t *new_rules, 35 : const json_t *account_properties, 36 : struct GNUNET_TIME_Timestamp expiration_time, 37 : unsigned int num_events, 38 : const char **events) 39 : { 40 0 : struct PostgresClosure *pg = cls; 41 : struct GNUNET_TIME_Timestamp now 42 0 : = GNUNET_TIME_timestamp_get (); 43 0 : struct TALER_KycCompletedEventP rep = { 44 0 : .header.size = htons (sizeof (rep)), 45 0 : .header.type = htons (TALER_DBEVENT_EXCHANGE_KYC_COMPLETED), 46 : .h_payto = *h_payto 47 : }; 48 : char *notify_s 49 0 : = GNUNET_PQ_get_event_notify_channel (&rep.header); 50 0 : struct GNUNET_PQ_QueryParam params[] = { 51 0 : GNUNET_PQ_query_param_auto_from_type (h_payto), 52 0 : GNUNET_PQ_query_param_timestamp (&now), 53 0 : GNUNET_PQ_query_param_timestamp (&expiration_time), 54 : NULL != account_properties 55 0 : ? TALER_PQ_query_param_json (account_properties) 56 0 : : GNUNET_PQ_query_param_null (), 57 : NULL != new_rules 58 0 : ? TALER_PQ_query_param_json (new_rules) 59 0 : : GNUNET_PQ_query_param_null (), 60 0 : GNUNET_PQ_query_param_bool (to_investigate), 61 0 : GNUNET_PQ_query_param_string (notify_s), 62 0 : GNUNET_PQ_query_param_array_ptrs_string (num_events, 63 : events, 64 : pg->conn), 65 : GNUNET_PQ_query_param_end 66 : }; 67 : uint64_t outcome_serial_id; 68 0 : struct GNUNET_PQ_ResultSpec rs[] = { 69 0 : GNUNET_PQ_result_spec_uint64 ("outcome_serial_id", 70 : &outcome_serial_id), 71 : GNUNET_PQ_result_spec_end 72 : }; 73 : enum GNUNET_DB_QueryStatus qs; 74 : 75 0 : PREPARE (pg, 76 : "do_insert_sanction_list_hit", 77 : "SELECT" 78 : " out_outcome_serial_id" 79 : " FROM exchange_insert_sanction_list_hit" 80 : "($1,$2,$3,$4,$5,$6,$7,$8);"); 81 0 : qs = GNUNET_PQ_eval_prepared_singleton_select ( 82 : pg->conn, 83 : "do_insert_sanction_list_hit", 84 : params, 85 : rs); 86 : (void) outcome_serial_id; 87 0 : GNUNET_PQ_cleanup_query_params_closures (params); 88 0 : GNUNET_free (notify_s); 89 0 : GNUNET_PQ_event_do_poll (pg->conn); 90 0 : return qs; 91 : }