mirror of
https://github.com/wassname/talk.git
synced 2026-08-12 12:30:39 +08:00
merge master
This commit is contained in:
+10
-10
@@ -12,23 +12,23 @@ const errors = require('../../errors');
|
||||
* @param {String} action_type type of the action
|
||||
* @return {Promise} resolves to the action created
|
||||
*/
|
||||
const createAction = ({user = {}}, {item_id, item_type, action_type, group_id, metadata = {}}) => {
|
||||
return ActionsService.insertUserAction({
|
||||
const createAction = async ({user = {}}, {item_id, item_type, action_type, group_id, metadata = {}}) => {
|
||||
let action = await ActionsService.insertUserAction({
|
||||
item_id,
|
||||
item_type,
|
||||
user_id: user.id,
|
||||
group_id,
|
||||
action_type,
|
||||
metadata
|
||||
}).then((action) => {
|
||||
if (item_type === 'USERS' && action_type === 'FLAG') {
|
||||
return UsersService
|
||||
.setStatus(item_id, 'PENDING')
|
||||
.then(() => action);
|
||||
}
|
||||
|
||||
return action;
|
||||
});
|
||||
|
||||
if (item_type === 'USERS' && action_type === 'FLAG') {
|
||||
|
||||
// Set the user as pending if it was a user flag.
|
||||
await UsersService.setStatus(item_id, 'PENDING');
|
||||
}
|
||||
|
||||
return action;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user