Merge pull request 'Delete deleted posts from Meilisearch' (#10223) from PrivateGER/calckey:feat/delete-posts-from-meili into develop
Reviewed-on: https://codeberg.org/calckey/calckey/pulls/10223
This commit is contained in:
commit
8d81e4f5ee
@ -264,5 +264,29 @@ export default hasConfig
|
|||||||
indexed_count: stats.indexes["posts"].numberOfDocuments,
|
indexed_count: stats.indexes["posts"].numberOfDocuments,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
deleteNotes: async (note: Note | Note[] | string | string[]) => {
|
||||||
|
if (note instanceof Note) {
|
||||||
|
note = [note];
|
||||||
|
}
|
||||||
|
if (typeof note === "string") {
|
||||||
|
note = [note];
|
||||||
|
}
|
||||||
|
|
||||||
|
let deletionBatch = note.map((n) => {
|
||||||
|
if(n instanceof Note) {
|
||||||
|
return n.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(n.length > 0) return n;
|
||||||
|
|
||||||
|
logger.error(`Failed to delete note from Meilisearch, invalid post ID: ${JSON.stringify(n)}`)
|
||||||
|
|
||||||
|
throw new Error(`Invalid note ID passed to meilisearch deleteNote: ${JSON.stringify(n)}`)
|
||||||
|
}).filter((el) => el !== null);
|
||||||
|
|
||||||
|
await posts.deleteDocuments(deletionBatch as string[]).then(() => {
|
||||||
|
logger.info(`submitted ${deletionBatch.length} large batch for deletion`)
|
||||||
|
});
|
||||||
|
},
|
||||||
}
|
}
|
||||||
: null;
|
: null;
|
||||||
|
@ -7,6 +7,7 @@ import type { DriveFile } from "@/models/entities/drive-file.js";
|
|||||||
import { MoreThan } from "typeorm";
|
import { MoreThan } from "typeorm";
|
||||||
import { deleteFileSync } from "@/services/drive/delete-file.js";
|
import { deleteFileSync } from "@/services/drive/delete-file.js";
|
||||||
import { sendEmail } from "@/services/send-email.js";
|
import { sendEmail } from "@/services/send-email.js";
|
||||||
|
import meilisearch from "@/db/meilisearch.js";
|
||||||
|
|
||||||
const logger = queueLogger.createSubLogger("delete-account");
|
const logger = queueLogger.createSubLogger("delete-account");
|
||||||
|
|
||||||
@ -43,6 +44,9 @@ export async function deleteAccount(
|
|||||||
cursor = notes[notes.length - 1].id;
|
cursor = notes[notes.length - 1].id;
|
||||||
|
|
||||||
await Notes.delete(notes.map((note) => note.id));
|
await Notes.delete(notes.map((note) => note.id));
|
||||||
|
if (meilisearch) {
|
||||||
|
await meilisearch.deleteNotes(notes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.succ("All of notes deleted");
|
logger.succ("All of notes deleted");
|
||||||
|
@ -21,6 +21,7 @@ import {
|
|||||||
import { countSameRenotes } from "@/misc/count-same-renotes.js";
|
import { countSameRenotes } from "@/misc/count-same-renotes.js";
|
||||||
import { registerOrFetchInstanceDoc } from "../register-or-fetch-instance-doc.js";
|
import { registerOrFetchInstanceDoc } from "../register-or-fetch-instance-doc.js";
|
||||||
import { deliverToRelays } from "../relay.js";
|
import { deliverToRelays } from "../relay.js";
|
||||||
|
import meilisearch from "@/db/meilisearch.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 投稿を削除します。
|
* 投稿を削除します。
|
||||||
@ -119,6 +120,10 @@ export default async function (
|
|||||||
id: note.id,
|
id: note.id,
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(meilisearch) {
|
||||||
|
await meilisearch.deleteNotes(note.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function findCascadingNotes(note: Note) {
|
async function findCascadingNotes(note: Note) {
|
||||||
|
Loading…
Reference in New Issue
Block a user