X-Git-Url: https://git.wpitchoune.net/gitweb/?p=prss.git;a=blobdiff_plain;f=src%2Fttrss_ws.c;fp=src%2Fttrss_ws.c;h=e9680f4850fea6010f3fbe08fda7f405cf93799d;hp=2c0da73af093a1a5341224107a67456c43788bc5;hb=c6fa04234bdb4ad62f0ed0e3f9a619a2ff007e8a;hpb=9f2b2bde43dc8f831417213463709640935eeeb9 diff --git a/src/ttrss_ws.c b/src/ttrss_ws.c index 2c0da73..e9680f4 100644 --- a/src/ttrss_ws.c +++ b/src/ttrss_ws.c @@ -259,32 +259,56 @@ int ws_open_session() return result; } -char *ws_get_article_content(int id) +struct json_object *ws_request_new_get_article_content(int id) { - struct json_object *rp, *rq, *content, *item; - char *str; + struct json_object *rq; rq = ws_request_new("getArticle"); ws_request_add_att_int(rq, "article_id", id); - rp = ws_execute(rq); - - json_object_put(rq); + return rq; +} - str = NULL; +const char *ws_reply_get_article_content(struct json_object *rp) +{ + struct json_object *item, *content; if (rp) { item = json_object_array_get_idx(rp, 0); if (item) { content = json_object_object_get(item, "content"); - str = strdup(json_object_get_string(content)); + return json_object_get_string(content); } + } - json_object_put(rp); + return NULL; +} + +char *ws_get_article_content(int id) +{ + struct json_object *rp, *rq; + const char *content; + char *str; + + rq = ws_request_new("getArticle"); + ws_request_add_att_int(rq, "article_id", id); + + rp = ws_execute(rq); + + json_object_put(rq); + + if (rp) { + content = ws_reply_get_article_content(rp); + + if (content) { + str = strdup(content); + json_object_put(rp); + return str; + } } - return str; + return NULL; } int ws_update_headlines(struct feed *feed) @@ -296,7 +320,6 @@ int ws_update_headlines(struct feed *feed) rq = ws_request_new("getHeadlines"); ws_request_add_att_int(rq, "feed_id", feed->id); - ws_request_add_att_bool(rq, "show_excerpt", 1); rp = ws_execute(rq); @@ -321,10 +344,6 @@ int ws_update_headlines(struct feed *feed) h = headline_new(hid, url, title); j = json_object_object_get(jheadline, - "excerpt"); - h->excerpt = strdup(json_object_get_string(j)); - - j = json_object_object_get(jheadline, "updated"); h->date = json_object_get_int(j);