mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-05 03:52:14 +00:00
feat(private-messages): add features for private-messaging (deletePM, blockUser)
This commit is contained in:
parent
f68f884525
commit
1bca160eb6
2 changed files with 45 additions and 0 deletions
27
dist/habitrpg-shared.js
vendored
27
dist/habitrpg-shared.js
vendored
|
|
@ -13730,6 +13730,13 @@ api.dotGet = function(obj, path) {
|
|||
})(this)), obj);
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
Reflists are arrays, but stored as objects. Mongoose has a helluvatime working with arrays (the main problem for our
|
||||
syncing issues) - so the goal is to move away from arrays to objects, since mongoose can reference elements by ID
|
||||
no problem. To maintain sorting, we use these helper functions:
|
||||
*/
|
||||
|
||||
api.refPush = function(reflist, item, prune) {
|
||||
if (prune == null) {
|
||||
prune = 0;
|
||||
|
|
@ -14694,6 +14701,26 @@ api.wrap = function(user, main) {
|
|||
}
|
||||
return typeof cb === "function" ? cb(null, user.preferences.webhooks) : void 0;
|
||||
},
|
||||
deletePM: function(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;
|
||||
},
|
||||
blockUser: function(req, cb) {
|
||||
var i;
|
||||
i = user.inbox.blocks.indexOf(req.params.uuid);
|
||||
if (~i) {
|
||||
user.inbox.blocks.splice(i, 1);
|
||||
} else {
|
||||
user.inbox.blocks.push(req.params.uuid);
|
||||
}
|
||||
if (typeof user.markModified === "function") {
|
||||
user.markModified('inbox.blocks');
|
||||
}
|
||||
return typeof cb === "function" ? cb(null, user.inbox.blocks) : void 0;
|
||||
},
|
||||
feed: function(req, cb) {
|
||||
var egg, evolve, food, message, pet, potion, userPets, _ref, _ref1, _ref2;
|
||||
_ref = req.params, pet = _ref.pet, food = _ref.food;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,11 @@ api.dotSet = (obj,path,val)->
|
|||
api.dotGet = (obj,path)->
|
||||
_.reduce path.split('.'), ((curr, next) => curr?[next]), obj
|
||||
|
||||
###
|
||||
Reflists are arrays, but stored as objects. Mongoose has a helluvatime working with arrays (the main problem for our
|
||||
syncing issues) - so the goal is to move away from arrays to objects, since mongoose can reference elements by ID
|
||||
no problem. To maintain sorting, we use these helper functions:
|
||||
###
|
||||
api.refPush = (reflist, item, prune=0) ->
|
||||
item.sort = if _.isEmpty(reflist) then 0 else _.max(reflist,'sort').sort+1
|
||||
item.id = api.uuid() unless item.id and !reflist[item.id]
|
||||
|
|
@ -620,6 +625,19 @@ api.wrap = (user, main=true) ->
|
|||
user.markModified? 'preferences.webhooks'
|
||||
cb? null, user.preferences.webhooks
|
||||
|
||||
# ------
|
||||
# Inbox
|
||||
# ------
|
||||
deletePM: (req, cb) ->
|
||||
delete user.inbox.messages[req.params.id]
|
||||
user.markModified? 'inbox.messages.'+req.params.id
|
||||
cb? null, user.inbox.messages
|
||||
blockUser: (req, cb) ->
|
||||
i = user.inbox.blocks.indexOf(req.params.uuid)
|
||||
if ~i then user.inbox.blocks.splice(i,1) else user.inbox.blocks.push(req.params.uuid)
|
||||
user.markModified? 'inbox.blocks'
|
||||
cb? null, user.inbox.blocks
|
||||
|
||||
# ------
|
||||
# Inventory
|
||||
# ------
|
||||
|
|
|
|||
Loading…
Reference in a new issue