import { deleteAccount } from "./delete-account.js";
import { deleteDriveFiles } from "./delete-drive-files.js";
import { exportBlocking } from "./export-blocking.js";
import { exportCustomEmojis } from "./export-custom-emojis.js";
import { exportFollowing } from "./export-following.js";
import { exportMute } from "./export-mute.js";
import { exportNotes } from "./export-notes.js";
import { exportUserLists } from "./export-user-lists.js";
import { importBlocking } from "./import-blocking.js";
import { importCustomEmojis } from "./import-custom-emojis.js";
import { importFollowing } from "./import-following.js";
import { importMuting } from "./import-muting.js";
import { importUserLists } from "./import-user-lists.js";
import { createQueue, defaultJobOpts } from "../index.js";
import config from "../../../config/index.js";
const processors = {
    deleteAccount,
    deleteDriveFiles,
    exportBlocking,
    exportCustomEmojis,
    exportFollowing,
    exportMute,
    exportNotes,
    exportUserLists,
    importBlocking,
    importCustomEmojis,
    importFollowing,
    importMuting,
    importUserLists
};
async function process(job) {
    const processor = processors[job.name];
    if (processor === undefined) return "skip: unknown job name";
    return await processor(job);
}
export const [dbQueue, dbInit] = createQueue("db", process, {
    limitPerSec: 256,
    concurrency: 16
});
export function createDeleteDriveFilesJob(user) {
    return dbQueue.add("deleteDriveFiles", {
        user: user
    }, defaultJobOpts);
}
export function createExportCustomEmojisJob(user) {
    return dbQueue.add("exportCustomEmojis", {
        user: user
    }, defaultJobOpts);
}
export function createExportNotesJob(user) {
    return dbQueue.add("exportNotes", {
        user: user
    }, defaultJobOpts);
}
export function createExportFollowingJob(user, excludeMuting = false, excludeInactive = false) {
    return dbQueue.add("exportFollowing", {
        user: user,
        excludeMuting,
        excludeInactive
    }, defaultJobOpts);
}
export function createExportMuteJob(user) {
    return dbQueue.add("exportMute", {
        user: user
    }, defaultJobOpts);
}
export function createExportBlockingJob(user) {
    return dbQueue.add("exportBlocking", {
        user: user
    }, defaultJobOpts);
}
export function createExportUserListsJob(user) {
    return dbQueue.add("exportUserLists", {
        user: user
    }, defaultJobOpts);
}
export function createImportFollowingJob(user, fileId) {
    return dbQueue.add("importFollowing", {
        user: user,
        fileId: fileId
    }, defaultJobOpts);
}
export function createImportMastoPostJob(user, post, signatureCheck) {
    return dbQueue.add("importMastoPost", {
        user: user,
        post: post,
        signatureCheck: signatureCheck
    }, {
        attempts: config.inboxJobMaxAttempts || 8,
        ...defaultJobOpts
    });
}
export function createImportCkPostJob(user, post, signatureCheck) {
    return dbQueue.add("importCkPost", {
        user: user,
        post: post,
        signatureCheck: signatureCheck
    }, defaultJobOpts);
}
export function createImportMutingJob(user, fileId) {
    return dbQueue.add("importMuting", {
        user: user,
        fileId: fileId
    }, defaultJobOpts);
}
export function createImportBlockingJob(user, fileId) {
    return dbQueue.add("importBlocking", {
        user: user,
        fileId: fileId
    }, defaultJobOpts);
}
export function createImportUserListsJob(user, fileId) {
    return dbQueue.add("importUserLists", {
        user: user,
        fileId: fileId
    }, defaultJobOpts);
}
export function createImportCustomEmojisJob(user, fileId) {
    return dbQueue.add("importCustomEmojis", {
        user: user,
        fileId: fileId
    }, defaultJobOpts);
}
export function createDeleteAccountJob(user, opts = {}) {
    return dbQueue.add("deleteAccount", {
        user: user,
        soft: opts.soft
    }, defaultJobOpts);
}
