diff options
| author | Mar0xy <marie@kaifa.ch> | 2023-11-22 19:02:43 +0100 |
|---|---|---|
| committer | Mar0xy <marie@kaifa.ch> | 2023-11-22 19:02:43 +0100 |
| commit | 81c36908d9ca03037c3847d0a350437dea087e8e (patch) | |
| tree | f861e06598675932c6fa4124b12fc41759107e74 /packages/backend/src/queue/processors | |
| parent | upd: add `Facebook` to note importing (diff) | |
| download | sharkey-81c36908d9ca03037c3847d0a350437dea087e8e.tar.gz sharkey-81c36908d9ca03037c3847d0a350437dea087e8e.tar.bz2 sharkey-81c36908d9ca03037c3847d0a350437dea087e8e.zip | |
fix: attachments not working on FB import
Diffstat (limited to 'packages/backend/src/queue/processors')
| -rw-r--r-- | packages/backend/src/queue/processors/ImportNotesProcessorService.ts | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/packages/backend/src/queue/processors/ImportNotesProcessorService.ts b/packages/backend/src/queue/processors/ImportNotesProcessorService.ts index a3d7915b96..5c3578010f 100644 --- a/packages/backend/src/queue/processors/ImportNotesProcessorService.ts +++ b/packages/backend/src/queue/processors/ImportNotesProcessorService.ts @@ -569,7 +569,7 @@ export class ImportNotesProcessorService { return; } - if (!this.isIterable(post.data) || !post.data[0].post) return; + if (!this.isIterable(post.data) || this.isIterable(post.data) && post.data[0].post === undefined) return; const date = new Date(post.timestamp * 1000); const title = decodeFBString(post.data[0].post); @@ -583,12 +583,18 @@ export class ImportNotesProcessorService { return Buffer.from(arr).toString('utf8'); } - if (post.attachments && this.isIterable(post.attachments) && this.isIterable(post.attachments.data)) { - for await (const file of post.attachments.data) { - if (!file.media) return; - const slashdex = file.media.uri.lastIndexOf('/'); - const name = file.media.uri.substring(slashdex + 1); - const exists = await this.driveFilesRepository.findOneBy({ name: name, userId: user.id }) ?? await this.driveFilesRepository.findOneBy({ name: `${name}.jpg`, userId: user.id }) ?? await this.driveFilesRepository.findOneBy({ name: `${name}.mp4`, userId: user.id }); + if (post.attachments && this.isIterable(post.attachments)) { + const media = []; + for await (const data of post.attachments[0].data) { + if (data.media) { + media.push(data.media); + } + } + + for await (const file of media) { + const slashdex = file.uri.lastIndexOf('/'); + const name = file.uri.substring(slashdex + 1); + const exists = await this.driveFilesRepository.findOneBy({ name: name, userId: user.id }); if (exists) { files.push(exists); } |