mirror of
https://github.com/wassname/talk.git
synced 2026-08-08 11:28:12 +08:00
More endpoints
This commit is contained in:
+14
-9
@@ -32,10 +32,10 @@ const CommentSchema = new Schema({
|
||||
|
||||
/**
|
||||
* Finds a comment by the id.
|
||||
* @param {String} asset_id identifier of comment (uuid)
|
||||
* @param {String} id identifier of comment (uuid)
|
||||
*/
|
||||
CommentSchema.statics.findById = function(id) {
|
||||
return Comment.findOne({id});
|
||||
return Comment.findOne({'id': id});
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -48,13 +48,19 @@ CommentSchema.statics.findByAssetId = function(asset_id) {
|
||||
|
||||
/**
|
||||
* Change the status of a comment.
|
||||
* @param {String} comment_id identifier of the comment (uuid)
|
||||
* @param {String} id identifier of the comment (uuid)
|
||||
* @param {String} status the new status of the comment
|
||||
*/
|
||||
CommentSchema.statics.changeStatus = function(id, status) {
|
||||
var comment = Comment.findOne({id});
|
||||
comment.status = status;
|
||||
return comment.save();
|
||||
return Comment.update({'id': id}, {$set: {'status': status}}, {upsert: false}).then(() => {
|
||||
Comment.findById(id).then((comment) => {
|
||||
return comment;
|
||||
}).catch((err) => {
|
||||
console.log('Error updating status for the comment.', err);
|
||||
});
|
||||
}).catch((err) => {
|
||||
console.log('Error updating status for the comment.', err);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -64,10 +70,9 @@ CommentSchema.statics.changeStatus = function(id, status) {
|
||||
*/
|
||||
CommentSchema.statics.addAction = function(id, user_id, action_type) {
|
||||
// check that the comment exist
|
||||
var item_type = 'comment';
|
||||
let action = new Action({
|
||||
var action = new Action({
|
||||
action_type: action_type,
|
||||
item_type: item_type,
|
||||
item_type: 'comment',
|
||||
item_id: id,
|
||||
user_id: user_id
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user