summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavier Hernandez <jhernandez@soleta.eu>2024-01-08 11:14:42 +0100
committerOpenGnSys Support Team <soporte-og@soleta.eu>2024-01-08 13:08:55 +0100
commit28ab2aa9b0fe22c4d4658f37799e2735b7370ef2 (patch)
tree9b2ff285c1421275f14fe53e4b50ab68bca9ab50
parenta7727e40eaf30393b3fde4e2bd0a7224b0ba8f83 (diff)
rest: Use mask to differentiate folder types
marker tells us if this folder to group rooms or computers. this is a woraround because the database has two tables to store room and computer folders, there is no unique id. the tables cannot be merged yet because of the legacy web console, to overcome this limitation, add a marker that provides a unique id to differentiate room and computer folder. this assumes only 65535 room folders are possible because the marker is 0x000010000 (65536)
-rw-r--r--src/rest.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/rest.c b/src/rest.c
index 8bde175..0ecfcbd 100644
--- a/src/rest.c
+++ b/src/rest.c
@@ -3943,14 +3943,20 @@ static int og_dbi_scope_get_computers_from_computers(const struct og_dbi *dbi,
char *query,
const uint32_t group_id);
+#define OG_COMPUTER_FOLDER_MARKER 0x00010000
+
static int og_dbi_scope_get_computers(const struct og_dbi *dbi, json_t *array,
- char *query)
+ char *query, bool in_room)
{
const char *msglog, *computers_name;
json_t *computers, *scope_array;
uint32_t computers_id;
+ uint32_t marker = 0;
dbi_result result;
+ if (in_room)
+ marker = OG_COMPUTER_FOLDER_MARKER;
+
result = dbi_conn_queryf(dbi->conn, query);
if (!result) {
dbi_conn_error(dbi->conn, &msglog);
@@ -3974,7 +3980,7 @@ static int og_dbi_scope_get_computers(const struct og_dbi *dbi, json_t *array,
json_string(computers_name));
json_object_set_new(computers, "type", json_string("folder"));
json_object_set_new(computers, "id",
- json_integer(computers_id));
+ json_integer(computers_id | marker));
json_object_set_new(computers, "scope", json_array());
json_array_append(array, computers);
json_decref(computers);
@@ -4018,7 +4024,7 @@ static int og_dbi_scope_get_computers_from_room(const struct og_dbi *dbi,
if (ret <= 0 || ret >= OG_QUERY_MAXLEN)
return -1;
- return og_dbi_scope_get_computers(dbi, array, query);
+ return og_dbi_scope_get_computers(dbi, array, query, true);
}
static int og_dbi_scope_get_computers_from_computers(const struct og_dbi *dbi,
@@ -4033,7 +4039,7 @@ static int og_dbi_scope_get_computers_from_computers(const struct og_dbi *dbi,
if (ret <= 0 || ret >= OG_QUERY_MAXLEN)
return -1;
- return og_dbi_scope_get_computers(dbi, array, query);
+ return og_dbi_scope_get_computers(dbi, array, query, false);
}
static int og_dbi_scope_get_room(const struct og_dbi *dbi, json_t *array,