From 0327cba62d6e32d47a249ef10dd56baa421b6f8a Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Fri, 14 Aug 2020 11:22:10 +0200 Subject: Handle the alert flag in subscriptions --- restapi/subscriptions.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'restapi') diff --git a/restapi/subscriptions.c b/restapi/subscriptions.c index 5a1abe6..a296b1c 100644 --- a/restapi/subscriptions.c +++ b/restapi/subscriptions.c @@ -42,8 +42,9 @@ restapi_subscriptions_get(void) const cJSON* type = cJSON_GetObjectItemCaseSensitive(update, "t"); const cJSON* open = cJSON_GetObjectItemCaseSensitive(update, "open"); const cJSON* unread = cJSON_GetObjectItemCaseSensitive(update, "unread"); + const cJSON* alert = cJSON_GetObjectItemCaseSensitive(update, "alert"); enum subscription_type etype; - if (!cJSON_IsString(rid) || rid->valuestring == NULL || !cJSON_IsString(name) || name->valuestring == NULL || !cJSON_IsString(type) || type->valuestring == NULL || !cJSON_IsTrue(open) || !cJSON_IsNumber(unread)) + if (!cJSON_IsString(rid) || rid->valuestring == NULL || !cJSON_IsString(name) || name->valuestring == NULL || !cJSON_IsString(type) || type->valuestring == NULL || !cJSON_IsTrue(open) || !cJSON_IsNumber(unread) || !(cJSON_IsTrue(alert) || cJSON_IsFalse(alert))) continue; if (strcmp(type->valuestring, "c") == 0) etype = SUBSCRIPTION_CHANNEL; @@ -55,7 +56,7 @@ restapi_subscriptions_get(void) fprintf(stderr, "Bug found : Unknown subscription type %s\n%s\n", type->valuestring, buffer); exit(999); } - common_subscription_add(&subscriptions, rid->valuestring, name->valuestring, etype, unread->valueint); + common_subscription_add(&subscriptions, rid->valuestring, name->valuestring, etype, unread->valueint, cJSON_IsTrue(alert)); } } get_json_cleanup: -- cgit v1.2.3