mirror of
https://github.com/wassname/talk.git
synced 2026-08-18 12:30:39 +08:00
Removing extra commas and collapsing actions into an object in the backend.
This commit is contained in:
+5
-12
@@ -32,23 +32,16 @@ ActionSchema.statics.findById = function(id) {
|
||||
|
||||
/**
|
||||
* Add an action.
|
||||
* @param {String} item_id identifier of the comment (uuid)
|
||||
* @param {String} item_id identifier of the item (uuid)
|
||||
* @param {String} user_id user id of the action (uuid)
|
||||
* @param {String} action the new action to the comment
|
||||
* @param {String} action the new action to the item
|
||||
* @return {Promise}
|
||||
*/
|
||||
ActionSchema.statics.insertUserAction = ({item_id, item_type, user_id, action_type, field, detail}) => {
|
||||
const action = {
|
||||
item_id,
|
||||
item_type,
|
||||
user_id,
|
||||
action_type,
|
||||
field,
|
||||
detail
|
||||
};
|
||||
ActionSchema.statics.insertUserAction = ({item_id, item_type, user_id, action}) => {
|
||||
let action_obj = Object.assign({}, action, {item_id, item_type, user_id});
|
||||
|
||||
// Create/Update the action.
|
||||
return Action.findOneAndUpdate(action, action, {
|
||||
return Action.findOneAndUpdate(action_obj, action_obj, {
|
||||
|
||||
// Ensure that if it's new, we return the new object created.
|
||||
new: true,
|
||||
|
||||
+2
-4
@@ -284,13 +284,11 @@ CommentSchema.statics.pushStatus = (id, status, assigned_by = null) => Comment.u
|
||||
* @param {String} action the new action to the comment
|
||||
* @return {Promise}
|
||||
*/
|
||||
CommentSchema.statics.addAction = (item_id, user_id, action_type, field, detail) => Action.insertUserAction({
|
||||
CommentSchema.statics.addAction = (item_id, user_id, action) => Action.insertUserAction({
|
||||
item_id,
|
||||
item_type: 'comment',
|
||||
user_id,
|
||||
action_type,
|
||||
field,
|
||||
detail
|
||||
action
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
+2
-4
@@ -555,11 +555,9 @@ UserService.addBio = (id, bio) => (
|
||||
* @param {String} action the new action to the user
|
||||
* @return {Promise}
|
||||
*/
|
||||
UserService.addAction = (item_id, user_id, action_type, field, detail) => Action.insertUserAction({
|
||||
UserService.addAction = (item_id, user_id, action) => Action.insertUserAction({
|
||||
item_id,
|
||||
item_type: 'comment',
|
||||
user_id,
|
||||
action_type,
|
||||
field,
|
||||
detail
|
||||
action
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user