From 568d709361d42adb1cd0a41da99a2139d32e129d Mon Sep 17 00:00:00 2001 From: OpenGnSys Support Team Date: Mon, 9 Sep 2024 16:02:24 +0200 Subject: rest: use integer for repository ID ID is integer, fix inconsistency in dc68d0f ('rest: add POST /client/repo') --- src/rest.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/rest.c b/src/rest.c index f836ef6..a86a9ec 100644 --- a/src/rest.c +++ b/src/rest.c @@ -1896,16 +1896,15 @@ static int og_cmd_get_client_setup(json_t *element, return 0; } -static int og_dbi_update_client_repo(struct og_dbi *dbi, - const char *mac, - const char *repo_id) +static int og_dbi_update_client_repo(struct og_dbi *dbi, const char *mac, + uint32_t repo_id) { const char *msglog; dbi_result result; result = dbi_conn_queryf(dbi->conn, - "UPDATE ordenadores SET idrepositorio=%s " - "WHERE mac='%s'", + "UPDATE ordenadores SET idrepositorio=%u " + "WHERE mac='%u'", repo_id, mac); if (!result) { @@ -1928,6 +1927,7 @@ static int og_cmd_post_client_repo(json_t *element, int ips_str_len = 0; struct og_dbi *dbi; dbi_result result; + uint32_t repo_id; int err = 0, i; json_t *value; @@ -1935,7 +1935,7 @@ static int og_cmd_post_client_repo(json_t *element, if (!strcmp(key, "clients")) { err = og_json_parse_clients(value, params); } else if (!strcmp(key, "id")) { - err = og_json_parse_string(value, ¶ms->id); + err = og_json_parse_uint(value, &repo_id); params->flags |= OG_REST_PARAM_ID; } @@ -1974,7 +1974,7 @@ static int og_cmd_post_client_repo(json_t *element, while (dbi_result_next_row(result)) { mac = dbi_result_get_string(result, "mac"); - err = og_dbi_update_client_repo(dbi, mac, params->id); + err = og_dbi_update_client_repo(dbi, mac, repo_id); if (err != 0) { dbi_result_free(result); og_dbi_close(dbi); -- cgit v1.2.3-18-g5258