Fix null notifications

This commit is contained in:
Natsumi
2023-04-12 08:46:28 +12:00
parent fc14cb8097
commit 5fc38f4e65
2 changed files with 12 additions and 1 deletions

View File

@@ -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',

View File

@@ -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) => {