From 19ae55a7b714e8f30ad2419e2a4a24a8c3d23bd9 Mon Sep 17 00:00:00 2001 From: sijanec Date: Thu, 18 Mar 2021 18:19:25 +0100 Subject: preparing for packaging for debian --- src/api.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/api.c') diff --git a/src/api.c b/src/api.c index 3460edb..cd646dc 100644 --- a/src/api.c +++ b/src/api.c @@ -7,8 +7,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -496,14 +495,17 @@ int dc_fetch_channels (struct dc_guild * g) { char * topic = cJSON_GetStringValue(cJSON_GetObjectItem(channel, "topic")); char * name = cJSON_GetStringValue(cJSON_GetObjectItem(channel, "name")); char * id = cJSON_GetStringValue(cJSON_GetObjectItem(channel, "id")); - double type = cJSON_GetNumberValue(cJSON_GetObjectItem(channel, "type")); - double slowmode = cJSON_GetNumberValue(cJSON_GetObjectItem(channel, "rate_limit_per_user")); - if (!id || !name || type == NAN) { - DC_CLIENT_ERROR(c, "!id || !name || type == NAN"); + cJSON * type = cJSON_GetObjectItem(channel, "type"); + cJSON * jsonslowmode = cJSON_GetObjectItem(channel, "rate_limit_per_user"); + if (!cJSON_IsNumber(type) || !id || !name) { + DC_CLIENT_ERROR(c, "!cJSON_IsNumber(jsontype) || !id || !name"); continue; } - if (type != 0) /* if it's not a text channel (z. B. voice channel, category, ...) */ + if (type->valueint != 0) /* if it's not a text channel (z. B. voice channel, category, ...) */ continue; + int slowmode = 0; + if (cJSON_IsNumber(jsonslowmode)) + slowmode = jsonslowmode->valueint; if (!topic) topic = ""; unsigned long long int idull = strtoull(id, NULL, 10); @@ -523,7 +525,7 @@ int dc_fetch_channels (struct dc_guild * g) { g->channels[g->channels_sizeof-1]->guild = g; g->channels[g->channels_sizeof-1]->messages = NULL; g->channels[g->channels_sizeof-1]->messages_sizeof = 0; - g->channels[g->channels_sizeof-1]->slowmode = slowmode != NAN ? slowmode : 0; + g->channels[g->channels_sizeof-1]->slowmode = slowmode; } if (DC_CUE(c, c->guilds_lock)) {rs = -8; goto rc;} rc: -- cgit v1.2.3