Add consent-gated media exchange library
This commit is contained in:
1 parent
b8e4a1bb88
commit
bf474dfe10
42 files changed
+2533
-9
No files matched your search
@@ -364,6 +364,54 @@ export function runMigrations(db: Database.Database): void {
|
||||
CREATE INDEX idx_conversation_automation_claims_status
|
||||
ON conversation_automation_claims(account_id, status, claimed_at);
|
||||
`),
|
||||
() => db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS media_library_assets (
|
||||
asset_id TEXT PRIMARY KEY,
|
||||
tags_json TEXT NOT NULL,
|
||||
safety TEXT NOT NULL CHECK(safety IN ('sfw', 'nsfw', 'unknown')),
|
||||
classification_status TEXT NOT NULL CHECK(classification_status IN ('ready', 'failed')),
|
||||
description TEXT,
|
||||
confidence REAL,
|
||||
file_name TEXT NOT NULL,
|
||||
relative_path TEXT NOT NULL UNIQUE,
|
||||
mime_type TEXT NOT NULL,
|
||||
size_bytes INTEGER NOT NULL,
|
||||
width INTEGER NOT NULL,
|
||||
height INTEGER NOT NULL,
|
||||
sha256 TEXT NOT NULL UNIQUE,
|
||||
enabled INTEGER NOT NULL DEFAULT 0 CHECK(enabled IN (0, 1)),
|
||||
consent_confirmed_at INTEGER NOT NULL,
|
||||
created_at INTEGER NOT NULL,
|
||||
updated_at INTEGER NOT NULL,
|
||||
deleted_at INTEGER
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_media_library_assets_enabled
|
||||
ON media_library_assets(enabled, classification_status, created_at DESC);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS media_library_sends (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
asset_id TEXT NOT NULL,
|
||||
asset_sha256 TEXT NOT NULL,
|
||||
account_id TEXT NOT NULL,
|
||||
conversation_id TEXT NOT NULL,
|
||||
incoming_key TEXT NOT NULL,
|
||||
request_kind TEXT NOT NULL CHECK(request_kind IN ('generic', 'penis', 'chest', 'selfie', 'topless', 'feet')),
|
||||
status TEXT NOT NULL CHECK(status IN ('pending', 'sent', 'failed', 'superseded')),
|
||||
requested_at INTEGER NOT NULL,
|
||||
sent_at INTEGER,
|
||||
matrix_media_event_id TEXT,
|
||||
matrix_text_event_id TEXT,
|
||||
mxc_uri TEXT,
|
||||
error TEXT,
|
||||
UNIQUE(account_id, conversation_id, incoming_key),
|
||||
UNIQUE(account_id, conversation_id, asset_id),
|
||||
UNIQUE(account_id, conversation_id, asset_sha256),
|
||||
FOREIGN KEY (asset_id) REFERENCES media_library_assets(asset_id),
|
||||
FOREIGN KEY (account_id) REFERENCES reddit_accounts(account_id) ON DELETE CASCADE
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_media_library_sends_conversation
|
||||
ON media_library_sends(account_id, conversation_id, requested_at);
|
||||
`),
|
||||
];
|
||||
|
||||
let currentVersion = db.pragma('user_version', { simple: true }) as number;
|
||||
|
||||
Reference in new issue
Block a user