static GError * __notify_services(struct meta1_backend_s *m1, struct sqlx_sqlite3_s *sq3, struct oio_url_s *url) { if (!m1->notifier) return NULL; struct meta1_service_url_s **services = NULL; GError *err = __get_container_all_services(sq3, url, NULL, &services); if (!err) { struct meta1_service_url_s **services2 = expand_urlv(services); GString *notif = g_string_sized_new(128); g_string_append (notif, "{\"event\":\""NAME_SRVTYPE_META1".account.services\""); g_string_append_printf (notif, ",\"when\":%"G_GINT64_FORMAT, oio_ext_real_time()); g_string_append (notif, ",\"data\":{"); g_string_append_printf (notif, "\"url\":\"%s\"", oio_url_get(url, OIOURL_WHOLE)); g_string_append (notif, ",\"services\":["); if (services2) { for (struct meta1_service_url_s **svc = services2; *svc ; svc++) { if (svc != services2) // not at the beginning g_string_append(notif, ","); meta1_service_url_encode_json(notif, *svc); } } g_string_append(notif, "]}}"); oio_events_queue__send (m1->notifier, g_string_free(notif, FALSE)); meta1_service_url_cleanv(services2); meta1_service_url_cleanv(services); } return err; }
static GError * __notify_services(struct meta1_backend_s *m1, struct sqlx_sqlite3_s *sq3, struct oio_url_s *url) { if (!m1->notifier) return NULL; struct meta1_service_url_s **services = NULL; GError *err = __get_container_all_services(sq3, url, NULL, &services); if (!err) { struct meta1_service_url_s **services2 = expand_urlv(services); GString *notif = oio_event__create ("account.services", url); g_string_append (notif, ",\"data\":["); if (services2) { for (struct meta1_service_url_s **svc = services2; *svc ; svc++) { if (svc != services2) // not at the beginning g_string_append(notif, ","); meta1_service_url_encode_json(notif, *svc); } } g_string_append(notif, "]}"); oio_events_queue__send (m1->notifier, g_string_free(notif, FALSE)); meta1_service_url_cleanv(services2); meta1_service_url_cleanv(services); } return err; }
static GString * _pack_m1url_list (GString *gstr, gchar ** urlv) { if (!gstr) gstr = g_string_new (""); g_string_append_c (gstr, '['); for (gchar ** v = urlv; v && *v; v++) { struct meta1_service_url_s *m1 = meta1_unpack_url (*v); meta1_service_url_encode_json (gstr, m1); meta1_service_url_clean (m1); if (*(v + 1)) g_string_append_c (gstr, ','); } g_string_append_c (gstr, ']'); return gstr; }