Skip to content

Commit b673d1d

Browse files
authored
Merge pull request #3791 from Countly/hotfix/push
[push] Missing indexes for token hashes
2 parents 497b950 + 33c9029 commit b673d1d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

plugins/push/api/api-push.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ module.exports.onMerge = ({app_id, oldUser, newUser}) => {
290290
update.$set = {};
291291
for (let k in ou.tk) {
292292
update.$set['tk.' + k] = ou.tk[k];
293-
newUser['tk' + k] = true;
293+
newUser['tk' + k] = oldUser['tk' + k];
294294
}
295295
}
296296
if (ou.msgs && ou.msgs.length) {
@@ -314,7 +314,7 @@ module.exports.onMerge = ({app_id, oldUser, newUser}) => {
314314
opts.upsert = true;
315315
delete update.$set._id;
316316
for (let k in ou.tk) {
317-
newUser['tk' + k] = true;
317+
newUser['tk' + k] = oldUser['tk' + k];
318318
}
319319
}
320320
else if (ou && Object.keys(ou).length === 1 && !nu) {

plugins/push/frontend/app.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

3-
const log = require('../../../api/utils/common.js').log('push:frontend');
3+
const log = require('../../../api/utils/common.js').log('push:frontend'),
4+
{ FIELDS } = require('../api/send/platforms');
45

56
module.exports = {
67
init: (app, db) => {
@@ -14,6 +15,14 @@ module.exports = {
1415
{name: 'main', key: {_id: 1, m: 1, p: 1, f: 1}},
1516
]).catch(() => {});
1617

18+
db.collection('apps').find().toArray(function(err, apps) {
19+
if (apps && apps.length) {
20+
apps.forEach(a => {
21+
db.collection(`app_users${a._id}`).createIndexes(Object.values(FIELDS).map(f => ({name: 'tk' + f, key: {['tk' + f]: 1}}))).catch(() => {});
22+
});
23+
}
24+
});
25+
1726
db.collection('plugins').updateMany({}, {$unset: {'push.proxyhttp': 1}}).catch(() => {});
1827
}
1928
};

0 commit comments

Comments
 (0)