diff --git a/keyserver/src/database/migration-config.js b/keyserver/src/database/migration-config.js --- a/keyserver/src/database/migration-config.js +++ b/keyserver/src/database/migration-config.js @@ -9,6 +9,7 @@ import { dbQuery, SQL } from '../database/database.js'; import { processMessagesInDBForSearch } from '../database/search-utils.js'; +import { deleteThread } from '../deleters/thread-deleters.js'; import { createScriptViewer } from '../session/scripts.js'; import { updateRolesAndPermissionsForAllThreads } from '../updaters/thread-permission-updaters.js'; import { updateThread } from '../updaters/thread-updaters.js'; @@ -514,6 +515,30 @@ `, ), ], + [ + 44, + async () => { + const { SIDEBAR_SOURCE, TOGGLE_PIN } = messageTypes; + const [result] = await dbQuery(SQL` + SELECT m1.thread + FROM messages m1 + LEFT JOIN messages m2 + ON m2.id = m1.target_message + WHERE m1.type = ${SIDEBAR_SOURCE} AND m2.type = ${TOGGLE_PIN} + `); + + const threadIDs = new Set(); + for (const row of result) { + threadIDs.add(row.thread.toString()); + } + + await Promise.all( + [...threadIDs].map(threadID => + deleteThread(botViewer, { threadID }, { ignorePermissions: true }), + ), + ); + }, + ], ]); const newDatabaseVersion: number = Math.max(...migrations.keys()); diff --git a/lib/types/thread-types.js b/lib/types/thread-types.js --- a/lib/types/thread-types.js +++ b/lib/types/thread-types.js @@ -242,7 +242,7 @@ export type ThreadDeletionRequest = { +threadID: string, - +accountPassword: ?string, + +accountPassword?: ?string, }; export type RemoveMembersRequest = {