Skip to main content

Thread/Comment Routes

GET /api/thread/getByPlan/:plan_id​

Return all threads and their comments(user name populated) of a plan.

NameTypeDescription
Paramsplan_idString
OutputThread[]all threads and their comments(user name populated) of a plan

Sample Output​

[
{
"resolved": false,
"_id": "624f8bb1ccbfa9214879a4fa",
"plan_id": "623659ddb8316b8b54f77815",
"location_type": "Semester",
"location_id": "623659ddb8316b8b54f77820Intersession",
"__v": 0,
"comments": [
{
"visible_user_id": [
"juniorDev",
"mockUser"
],
"date": "2022-04-07T17:36:58.451Z",
"_id": "624f8bb1ccbfa9214879a4fc",
"commenter_id": {
"_id": "juniorDev",
"name": "Junior Dev"
},
"message": "huh????",
"thread_id": "624f8bb1ccbfa9214879a4fa",
"__v": 0
},
{
"visible_user_id": [
"juniorDev",
"mockUser"
],
"date": "2022-04-07T17:36:58.451Z",
"_id": "624f9157ccbfa9214879a563",
"commenter_id": {
"_id": "juniorDev",
"name": "Junior Dev"
},
"thread_id": "624f8bb1ccbfa9214879a4fa",
"message": "why...",
"__v": 0
}
]
},
{
"resolved": false,
"_id": "625049cdde54f04374785d72",
"plan_id": "623659ddb8316b8b54f77815",
"location_type": "Semester",
"location_id": "623659ddb8316b8b54f7781aFall",
"__v": 0,
"comments": [
{
"visible_user_id": [
"juniorDev",
"mockUser"
],
"date": "2022-04-08T14:19:58.194Z",
"_id": "625049cdde54f04374785d74",
"commenter_id": {
"_id": "juniorDev",
"name": "Junior Dev"
},
"message": "new thread!",
"thread_id": "625049cdde54f04374785d72",
"__v": 0
}
]
}
]

POST /api/thread/new​

Create a new thread and a comment pointing to that thread.

NameTypeDescription
BodythreadObjectThe object must have all the required fields of the Thread schema.
commentObjectThe object must have all the required fields of the Comment schema.
OutputCommentThe newly created Comment object(note a new Thread is also created)

Sample Output​

{
"_id": "625053fbde54f04374785e6e",
"visible_user_id": [
"user1",
"user2"
],
"date": "2022-04-08T14:19:58.194+00:00",
"commenter_id": "user1",
"message": "Hi how are you?",
"thread_id": "625053fbde54f04374785e6c"
}

POST /api/thread/reply​

Add a new comment(reply) to a specific thread.

NameTypeDescription
BodycommentObjectThe object must have all the required fields of the Comment schema.
OutputCommentThe newly created Comment object(note a new Thread is not created)

Sample Output​

{
"_id": "625053fbde54f04374785e6e",
"visible_user_id": [
"user1",
"user2"
],
"date": "2022-04-09T14:19:58.194+00:00",
"commenter_id": "user2",
"message": "I'm good! How about you?",
"thread_id": "625053fbde54f04374785e6c"
}

PATCH /api/thread/resolve​

Resolve a thread.

NameTypeDescription
Bodythread_idStringThe object_id of the thread to resolve.
OutputThreadresolved field changed to True

Sample Output​

{
"_id": "625053fbde54f04374785e6c",
"plan_id": "62505477de54f04374785e93",
"location_type": "Course",
"location_id": "62505477de54f04374da9379",
"resolved": true
}

PATCH /api/comment​

Edit a specific comment.

NameTypeDescription
Bodycomment_idStringThe Object_id of the comment to edit
messageStringThe new comment content.
OutputCommentThe updated comment object

Sample Output​

{
"_id": "625053fbde54f04374785e6e",
"visible_user_id": [
"user1",
"user2"
],
"date": "2022-04-09T14:19:58.194+00:00",
"commenter_id": "user2",
"message": "Just changed the message~",
"thread_id": "625053fbde54f04374785e6c"
}

DELETE /api/comment​

Delete a specific comment.

NameTypeDescription
Bodycomment_idStringThe Object_id of the comment to delete
OutputCommentThe deleted comment object

Sample Output​

{
"_id": "625053fbde54f04374785e6e",
"visible_user_id": [
"user1",
"user2"
],
"date": "2022-04-09T14:19:58.194+00:00",
"commenter_id": "user2",
"message": "I'm good! How about you?",
"thread_id": "625053fbde54f04374785e6c"
}

DELETE /api/thread​

Delete a thread and all comments of that thread.

NameTypeDescription
Bodythread_idStringThe Object_id of the comment to edit
OutputCommentThe deleted thread object

Sample Output​

{
"_id": "625053fbde54f04374785e6c",
"plan_id": "62505477de54f04374785e93",
"location_type": "Course",
"location_id": "62505477de54f04374da9379",
"resolved": true
}