fix: broken unicode in strings on IG imports

This commit is contained in:
Mar0xy 2023-11-12 18:12:39 +01:00
parent 486a2ad839
commit 8cad8f0ae5
No known key found for this signature in database
GPG Key ID: 56569BBE47D2C828
1 changed files with 2 additions and 2 deletions

View File

@ -366,7 +366,7 @@ export class ImportNotesProcessorService {
if (post.media && this.isIterable(post.media) && post.media.length > 1) {
date = new Date(post.creation_timestamp * 1000);
title = post.title;
title = post.title.encode('latin-1').decode('utf-8');
for await (const file of post.media) {
const slashdex = file.uri.lastIndexOf('/');
const name = file.uri.substring(slashdex + 1);
@ -377,7 +377,7 @@ export class ImportNotesProcessorService {
}
} else if (post.media && this.isIterable(post.media) && !(post.media.length > 1)) {
date = new Date(post.media[0].creation_timestamp * 1000);
title = post.media[0].title;
title = post.media[0].title.encode('latin-1').decode('utf-8');
const slashdex = post.media[0].uri.lastIndexOf('/');
const name = post.media[0].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 });