From ad5f6b20264ca4abc19bc470bff070b75eaf61f9 Mon Sep 17 00:00:00 2001 From: Michael McVady Date: Mon, 2 Jan 2023 11:19:46 -0600 Subject: Fix JSON HTTP 404 --- src/clog.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/clog.c b/src/clog.c index 3ef2121..83f9f79 100644 --- a/src/clog.c +++ b/src/clog.c @@ -320,6 +320,7 @@ render_posts_json(struct post_request *post_req) ") row;" ); } + if (err == KORE_RESULT_ERROR) { post_req->resp_status = HTTP_STATUS_INTERNAL_ERROR; @@ -327,24 +328,14 @@ render_posts_json(struct post_request *post_req) goto out; } - rows = kore_pgsql_ntuples(&sql); - kore_log(LOG_DEBUG, "JSON rows: %d", rows); - - int fields = kore_pgsql_nfields(&sql); - kore_log(LOG_DEBUG, "JSON fields: %d", fields); - - int len = kore_pgsql_getlength(&sql, 0, 0); - kore_log(LOG_DEBUG, "JSON fields: %d", fields); - - kore_pgsql_logerror(&sql); + if (kore_pgsql_getlength(&sql, 0, 0) == 0) + { + post_req->resp_status = HTTP_STATUS_NOT_FOUND; + goto out; + } if (rows == 1) { json = kore_pgsql_getvalue(&sql, 0, 0); - kore_log(LOG_DEBUG, "JSON data: %s", json); - - len = kore_pgsql_getlength(&sql, 0, 0); - kore_log(LOG_DEBUG, "JSON data len: %d", len); - kore_buf_append( post_req->resp_buf, json, -- cgit v1.2.3