diff options
author | OpenGnSys Support Team <soporte-og@soleta.eu> | 2024-09-09 16:02:24 +0200 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2024-09-09 16:18:26 +0200 |
commit | 568d709361d42adb1cd0a41da99a2139d32e129d (patch) | |
tree | 72779210431b65d359dcab1b87bd41e07b4eb755 /src | |
parent | 4567bce90b38280dc6a217e5dfe2af20b3bdf95f (diff) |
rest: use integer for repository ID
ID is integer, fix inconsistency in dc68d0f ('rest: add POST /client/repo')
Diffstat (limited to 'src')
-rw-r--r-- | src/rest.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -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); |