Bridge polls from Matrix as pseudo-polls on Discord (with an embed). Not 100% working.

Co-authored-by: Cadence Ember <cloudrac3r@vivaldi.net>
This commit is contained in:
Ellie Algase
2026-01-25 00:28:42 -06:00
committed by Cadence Ember
parent e565342ac8
commit afca4de6b6
12 changed files with 417 additions and 156 deletions

View File

@@ -1,19 +0,0 @@
BEGIN TRANSACTION;
CREATE TABLE "poll_option" (
"message_id" TEXT NOT NULL,
"matrix_option" TEXT NOT NULL,
"discord_option" TEXT NOT NULL,
PRIMARY KEY("message_id","matrix_option")
FOREIGN KEY ("message_id") REFERENCES "message_channel" ("message_id") ON DELETE CASCADE
) WITHOUT ROWID;
CREATE TABLE "poll_vote" (
"vote" TEXT NOT NULL,
"message_id" TEXT NOT NULL,
"discord_or_matrix_user_id" TEXT NOT NULL,
PRIMARY KEY("vote","message_id","discord_or_matrix_user_id"),
FOREIGN KEY("message_id") REFERENCES "message_channel" ("message_id") ON DELETE CASCADE
) WITHOUT ROWID;
COMMIT;

View File

@@ -0,0 +1,34 @@
BEGIN TRANSACTION;
DROP TABLE IF EXISTS "poll";
DROP TABLE IF EXISTS "poll_option";
DROP TABLE IF EXISTS "poll_vote";
CREATE TABLE "poll" (
"message_id" TEXT NOT NULL,
"max_selections" INTEGER NOT NULL,
"question_text" TEXT NOT NULL,
"is_closed" INTEGER NOT NULL,
PRIMARY KEY ("message_id"),
FOREIGN KEY ("message_id") REFERENCES "message_room" ("message_id") ON DELETE CASCADE
) WITHOUT ROWID;
CREATE TABLE "poll_option" (
"message_id" TEXT NOT NULL,
"matrix_option" TEXT NOT NULL,
"discord_option" TEXT,
"option_text" TEXT NOT NULL,
"seq" INTEGER NOT NULL,
PRIMARY KEY ("message_id", "matrix_option"),
FOREIGN KEY ("message_id") REFERENCES "poll" ("message_id") ON DELETE CASCADE
) WITHOUT ROWID;
CREATE TABLE "poll_vote" (
"message_id" TEXT NOT NULL,
"matrix_option" TEXT NOT NULL,
"discord_or_matrix_user_id" TEXT NOT NULL,
PRIMARY KEY ("message_id", "matrix_option", "discord_or_matrix_user_id"),
FOREIGN KEY ("message_id", "matrix_option") REFERENCES "poll_option" ("message_id", "matrix_option") ON DELETE CASCADE
) WITHOUT ROWID;
COMMIT;

19
src/db/orm-defs.d.ts vendored
View File

@@ -140,16 +140,25 @@ export type Models = {
original_encoding: string | null
}
poll_vote: {
vote: string
poll: { // not actually in database yet
message_id: string
discord_or_matrix_user_id: string
max_selections: number
question_text: string
is_closed: number
}
poll_option: {
message_id: string
matrix_option: string
discord_option: string
discord_option: string | null
option_text: string // not actually in database yet
seq: number // not actually in database yet
}
poll_vote: {
message_id: string
matrix_option: string
discord_or_matrix_user_id: string
}
}