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:
committed by
Cadence Ember
parent
e565342ac8
commit
afca4de6b6
@@ -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;
|
||||
34
src/db/migrations/0032-add-polls.sql
Normal file
34
src/db/migrations/0032-add-polls.sql
Normal 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
19
src/db/orm-defs.d.ts
vendored
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user