summaryrefslogtreecommitdiffstats
path: root/src/api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/api.c')
-rw-r--r--src/api.c18
1 files changed, 10 insertions, 8 deletions
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 <i18n.h>
#include <string.h>
#include <lib.c>
-#include <cJSON.h>
-#include <cJSON.c>
+#include <cjson/cJSON.h>
#include <time.h>
#include <stdarg.h>
#include <printf.h>
@@ -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: