mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
shared-code-private-messages
This commit is contained in:
@@ -115,6 +115,9 @@ import sell from './ops/sell';
|
||||
import unlock from './ops/unlock';
|
||||
import revive from './ops/revive';
|
||||
import rebirth from './ops/rebirth';
|
||||
import blockUser from './ops/blockUser';
|
||||
import clearPMs from './ops/clearPMs';
|
||||
import deletePM from './ops/deletePM';
|
||||
import reroll from './ops/reroll';
|
||||
|
||||
api.ops = {
|
||||
@@ -147,6 +150,9 @@ api.ops = {
|
||||
unlock,
|
||||
revive,
|
||||
rebirth,
|
||||
blockUser,
|
||||
clearPMs,
|
||||
deletePM,
|
||||
reroll,
|
||||
};
|
||||
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
module.exports = function(user, req, cb) {
|
||||
var i;
|
||||
i = user.inbox.blocks.indexOf(req.params.uuid);
|
||||
if (~i) {
|
||||
user.inbox.blocks.splice(i, 1);
|
||||
} else {
|
||||
import validator from 'validator';
|
||||
import i18n from '../../../common/script/i18n';
|
||||
import {
|
||||
BadRequest,
|
||||
} from '../libs/errors';
|
||||
|
||||
module.exports = function blockUser (user, req = {}) {
|
||||
if (!validator.isUUID(req.params.uuid)) throw new BadRequest(i18n.t('invalidUUID', req.language));
|
||||
|
||||
let i = user.inbox.blocks.indexOf(req.params.uuid);
|
||||
if (i === -1) {
|
||||
user.inbox.blocks.push(req.params.uuid);
|
||||
} else {
|
||||
user.inbox.blocks.splice(i, 1);
|
||||
}
|
||||
if (typeof user.markModified === "function") {
|
||||
user.markModified('inbox.blocks');
|
||||
}
|
||||
return typeof cb === "function" ? cb(null, user.inbox.blocks) : void 0;
|
||||
|
||||
user.markModified('inbox.blocks');
|
||||
return user.inbox.blocks;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
module.exports = function(user, req, cb) {
|
||||
|
||||
module.exports = function clearPMs (user) {
|
||||
user.inbox.messages = {};
|
||||
if (typeof user.markModified === "function") {
|
||||
user.markModified('inbox.messages');
|
||||
}
|
||||
return typeof cb === "function" ? cb(null, user.inbox.messages) : void 0;
|
||||
user.markModified('inbox.messages');
|
||||
return user.inbox.messages;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module.exports = function(user, req, cb) {
|
||||
delete user.inbox.messages[req.params.id];
|
||||
if (typeof user.markModified === "function") {
|
||||
user.markModified('inbox.messages.' + req.params.id);
|
||||
}
|
||||
return typeof cb === "function" ? cb(null, user.inbox.messages) : void 0;
|
||||
import _ from 'lodash';
|
||||
|
||||
module.exports = function deletePM (user, req = {}) {
|
||||
delete user.inbox.messages[_.get(req, 'params.id')];
|
||||
user.markModified(`inbox.messages.${req.params.id}`);
|
||||
return user.inbox.messages;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user