Skip to content

Commit

Permalink
Add toString for id comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Dec 19, 2023
1 parent 599b330 commit c70c0bb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/api/db/models/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ export class ImageModel {
try {
const image = await ImageModel.queryById(input.imageId, context);

const comment = (image.comments || []).filter((c) => { return c._id === input.id; })[0];
const comment = (image.comments || []).filter((c) => { return c._id.toString() === input.id.toString(); })[0];
if (!comment) throw new Error('Comment not found on image');

if (comment.author !== context.user['cognito:username'] && !context.user['is_superuser']) {
Expand All @@ -349,7 +349,7 @@ export class ImageModel {
try {
const image = await ImageModel.queryById(input.imageId, context);

const comment = (image.comments || []).filter((c) => { return c._id === input.id; })[0];
const comment = (image.comments || []).filter((c) => { return c._id.toString() === input.id.toString(); })[0];
if (!comment) throw new Error('Comment not found on image');

if (comment.author !== context.user['cognito:username'] && !context.user['is_superuser']) {
Expand Down

0 comments on commit c70c0bb

Please sign in to comment.