nyaa
This commit is contained in:
parent
00dc860574
commit
09aeb6e2f5
|
@ -317,12 +317,14 @@ export function createImportFollowingJob(
|
||||||
export function createImportPostsJob(
|
export function createImportPostsJob(
|
||||||
user: ThinUser,
|
user: ThinUser,
|
||||||
fileId: DriveFile["id"],
|
fileId: DriveFile["id"],
|
||||||
|
signatureCheck: boolean,
|
||||||
) {
|
) {
|
||||||
return dbQueue.add(
|
return dbQueue.add(
|
||||||
"importPosts",
|
"importPosts",
|
||||||
{
|
{
|
||||||
user: user,
|
user: user,
|
||||||
fileId: fileId,
|
fileId: fileId,
|
||||||
|
signatureCheck: signatureCheck,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
removeOnComplete: true,
|
removeOnComplete: true,
|
||||||
|
|
|
@ -5,7 +5,7 @@ import * as Post from "@/misc/post.js";
|
||||||
import create from "@/services/note/create.js";
|
import create from "@/services/note/create.js";
|
||||||
import { downloadTextFile } from "@/misc/download-text-file.js";
|
import { downloadTextFile } from "@/misc/download-text-file.js";
|
||||||
import { Users, DriveFiles } from "@/models/index.js";
|
import { Users, DriveFiles } from "@/models/index.js";
|
||||||
import type { DbUserImportJobData } from "@/queue/types.js";
|
import type { DbUserImportPostsJobData } from "@/queue/types.js";
|
||||||
import { queueLogger } from "../../logger.js";
|
import { queueLogger } from "../../logger.js";
|
||||||
import type Bull from "bull";
|
import type Bull from "bull";
|
||||||
import { htmlToMfm } from "@/remote/activitypub/misc/html-to-mfm.js";
|
import { htmlToMfm } from "@/remote/activitypub/misc/html-to-mfm.js";
|
||||||
|
@ -13,7 +13,7 @@ import { htmlToMfm } from "@/remote/activitypub/misc/html-to-mfm.js";
|
||||||
const logger = queueLogger.createSubLogger("import-posts");
|
const logger = queueLogger.createSubLogger("import-posts");
|
||||||
|
|
||||||
export async function importPosts(
|
export async function importPosts(
|
||||||
job: Bull.Job<DbUserImportJobData>,
|
job: Bull.Job<DbUserImportPostsJobData>,
|
||||||
done: any,
|
done: any,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
logger.info(`Importing posts of ${job.data.user.id} ...`);
|
logger.info(`Importing posts of ${job.data.user.id} ...`);
|
||||||
|
|
|
@ -21,6 +21,7 @@ export type InboxJobData = {
|
||||||
|
|
||||||
export type DbJobData =
|
export type DbJobData =
|
||||||
| DbUserJobData
|
| DbUserJobData
|
||||||
|
| DbUserImportPostsJobData
|
||||||
| DbUserImportJobData
|
| DbUserImportJobData
|
||||||
| DbUserDeleteJobData;
|
| DbUserDeleteJobData;
|
||||||
|
|
||||||
|
@ -40,6 +41,12 @@ export type DbUserImportJobData = {
|
||||||
fileId: DriveFile["id"];
|
fileId: DriveFile["id"];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type DbUserImportPostsJobData = {
|
||||||
|
user: ThinUser;
|
||||||
|
fileId: DriveFile["id"];
|
||||||
|
signatureCheck: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
export type ObjectStorageJobData =
|
export type ObjectStorageJobData =
|
||||||
| ObjectStorageFileJobData
|
| ObjectStorageFileJobData
|
||||||
| Record<string, unknown>;
|
| Record<string, unknown>;
|
||||||
|
|
|
@ -30,6 +30,7 @@ export const paramDef = {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: {
|
properties: {
|
||||||
fileId: { type: "string", format: "misskey:id" },
|
fileId: { type: "string", format: "misskey:id" },
|
||||||
|
signatureCheck: { type: "boolean" },
|
||||||
},
|
},
|
||||||
required: ["fileId"],
|
required: ["fileId"],
|
||||||
} as const;
|
} as const;
|
||||||
|
@ -39,5 +40,5 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
|
|
||||||
if (file == null) throw new ApiError(meta.errors.noSuchFile);
|
if (file == null) throw new ApiError(meta.errors.noSuchFile);
|
||||||
if (file.size === 0) throw new ApiError(meta.errors.emptyFile);
|
if (file.size === 0) throw new ApiError(meta.errors.emptyFile);
|
||||||
createImportPostsJob(user, file.id);
|
createImportPostsJob(user, file.id, ps.signatureCheck);
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
<FormFolder class="_formBlock">
|
<FormFolder class="_formBlock">
|
||||||
<template #label>{{ i18n.ts.import }}</template>
|
<template #label>{{ i18n.ts.import }}</template>
|
||||||
<template #icon><i class="ph-upload-simple ph-bold ph-lg"></i></template>
|
<template #icon><i class="ph-upload-simple ph-bold ph-lg"></i></template>
|
||||||
|
<FormSwitch v-model="signatureCheck" class="_formBlock">
|
||||||
|
Mastodon import?
|
||||||
|
</FormSwitch>
|
||||||
<MkButton primary :class="$style.button" inline @click="importPosts($event)"><i class="ph-upload-simple ph-bold ph-lg"></i> {{ i18n.ts.import }}</MkButton>
|
<MkButton primary :class="$style.button" inline @click="importPosts($event)"><i class="ph-upload-simple ph-bold ph-lg"></i> {{ i18n.ts.import }}</MkButton>
|
||||||
</FormFolder>
|
</FormFolder>
|
||||||
</FormSection>
|
</FormSection>
|
||||||
|
@ -86,6 +89,7 @@ import { i18n } from '@/i18n';
|
||||||
import { definePageMetadata } from '@/scripts/page-metadata';
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
||||||
|
|
||||||
const excludeMutingUsers = ref(false);
|
const excludeMutingUsers = ref(false);
|
||||||
|
const signatureCheck = ref(false);
|
||||||
const excludeInactiveUsers = ref(false);
|
const excludeInactiveUsers = ref(false);
|
||||||
|
|
||||||
const onExportSuccess = () => {
|
const onExportSuccess = () => {
|
||||||
|
@ -115,7 +119,7 @@ const exportNotes = () => {
|
||||||
|
|
||||||
const importPosts = async (ev) => {
|
const importPosts = async (ev) => {
|
||||||
const file = await selectFile(ev.currentTarget ?? ev.target);
|
const file = await selectFile(ev.currentTarget ?? ev.target);
|
||||||
os.api('i/import-posts', { fileId: file.id }).then(onImportSuccess).catch(onError);
|
os.api('i/import-posts', { fileId: file.id, signatureCheck: signatureCheck }).then(onImportSuccess).catch(onError);
|
||||||
};
|
};
|
||||||
|
|
||||||
const exportFollowing = () => {
|
const exportFollowing = () => {
|
||||||
|
|
Loading…
Reference in New Issue