commit a853c303e488e6da1b65b7e6b42c1d1d5d81035e
parent 0cd9c8b4f9f1d80e024b6478becf062a43473db4
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 28 Dec 2025 13:31:51 +0100
complete POST /reports/ handler
Diffstat:
1 file changed, 39 insertions(+), 11 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_post-reports-ID.c b/src/backend/taler-merchant-httpd_post-reports-ID.c
@@ -21,6 +21,7 @@
* @author Christian Grothoff
*/
#include "platform.h"
+#include "taler-merchant-httpd_dispatcher.h"
#include "taler-merchant-httpd_post-reports-ID.h"
#include <taler/taler_json_lib.h>
@@ -103,18 +104,45 @@ TMH_post_reports_ID (
}
{
- char *url;
+ struct TMH_MerchantInstance *mi;
- GNUNET_asprintf (&url,
- "/instances/%s%s",
- instance_id,
- data_source);
- GNUNET_free (instance_id);
- GNUNET_free (data_source);
-
- /* FIXME: Generate and return report from URL */
- GNUNET_free (url);
+ mi = TMH_lookup_instance (instance_id);
+ if (NULL == mi)
+ {
+ /* Strange, we found the report but the instance of the
+ report is not known. This should basically be impossible
+ modulo maybe some transactional issue where the
+ instance was created, the report added *and* triggered
+ before this process was able to process the notification
+ about the new instance. Wild. */
+ GNUNET_break (0);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_NOT_FOUND,
+ TALER_EC_MERCHANT_GENERIC_REPORT_UNKNOWN,
+ report_id_str);
+ }
+ /* Rewrite request: force instance to match report */
+ hc->instance = mi;
}
+ {
+ enum GNUNET_GenericReturnValue ret;
+ bool is_public; /* ignored: access control never applies for reports */
- return MHD_NO;
+ /* This rewrite request: force request handler to match report! */
+ hc->rh = NULL; /* just to make it clear: current one will NOT remain */
+ ret = TMH_dispatch_request (hc,
+ data_source,
+ MHD_HTTP_METHOD_GET,
+ 0 == strcmp ("admin",
+ instance_id),
+ &is_public);
+ if (GNUNET_OK != ret)
+ return (GNUNET_NO == ret) ? MHD_YES : MHD_NO;
+ GNUNET_break (NULL != hc->rh);
+ }
+ GNUNET_free (instance_id);
+ GNUNET_free (data_source);
+ /* MHD will call the main handler again, which will now
+ dispatch into the _new_ handler callback we just installed! */
+ return MHD_YES;
}