Message content changes and message deletions are now tracked

This commit is contained in:
2025-06-29 09:28:03 -04:00
parent ac2dd9983e
commit c570f57463
6 changed files with 75 additions and 22 deletions

View File

@@ -11,17 +11,13 @@ export class SqliteDB implements SQLCommon {
async run(query: string): Promise<number> {
return new Promise((resolve, reject) => {
this.db.run(query, (result : sqlite3.RunResult, err: Error) => {
this.db.run(query, function (this : sqlite3.RunResult, err: Error) {
if (err) {
// TODO Winston should handle this
console.log(err)
throw err
} else {
if (result != null) {
resolve(result.changes)
} else {
resolve(0)
}
resolve(this.changes)
}
})
})
@@ -29,17 +25,13 @@ export class SqliteDB implements SQLCommon {
async runParameterized(query: string, parameters: any[]): Promise<number> {
return new Promise((resolve, reject) => {
this.db.run(query, parameters, (result : sqlite3.RunResult, err: Error) => {
this.db.run(query, parameters, function (this : sqlite3.RunResult, err: Error) {
if (err) {
// TODO Winston should handle this
console.log(err)
throw err
} else {
if (result != null) {
resolve(result.changes)
} else {
resolve(0)
}
resolve(this.changes)
}
})
})

View File

@@ -2,10 +2,10 @@ import { SQLCommon } from "./interfaces";
const tables: string[] = [
"CREATE TABLE IF NOT EXISTS servers (server_snowflake bigint NOT NULL PRIMARY KEY,server_name text NOT NULL,server_description mediumtext);",
"CREATE TABLE channels (channel_snowflake bigint NOT NULL PRIMARY KEY,server_snowflake bigint,channel_name text,is_thread bit NOT NULL,is_dm bit NOT NULL);",
"CREATE TABLE users (user_snowflake bigint NOT NULL PRIMARY KEY,user_name text NOT NULL,user_displayname text);",
"CREATE TABLE IF NOT EXISTS channels (channel_snowflake bigint NOT NULL PRIMARY KEY,server_snowflake bigint,channel_name text,is_thread bit NOT NULL,is_dm bit NOT NULL);",
"CREATE TABLE IF NOT EXISTS users (user_snowflake bigint NOT NULL PRIMARY KEY,user_name text NOT NULL,user_displayname text);",
"CREATE TABLE IF NOT EXISTS messages (message_snowflake bigint NOT NULL PRIMARY KEY,channel_snowflake bigint NOT NULL,user_snowflake bigint NOT NULL,message_content longtext NOT NULL,message_timestamp datetime NOT NULL,message_deleted bit NOT NULL);",
"CREATE TABLE IF NOT EXISTS message_content_changes (message_change_id bigint NOT NULL PRIMARY KEY,message_snowflake bigint NOT NULL,message_change_old_timestamp datetime NOT NULL,message_change_old_content longtext NOT NULL);",
"CREATE TABLE IF NOT EXISTS message_content_changes (message_change_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,message_snowflake bigint NOT NULL,message_change_old_timestamp datetime NOT NULL,message_change_old_content longtext NOT NULL);",
"CREATE TABLE IF NOT EXISTS message_attachments (attachment_snowflake bigint NOT NULL PRIMARY KEY,message_snowflake bigint NOT NULL,attachment_name text NOT NULL,attachment_description text,attachment_timestamp datetime NOT NULL,attachment_mime_type text,attachment_url text NOT NULL,attachment_downloaded bit NOT NULL);"
]