mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
wip: split shared ops
This commit is contained in:
20
common/script/ops/addPushDevice.js
Normal file
20
common/script/ops/addPushDevice.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import _ from 'lodash';
|
||||
|
||||
module.exports = function(user, req, cb) {
|
||||
var i, item, pd;
|
||||
if (!user.pushDevices) {
|
||||
user.pushDevices = [];
|
||||
}
|
||||
pd = user.pushDevices;
|
||||
item = {
|
||||
regId: req.body.regId,
|
||||
type: req.body.type
|
||||
};
|
||||
i = _.findIndex(pd, {
|
||||
regId: item.regId
|
||||
});
|
||||
if (i === -1) {
|
||||
pd.push(item);
|
||||
}
|
||||
return typeof cb === "function" ? cb(null, user.pushDevices) : void 0;
|
||||
};
|
||||
Reference in New Issue
Block a user