aboutsummaryrefslogtreecommitdiff
path: root/src/exchange
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-12-28 23:44:17 +0100
committerChristian Grothoff <christian@grothoff.org>2022-12-28 23:44:17 +0100
commit880c14909bfdaf1199ffc5da989eccb52f6cac12 (patch)
treeb135e2ea69a1df8ec2d09492873e025e8b2d2a06 /src/exchange
parent5533bcbf651eafce682212ce635bdf8ce83d4bcb (diff)
downloadexchange-880c14909bfdaf1199ffc5da989eccb52f6cac12.tar.gz
exchange-880c14909bfdaf1199ffc5da989eccb52f6cac12.tar.bz2
exchange-880c14909bfdaf1199ffc5da989eccb52f6cac12.zip
add notification logic on purse deletion
Diffstat (limited to 'src/exchange')
-rw-r--r--src/exchange/taler-exchange-httpd_purses_delete.c18
-rw-r--r--src/exchange/taler-exchange-httpd_purses_deposit.c18
-rw-r--r--src/exchange/taler-exchange-httpd_purses_get.c11
3 files changed, 38 insertions, 9 deletions
diff --git a/src/exchange/taler-exchange-httpd_purses_delete.c b/src/exchange/taler-exchange-httpd_purses_delete.c
index f4106a664..58cc78250 100644
--- a/src/exchange/taler-exchange-httpd_purses_delete.c
+++ b/src/exchange/taler-exchange-httpd_purses_delete.c
@@ -24,6 +24,7 @@
#include <gnunet/gnunet_json_lib.h>
#include <jansson.h>
#include <microhttpd.h>
+#include "taler_dbevents.h"
#include "taler_json_lib.h"
#include "taler_mhd_lib.h"
#include "taler-exchange-httpd_common_deposit.h"
@@ -131,6 +132,23 @@ TEH_handler_purses_delete (
TALER_EC_EXCHANGE_PURSE_DELETE_ALREADY_DECIDED,
NULL);
}
+ {
+ /* Possible minor optimization: integrate notification with
+ transaction above... */
+ struct TALER_PurseEventP rep = {
+ .header.size = htons (sizeof (rep)),
+ .header.type = htons (TALER_DBEVENT_EXCHANGE_PURSE_DEPOSITED),
+ .purse_pub = purse_pub
+ };
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Notifying about purse deletion %s\n",
+ TALER_B2S (&purse_pub));
+ TEH_plugin->event_notify (TEH_plugin->cls,
+ &rep.header,
+ NULL,
+ 0);
+ }
/* success */
return TALER_MHD_reply_static (connection,
MHD_HTTP_NO_CONTENT,
diff --git a/src/exchange/taler-exchange-httpd_purses_deposit.c b/src/exchange/taler-exchange-httpd_purses_deposit.c
index 4bebebf6f..291807aaa 100644
--- a/src/exchange/taler-exchange-httpd_purses_deposit.c
+++ b/src/exchange/taler-exchange-httpd_purses_deposit.c
@@ -374,6 +374,7 @@ TEH_handler_purses_deposit (
enum GNUNET_DB_QueryStatus qs;
struct GNUNET_TIME_Timestamp create_timestamp;
struct GNUNET_TIME_Timestamp merge_timestamp;
+ bool was_deleted;
qs = TEH_plugin->select_purse (
TEH_plugin->cls,
@@ -383,7 +384,8 @@ TEH_handler_purses_deposit (
&pcc.amount,
&pcc.deposit_total,
&pcc.h_contract_terms,
- &merge_timestamp);
+ &merge_timestamp,
+ &was_deleted);
switch (qs)
{
case GNUNET_DB_STATUS_HARD_ERROR:
@@ -406,12 +408,16 @@ TEH_handler_purses_deposit (
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
break; /* handled below */
}
- if (GNUNET_TIME_absolute_is_past (pcc.purse_expiration.abs_time))
+ if (GNUNET_TIME_absolute_is_past (pcc.purse_expiration.abs_time) ||
+ was_deleted)
{
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_GONE,
- TALER_EC_EXCHANGE_GENERIC_PURSE_EXPIRED,
- NULL);
+ return TALER_MHD_reply_with_error (
+ connection,
+ MHD_HTTP_GONE,
+ was_deleted
+ ? TALER_EC_EXCHANGE_GENERIC_PURSE_DELETED
+ : TALER_EC_EXCHANGE_GENERIC_PURSE_EXPIRED,
+ GNUNET_TIME_timestamp2s (pcc.purse_expiration));
}
}
diff --git a/src/exchange/taler-exchange-httpd_purses_get.c b/src/exchange/taler-exchange-httpd_purses_get.c
index 8384086b6..e36b9a101 100644
--- a/src/exchange/taler-exchange-httpd_purses_get.c
+++ b/src/exchange/taler-exchange-httpd_purses_get.c
@@ -207,6 +207,7 @@ TEH_handler_purses_get (struct TEH_RequestContext *rc,
const char *const args[2])
{
struct GetContext *gc = rc->rh_ctx;
+ bool purse_deleted;
MHD_RESULT res;
if (NULL == gc)
@@ -312,7 +313,8 @@ TEH_handler_purses_get (struct TEH_RequestContext *rc,
&gc->amount,
&gc->deposited,
&gc->h_contract,
- &gc->merge_timestamp);
+ &gc->merge_timestamp,
+ &purse_deleted);
switch (qs)
{
case GNUNET_DB_STATUS_HARD_ERROR:
@@ -367,11 +369,14 @@ TEH_handler_purses_get (struct TEH_RequestContext *rc,
gc->eh = eh2;
}
}
- if (GNUNET_TIME_absolute_is_past (gc->purse_expiration.abs_time))
+ if (GNUNET_TIME_absolute_is_past (gc->purse_expiration.abs_time) ||
+ purse_deleted)
{
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_GONE,
- TALER_EC_EXCHANGE_GENERIC_PURSE_EXPIRED,
+ purse_deleted
+ ? TALER_EC_EXCHANGE_GENERIC_PURSE_DELETED
+ : TALER_EC_EXCHANGE_GENERIC_PURSE_EXPIRED,
GNUNET_TIME_timestamp2s (
gc->purse_expiration));
}