Skip to content

Commit

Permalink
Update post.service.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
RiXelanya committed Mar 23, 2024
1 parent 6c83e79 commit 396ab8c
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/services/post.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ export class PostService {
try {

Check failure on line 296 in src/services/post.service.ts

View workflow job for this annotation

GitHub Actions / Test on Node.js 16 ( lint:check )

Unnecessary try/catch wrapper
if (!validateURL(url)) throw new Error('InvalidURL');
embeddedURL = await getOpenGraph(url);
} catch {
} catch (error) {
throw error
// ignore
}

Expand Down Expand Up @@ -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);

Check failure

Code scanning / CodeQL

Incomplete regular expression for hostnames High

This regular expression has an unescaped '.' before 'googleapis.com', so it might match more hosts than expected.
This regular expression has an unescaped '.' before 'appspot.com', so it might match more hosts than expected.
if (found) {
const index: number = draftPost.text.indexOf(found[0]);

Expand All @@ -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
}

Expand Down Expand Up @@ -747,13 +749,16 @@ export class PostService {
}

private async getVisibility(userId: string, timelineIds = [] as string[]) {
const timelineUser = this.experienceRepository.find({
try {

Check failure on line 752 in src/services/post.service.ts

View workflow job for this annotation

GitHub Actions / Test on Node.js 16 ( lint:check )

Unnecessary try/catch wrapper

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},
Expand All @@ -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');
Expand Down Expand Up @@ -844,6 +850,9 @@ export class PostService {
visibility,
selectedUserIds,
};
} catch (error) {
throw error
}
}

private getImportedTags(
Expand Down

0 comments on commit 396ab8c

Please sign in to comment.