forked from FoundKeyGang/FoundKey
backend: allow to export only specific emoji
This commit is contained in:
parent
7ea6deb19b
commit
cb0b14ba2d
3 changed files with 14 additions and 4 deletions
|
@ -131,9 +131,10 @@ export function createDeleteDriveFilesJob(user: ThinUser) {
|
|||
});
|
||||
}
|
||||
|
||||
export function createExportCustomEmojisJob(user: ThinUser) {
|
||||
export function createExportCustomEmojisJob(user: ThinUser, ids: string[] | undefined) {
|
||||
return dbQueue.add('exportCustomEmojis', {
|
||||
user,
|
||||
ids,
|
||||
}, {
|
||||
removeOnComplete: true,
|
||||
removeOnFail: true,
|
||||
|
|
|
@ -3,7 +3,7 @@ import archiver from 'archiver';
|
|||
import Bull from 'bull';
|
||||
import { format as dateFormat } from 'date-fns';
|
||||
import mime from 'mime-types';
|
||||
import { IsNull } from 'typeorm';
|
||||
import { In, IsNull } from 'typeorm';
|
||||
import config from '@/config/index.js';
|
||||
import { createTemp, createTempDir } from '@/misc/create-temp.js';
|
||||
import { downloadUrl } from '@/misc/download-url.js';
|
||||
|
@ -50,6 +50,7 @@ export async function exportCustomEmojis(job: Bull.Job, done: () => void): Promi
|
|||
const customEmojis = await Emojis.find({
|
||||
where: {
|
||||
host: IsNull(),
|
||||
...(job.data.ids ? { id: In(job.data.ids) } : {}),
|
||||
},
|
||||
order: {
|
||||
id: 'ASC',
|
||||
|
|
|
@ -13,11 +13,19 @@ export const meta = {
|
|||
|
||||
export const paramDef = {
|
||||
type: 'object',
|
||||
properties: {},
|
||||
properties: {
|
||||
ids: {
|
||||
description: 'Specific emoji IDs to be exported. Non-local emoji will be ignored. If not provided, all local emoji will be exported.',
|
||||
type: 'array',
|
||||
items: { type: 'string' },
|
||||
minItems: 1,
|
||||
uniqueItems: true,
|
||||
},
|
||||
},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
createExportCustomEmojisJob(user);
|
||||
createExportCustomEmojisJob(user, ps.ids);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue