Skip to content

Commit

Permalink
fix: Fix forum post with wrong id (#471)
Browse files Browse the repository at this point in the history
  • Loading branch information
LautaroPetaccio committed Mar 31, 2022
1 parent 44821fc commit c657a96
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Forum/Forum.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class ForumRouter extends Router {
}

async post(req: AuthRequest) {
const id: string = server.extractFromReq(req, 'id')
const collectionId: string = server.extractFromReq(req, 'id')
const forumPostJSON: any = server.extractFromReq(req, 'forumPost')

const validate = validator.compile(forumPostSchema)
Expand All @@ -40,16 +40,16 @@ export class ForumRouter extends Router {
}
const forumPost: ForumPost = forumPostJSON as ForumPost

const collection = await Collection.findOne(id)
const collection = await Collection.findOne(collectionId)
if (collection.forum_link) {
throw new HTTPError('Forum post already exists', { id })
throw new HTTPError('Forum post already exists', { id: collectionId })
}

try {
const { id, link } = await createPost(forumPost)
await Collection.update<CollectionAttributes>(
{ forum_id: id, forum_link: link },
{ id }
{ id: collectionId }
)

return link
Expand Down

0 comments on commit c657a96

Please sign in to comment.