mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-04-14 19:56:23 +00:00
20 lines
406 B
JavaScript
20 lines
406 B
JavaScript
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;
|
|
};
|