diff options
Diffstat (limited to 'src/exchange/taler-exchange-httpd_extensions.c')
-rw-r--r-- | src/exchange/taler-exchange-httpd_extensions.c | 59 |
1 files changed, 42 insertions, 17 deletions
diff --git a/src/exchange/taler-exchange-httpd_extensions.c b/src/exchange/taler-exchange-httpd_extensions.c index d6c26f6f..2a99d7a2 100644 --- a/src/exchange/taler-exchange-httpd_extensions.c +++ b/src/exchange/taler-exchange-httpd_extensions.c @@ -100,6 +100,9 @@ extension_update_event_cb (void *cls, // No config found -> disable extension if (NULL == config_str) { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "No configuration found for extension %s, disabling it\n", + extension->name); extension->disable ((struct TALER_Extension *) extension); return; } @@ -114,28 +117,40 @@ extension_update_event_cb (void *cls, err.text, err.source); GNUNET_break (0); + free(config_str); return; } // Call the parser for the extension ret = extension->load_json_config ( (struct TALER_Extension *) extension, - config); + json_object_get(config, "config")); if (GNUNET_OK != ret) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Couldn't parse configuration for extension %s from the database", - extension->name); + "Couldn't parse configuration for extension %s from the database: %s\n", + extension->name, + config_str); GNUNET_break (0); } + + free(config_str); + json_decref(config); } /* Special case age restriction: Update global flag and mask */ if (TALER_Extension_AgeRestriction == type) { - TEH_age_restriction_enabled = - TALER_extensions_age_restriction_is_enabled (); + const struct TALER_AgeRestrictionConfig *conf = + TALER_extensions_get_age_restriction_config (); + if (NULL != conf) + TEH_age_restriction_config = *conf; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "[age restriction] DB event has changed the config to %s with mask: %s\n", + conf->enabled ? "enabled": "disabled", + TALER_age_mask_to_string (&conf->mask)); + } } @@ -143,14 +158,21 @@ extension_update_event_cb (void *cls, enum GNUNET_GenericReturnValue TEH_extensions_init () { - GNUNET_assert (GNUNET_OK == - TALER_extension_age_restriction_register ()); - /* Set the event handler for updates */ struct GNUNET_DB_EventHeaderP ev = { .size = htons (sizeof (ev)), .type = htons (TALER_DBEVENT_EXCHANGE_EXTENSIONS_UPDATED), }; + + /* Load the shared libraries first */ + if (GNUNET_OK != + TALER_extensions_load (TEH_cfg)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "failed to load extensions"); + return GNUNET_SYSERR; + } + extensions_eh = TEH_plugin->event_listen (TEH_plugin->cls, GNUNET_TIME_UNIT_FOREVER_REL, &ev, @@ -162,17 +184,20 @@ TEH_extensions_init () return GNUNET_SYSERR; } - /* FIXME #7270: shall we load the extensions from the config right away? - * We do have to for now, as otherwise denominations with age restriction - * will not have the age mask set right upon initial generation. - */ - TALER_extensions_load_taler_config (TEH_cfg); - /* Trigger the initial load of configuration from the db */ - for (const struct TALER_Extension *it = TALER_extensions_get_head (); - NULL != it->next; + for (const struct TALER_Extensions *it = TALER_extensions_get_head (); + NULL != it && NULL != it->extension; it = it->next) - extension_update_event_cb (NULL, &it->type, sizeof(it->type)); + { + const struct TALER_Extension *ext = it->extension; + char *conf = json_dumps (ext->config_to_json (ext), JSON_COMPACT); + + TEH_plugin->set_extension_config (TEH_plugin->cls, + ext->name, + conf); + extension_update_event_cb (NULL, &ext->type, sizeof(ext->type)); + free (conf); + } return GNUNET_OK; } |