mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-26 20:03:10 +02:00
fix: attachments not working on FB import
This commit is contained in:
parent
d078a72f38
commit
81c36908d9
1 changed files with 13 additions and 7 deletions
|
@ -569,7 +569,7 @@ export class ImportNotesProcessorService {
|
||||||
return;
|
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 date = new Date(post.timestamp * 1000);
|
||||||
const title = decodeFBString(post.data[0].post);
|
const title = decodeFBString(post.data[0].post);
|
||||||
|
@ -583,12 +583,18 @@ export class ImportNotesProcessorService {
|
||||||
return Buffer.from(arr).toString('utf8');
|
return Buffer.from(arr).toString('utf8');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (post.attachments && this.isIterable(post.attachments) && this.isIterable(post.attachments.data)) {
|
if (post.attachments && this.isIterable(post.attachments)) {
|
||||||
for await (const file of post.attachments.data) {
|
const media = [];
|
||||||
if (!file.media) return;
|
for await (const data of post.attachments[0].data) {
|
||||||
const slashdex = file.media.uri.lastIndexOf('/');
|
if (data.media) {
|
||||||
const name = file.media.uri.substring(slashdex + 1);
|
media.push(data.media);
|
||||||
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 });
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
if (exists) {
|
||||||
files.push(exists);
|
files.push(exists);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue