mirror of
https://github.com/wassname/talk.git
synced 2026-06-29 04:11:26 +08:00
Fixed bug with status changes in the graph
This commit is contained in:
@@ -180,9 +180,9 @@ const createPublicComment = (context, commentInput) => {
|
||||
* @param {String} status the new status of the comment
|
||||
*/
|
||||
|
||||
const setCommentStatus = ({loaders: {Comments}}, {id, status}) => {
|
||||
const setCommentStatus = ({user, loaders: {Comments}}, {id, status}) => {
|
||||
return CommentsService
|
||||
.setStatus(id, status)
|
||||
.pushStatus(id, status, user ? user.id : null)
|
||||
.then((comment) => {
|
||||
|
||||
// If the loaders are present, clear the caches for these values because we
|
||||
|
||||
+9
-22
@@ -213,7 +213,15 @@ module.exports = class CommentsService {
|
||||
* @return {Promise}
|
||||
*/
|
||||
static pushStatus(id, status, assigned_by = null) {
|
||||
return CommentModel.update({id}, {
|
||||
|
||||
// Check to see if the comment status is in the allowable set of statuses.
|
||||
if (STATUSES.indexOf(status) === -1) {
|
||||
|
||||
// Comment status is not supported! Error out here.
|
||||
return Promise.reject(new Error(`status ${status} is not supported`));
|
||||
}
|
||||
|
||||
return CommentModel.findOneAndUpdate({id}, {
|
||||
$push: {
|
||||
status_history: {
|
||||
type: status,
|
||||
@@ -292,25 +300,4 @@ module.exports = class CommentsService {
|
||||
|
||||
return CommentModel.find(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets Comment Status
|
||||
* @param {String} id identifier of the comment (uuid)
|
||||
* @param {String} status the new status of the comment
|
||||
* @return {Promise}
|
||||
*/
|
||||
|
||||
static setStatus(id, status) {
|
||||
|
||||
// Check to see if the comment status is in the allowable set of statuses.
|
||||
if (STATUSES.indexOf(status) === -1) {
|
||||
|
||||
// Comment status is not supported! Error out here.
|
||||
return Promise.reject(new Error(`status ${status} is not supported`));
|
||||
}
|
||||
|
||||
return CommentModel.findOneAndUpdate({id}, {
|
||||
$set: {status}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user