Skip to content

Commit

Permalink
Merge pull request #188 from SquareTable/187-tempsearchforthreadcomme…
Browse files Browse the repository at this point in the history
…nts-api-should-take-postid-parameter

temp/searchforthreadcomments API now takes postId parameter instead of threadId
  • Loading branch information
Sebastian-Webster authored Oct 10, 2023
2 parents 44ddb7e + 42c28f5 commit 5bda2b0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions controllers/Temp.js
Original file line number Diff line number Diff line change
Expand Up @@ -3608,14 +3608,14 @@ class TempController {
})
}

static #searchforthreadcomments = (userId, threadId) => {
static #searchforthreadcomments = (userId, postId) => {
return new Promise(resolve => {
if (typeof threadId !== 'string') {
return resolve(HTTPWTHandler.badInput(`threadId must be a string. Provided type: ${typeof threadId}`))
if (typeof postId !== 'string') {
return resolve(HTTPWTHandler.badInput(`postId must be a string. Provided type: ${typeof postId}`))
}

if (threadId.length == 0) {
return resolve(HTTPWTHandler.badInput('threadId cannot be blank'))
if (postId.length == 0) {
return resolve(HTTPWTHandler.badInput('postId cannot be blank'))
}

//Find User
Expand All @@ -3625,7 +3625,7 @@ class TempController {
HTTPHandler.OK(res, 'Comment search successful', nameSendBackObject)
}

Thread.findOne({_id: {$eq: threadId}}).lean().then(data => {
Thread.findOne({_id: {$eq: postId}}).lean().then(data => {
if (data) {
var nameSendBackObject = [];
var comments = data.comments;
Expand All @@ -3650,7 +3650,7 @@ class TempController {
}
nameSendBackObject.push({commentId: String(data.comments[index].commentId), commenterName: result.name, commenterDisplayName: result.displayName, commentText: data.comments[index].commentsText, commentUpVotes: commentUpVotes, commentDownVotes: data.comments[index].commentDownVotes, commentReplies: data.comments[index].commentReplies.length, datePosted: data.comments[index].datePosted, profileImageKey: result.profileImageKey, commentUpVoted: commentUpVoted, commentDownVoted: commentDownVoted})
} else {
console.error('A comment was found on thread post with id:', threadId, " and the comment creator cannot be found. The comment creator's id is:", comments[index].commenterId)
console.error('A comment was found on thread post with id:', postId, " and the comment creator cannot be found. The comment creator's id is:", comments[index].commenterId)
return resolve(HTTPWTHandler.serverError('An error occurred while checking for comment creator'))
}
itemsProcessed++;
Expand All @@ -3669,7 +3669,7 @@ class TempController {
}
})
.catch(err => {
console.error('An error occurred while finding thread with id:', threadId, '. The error was:', err)
console.error('An error occurred while finding thread with id:', postId, '. The error was:', err)
return resolve(HTTPWTHandler.serverError('An error occurred while finding thread. Please try again.'))
});
})
Expand Down Expand Up @@ -6573,8 +6573,8 @@ class TempController {
return await this.#threadpostcommentreply(userId, comment, postId, commentId)
}

static searchforthreadcomments = async (userId, threadId) => {
return await this.#searchforthreadcomments(userId, threadId)
static searchforthreadcomments = async (userId, postId) => {
return await this.#searchforthreadcomments(userId, postId)
}

static getsinglethreadcomment = async (userId, threadId, commentId) => {
Expand Down
2 changes: 1 addition & 1 deletion routes/Temp.js
Original file line number Diff line number Diff line change
Expand Up @@ -1755,7 +1755,7 @@ router.post('/searchforthreadcomments', rateLimiters['/searchforthreadcomments']
const worker = new Worker(workerPath, {
workerData: {
functionName: 'searchforthreadcomments',
functionArgs: [req.tokenData, req.body.threadId]
functionArgs: [req.tokenData, req.body.postId]
}
})

Expand Down

0 comments on commit 5bda2b0

Please sign in to comment.