Thread/Comment Routes
GET
/api/thread/getByPlan/:plan_id
Return all threads and their comments(user name populated) of a plan.
Name | Type | Description | |
---|---|---|---|
Params | plan_id | String | |
Output | Thread[] | 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.
Name | Type | Description | |
---|---|---|---|
Body | thread | Object | The object must have all the required fields of the Thread schema. |
comment | Object | The object must have all the required fields of the Comment schema. | |
Output | Comment | The 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.
Name | Type | Description | |
---|---|---|---|
Body | comment | Object | The object must have all the required fields of the Comment schema. |
Output | Comment | The 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.
Name | Type | Description | |
---|---|---|---|
Body | thread_id | String | The object_id of the thread to resolve. |
Output | Thread | resolved 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.
Name | Type | Description | |
---|---|---|---|
Body | comment_id | String | The Object_id of the comment to edit |
message | String | The new comment content. | |
Output | Comment | The 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.
Name | Type | Description | |
---|---|---|---|
Body | comment_id | String | The Object_id of the comment to delete |
Output | Comment | The 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.
Name | Type | Description | |
---|---|---|---|
Body | thread_id | String | The Object_id of the comment to edit |
Output | Comment | The deleted thread object |
Sample Output
{
"_id": "625053fbde54f04374785e6c",
"plan_id": "62505477de54f04374785e93",
"location_type": "Course",
"location_id": "62505477de54f04374da9379",
"resolved": true
}