Add CLI poll creation, voting and emoji reaction commands

This commit is contained in:
evgeny committed 2026-10-06 21:26:37 +02:00
1 parent f99a8c1da2
commit da2c13dcf1
2 files changed
+44 -2

No files matched your search

+7 -1
View File
@@ -351,7 +351,13 @@ int chat_feedback_command(struct UTUN_INSTANCE* inst, const char* command, char*
return poll_command_error("Cannot read reactions", result);
sqlite3_stmt* st = poll_field(inst, command, "$.emoji"); if (!st) return poll_command_error("Invalid emoji", result);
const char* type = (const char*)sqlite3_column_text(st, 0); sqlite3_int64 emoji = sqlite3_column_int64(st, 1);
ok = type && !strcmp(type, "integer") && emoji >= 0 && emoji < CHAT_REACTION_COUNT; sqlite3_finalize(st);
if (type && !strcmp(type, "text")) {
const char* text = (const char*)sqlite3_column_text(st, 1); emoji = -1;
for (unsigned i = 0; text && i < CHAT_REACTION_COUNT; i++)
if (!strcmp(text, chat_reaction_emoji(i))) { emoji = i; break; }
}
ok = type && (!strcmp(type, "integer") || !strcmp(type, "text")) && emoji >= 0 && emoji < CHAT_REACTION_COUNT;
sqlite3_finalize(st);
if (!ok) return poll_command_error("Invalid emoji", result);
size_t at = 0; while (at < count && ids[at] != emoji) at++;
int on = poll_field_bool(inst, command, "$.on", at == count);