fix: skip attachment import if undefined

This commit is contained in:
DVD 2023-07-19 09:45:00 -07:00 committed by ThatOneCalculator
parent 91033ab90a
commit 6e296320e0
No known key found for this signature in database
GPG key ID: 8703CACD01000000

View file

@ -44,6 +44,13 @@ function processMastoFile(fn: string, path: string, dir: string, uid: string) {
logger.info(`Unzip to ${dir}`); logger.info(`Unzip to ${dir}`);
const outbox = JSON.parse(fs.readFileSync(`${dir}/outbox.json`)); const outbox = JSON.parse(fs.readFileSync(`${dir}/outbox.json`));
for (const note of outbox.orderedItems) { 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) { for (const attachment of note.object.attachment) {
const url = attachment.url.replaceAll("..", ""); const url = attachment.url.replaceAll("..", "");
if (url.indexOf("\0") !== -1) { if (url.indexOf("\0") !== -1) {