fix: skip attachment import if undefined

This commit is contained in:
DVD 2023-07-19 09:45:00 -07:00 committed by ThatOneCalculator
parent 24f636170e
commit 13265e6652

View File

@ -44,6 +44,13 @@ function processMastoFile(fn: string, path: string, dir: string, uid: string) {
logger.info(`Unzip to ${dir}`);
const outbox = JSON.parse(fs.readFileSync(`${dir}/outbox.json`));
for (const note of outbox.orderedItems) {
// Skip if attachment is undefined or not iterable
if (
note.object.attachment == null ||
!note.object.attachment[Symbol.iterator]
) {
continue;
}
for (const attachment of note.object.attachment) {
const url = attachment.url.replaceAll("..", "");
if (url.indexOf("\0") !== -1) {