mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
21 lines
406 B
JavaScript
21 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;
|
|
};
|