mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-30 15:15:24 +00:00
feat: convert file manager into a plugin
This commit is contained in:
1 parent
b76da9ab52
commit
c85c1fdb86
259 files changed
+54155
-16791
No files matched your search
@@ -1,13 +1,35 @@
|
||||
import { sql } from "drizzle-orm";
|
||||
import {
|
||||
createCurrentDismissedAlertRepository,
|
||||
createCurrentFileManagerBookmarkRepository,
|
||||
createCurrentTransferRecentRepository,
|
||||
createCurrentUserDataExportRepository,
|
||||
createCurrentUserRepository,
|
||||
} from "../database/repositories/factory.js";
|
||||
import { getDb } from "../database/db/index.js";
|
||||
import { DataCrypto } from "./data-crypto.js";
|
||||
import { databaseLogger } from "./logger.js";
|
||||
|
||||
// The file manager plugin owns these tables now (p_file_manager_*); read by
|
||||
// raw SQL rather than importing plugin code into core.
|
||||
async function listFileManagerExportData(userId: string): Promise<{
|
||||
recent: unknown[];
|
||||
pinned: unknown[];
|
||||
shortcuts: unknown[];
|
||||
transferRecent: unknown[];
|
||||
}> {
|
||||
const db = getDb();
|
||||
const [recent, pinned, shortcuts, transferRecent] = await Promise.all([
|
||||
db.all(sql`SELECT * FROM p_file_manager_recent WHERE user_id = ${userId}`),
|
||||
db.all(sql`SELECT * FROM p_file_manager_pinned WHERE user_id = ${userId}`),
|
||||
db.all(
|
||||
sql`SELECT * FROM p_file_manager_shortcuts WHERE user_id = ${userId}`,
|
||||
),
|
||||
db.all(
|
||||
sql`SELECT * FROM p_file_manager_transfer_recent WHERE user_id = ${userId}`,
|
||||
),
|
||||
]);
|
||||
return { recent, pinned, shortcuts, transferRecent };
|
||||
}
|
||||
|
||||
interface UserExportData {
|
||||
version: string;
|
||||
exportedAt: string;
|
||||
@@ -90,19 +112,12 @@ class UserDataExport {
|
||||
: credentials;
|
||||
}
|
||||
|
||||
const [recentFiles, pinnedFiles, shortcuts, transferRecentData] =
|
||||
await Promise.all([
|
||||
createCurrentFileManagerBookmarkRepository().listRecentByUserId(
|
||||
userId,
|
||||
),
|
||||
createCurrentFileManagerBookmarkRepository().listPinnedByUserId(
|
||||
userId,
|
||||
),
|
||||
createCurrentFileManagerBookmarkRepository().listShortcutsByUserId(
|
||||
userId,
|
||||
),
|
||||
createCurrentTransferRecentRepository().listByUserId(userId),
|
||||
]);
|
||||
const {
|
||||
recent: recentFiles,
|
||||
pinned: pinnedFiles,
|
||||
shortcuts,
|
||||
transferRecent: transferRecentData,
|
||||
} = await listFileManagerExportData(userId);
|
||||
|
||||
const alerts =
|
||||
await createCurrentDismissedAlertRepository().listByUserId(userId);
|
||||
|
||||
Reference in new issue
Block a user