diff --git a/html/src/app.js b/html/src/app.js index 83726a94..ef21d32f 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -22600,7 +22600,7 @@ speechSynthesis.getVoices(); $app.data.databaseVersion = configRepository.getInt('VRCX_databaseVersion'); $app.methods.updateDatabaseVersion = async function () { - var databaseVersion = 4; + var databaseVersion = 5; if (this.databaseVersion !== databaseVersion) { var msgBox = this.$message({ message: 'DO NOT CLOSE VRCX, database upgrade in process...', @@ -22617,6 +22617,7 @@ speechSynthesis.getVoices(); await database.fixBrokenLeaveEntries(); // fix user instance timer being higher than current user location timer await database.fixBrokenGroupInvites(); // fix notification v2 in wrong table await database.updateTableForGroupNames(); // alter tables to include group name + database.fixBrokenNotifications(); // fix notifications being null this.databaseVersion = databaseVersion; configRepository.setInt( 'VRCX_databaseVersion', diff --git a/html/src/repository/database.js b/html/src/repository/database.js index 5b60316d..144abcf4 100644 --- a/html/src/repository/database.js +++ b/html/src/repository/database.js @@ -709,6 +709,10 @@ class Database { if (row.$isExpired) { expired = 1; } + if (!entry.created_at || !entry.type || !entry.id) { + console.error('Notification is missing required field', entry); + throw new Error('Notification is missing required field'); + } sqliteService.executeNonQuery( `INSERT OR IGNORE INTO ${Database.userPrefix}_notifications (id, created_at, type, sender_user_id, sender_username, receiver_user_id, message, world_id, world_name, image_url, invite_message, request_message, response_message, expired) VALUES (@id, @created_at, @type, @sender_user_id, @sender_username, @receiver_user_id, @message, @world_id, @world_name, @image_url, @invite_message, @request_message, @response_message, @expired)`, { @@ -1951,6 +1955,12 @@ class Database { }); } + fixBrokenNotifications() { + sqliteService.executeNonQuery( + `DELETE FROM ${Database.userPrefix}_notifications WHERE (created_at is null or created_at = '')` + ); + } + async updateTableForGroupNames() { var tables = []; await sqliteService.execute((dbRow) => {