summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2024-09-09 16:02:24 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2024-09-09 16:18:26 +0200
commit568d709361d42adb1cd0a41da99a2139d32e129d (patch)
tree72779210431b65d359dcab1b87bd41e07b4eb755 /src
parent4567bce90b38280dc6a217e5dfe2af20b3bdf95f (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.c14
1 files changed, 7 insertions, 7 deletions
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, &params->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);