From 396ab8c1ab2c65c0b1026eb39d5507126d57112e Mon Sep 17 00:00:00 2001 From: RXRD Date: Sat, 23 Mar 2024 20:30:59 +0700 Subject: [PATCH] Update post.service.ts --- src/services/post.service.ts | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/services/post.service.ts b/src/services/post.service.ts index 9734e3f81..11a311c6e 100644 --- a/src/services/post.service.ts +++ b/src/services/post.service.ts @@ -296,7 +296,8 @@ export class PostService { try { if (!validateURL(url)) throw new Error('InvalidURL'); embeddedURL = await getOpenGraph(url); - } catch { + } catch (error) { + throw error // ignore } @@ -402,7 +403,7 @@ export class PostService { let embeddedURL = null; if (draftPost.text) { - const found = draftPost.text.match(/https:\/\/|http:\/\/|www./g); + const found = draftPost.text.match(/https:\/\/(?!storage.googleapis.com\/myriad-social-testnet.appspot.com)|http:\/\/|www./g); if (found) { const index: number = draftPost.text.indexOf(found[0]); @@ -417,7 +418,8 @@ export class PostService { try { if (!validateURL(url)) throw new Error('InvalidURL'); embeddedURL = await getOpenGraph(url); - } catch { + } catch (error) { + console.error(error) // ignore } @@ -747,13 +749,16 @@ export class PostService { } private async getVisibility(userId: string, timelineIds = [] as string[]) { - const timelineUser = this.experienceRepository.find({ + try { + + const timelineUser = await this.experienceRepository.find({ where: { id: {inq: timelineIds}, createdBy: userId, }, }); - const editable = this.experienceEditorRepository + console.log("timelineUser is", timelineUser) + const editable = await this.experienceEditorRepository .find({ where: { experienceId: {inq: timelineIds}, @@ -768,9 +773,10 @@ export class PostService { }, }); }); - const timelines = await Promise.all([timelineUser, editable]).then(res => { - return [...res[0], ...res[1]]; - }); + const timelines = [...timelineUser, ...editable]; + // const timelines = await Promise.all([timelineUser, editable]).then(res => { + // return [...res[0], ...res[1]]; + // }); if (timelines.length <= 0) { throw new HttpErrors.UnprocessableEntity('TimelineNotFound'); @@ -844,6 +850,9 @@ export class PostService { visibility, selectedUserIds, }; + } catch (error) { + throw error + } } private getImportedTags(