Separating users from tasks + fixing weird ota bug

This commit is contained in:
2026-03-07 23:41:26 -05:00
parent 3fa879d007
commit ac95358561
14 changed files with 657 additions and 308 deletions

View File

@@ -3,7 +3,7 @@
#include "api/users/store.hpp"
// Find a user by ID, returns nullptr if not found
internal user_t *find_user(uint8 id)
user_t *find_user(uint8 id)
{
for (int i = 0; i < MAX_USERS; i++)
{
@@ -16,7 +16,7 @@ internal user_t *find_user(uint8 id)
}
// Add a user, returns pointer to new user or nullptr if full
internal user_t *add_user(const char *name)
user_t *add_user(const char *name)
{
for (int i = 0; i < MAX_USERS; i++)
{
@@ -32,7 +32,7 @@ internal user_t *add_user(const char *name)
}
// Remove a user by ID, returns true if found and removed
internal bool remove_user(uint8 id)
bool remove_user(uint8 id)
{
for (int i = 0; i < MAX_USERS; i++)
{
@@ -47,8 +47,19 @@ internal bool remove_user(uint8 id)
return false;
}
// Update a user's name, returns pointer to user or nullptr if not found
user_t *update_user(uint8 id, const char *name)
{
user_t *user = find_user(id);
if (user)
{
strlcpy(user->name, name, sizeof(user->name));
}
return user;
}
// Populate dummy users on boot for development iteration
internal void seed_users()
void seed_users()
{
add_user("Alice");
add_user("Bob");