46 lines
1.5 KiB
JavaScript
46 lines
1.5 KiB
JavaScript
require("dotenv").config();
|
|
const axios = require("axios");
|
|
|
|
const outputKeyword = require("./output-keyword.json");
|
|
const outputBlurhash = require("./output-blurhash.json");
|
|
const outputFileNotes = require("./output-file_notes.json");
|
|
|
|
let noteIds = [
|
|
...(outputKeyword.map(i => i.id)),
|
|
...(outputFileNotes.map(i => i.id)),
|
|
];
|
|
noteIds = noteIds.filter((item, index) => noteIds.indexOf(item) == index); // Deduplicate
|
|
const fileIds = outputBlurhash.map(i => i.id);
|
|
|
|
(async () => {
|
|
console.log("Deleting notes");
|
|
let res = await Promise.allSettled(noteIds.map(id =>
|
|
axios.post(
|
|
"https://lea.pet/api/notes/delete",
|
|
JSON.stringify({ noteId: id }),
|
|
{
|
|
headers: {
|
|
"content-type": "application/json",
|
|
Authorization: `Bearer ${process.env.API_TOKEN}`
|
|
},
|
|
},
|
|
)
|
|
));
|
|
console.log(`Done, ${res.filter((r) => r.status == "rejected").length} errors`);
|
|
|
|
console.log("Deleting files");
|
|
res = await Promise.allSettled(fileIds.map(id =>
|
|
axios.post(
|
|
"https://lea.pet/api/drive/files/delete",
|
|
JSON.stringify({ fileId: id }),
|
|
{
|
|
headers: {
|
|
"content-type": "application/json",
|
|
Authorization: `Bearer ${process.env.API_TOKEN}`
|
|
},
|
|
},
|
|
)
|
|
));
|
|
console.log(`Done, ${res.filter((r) => r.status == "rejected").length} errors`);
|
|
})();
|