Skip to content

Commit 5f46b15

Browse files
Merge pull request #4812 from Countly/SER-1062-cannot-send-push-after-app-setting-update
[SER-1062] [push] Push: updated credentials query for message creation
2 parents 04543dc + fc1b2f5 commit 5f46b15

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

plugins/push/api/api-message.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ const { Message, Result, Creds, State, Status, platforms, Audience, ValidationEr
33
common = require('../../../api/utils/common'),
44
log = common.log('push:api:message'),
55
moment = require('moment-timezone'),
6-
{ request } = require('./proxy');
6+
{ request } = require('./proxy'),
7+
{ObjectId} = require("mongodb");
78

89

910
/**
@@ -82,8 +83,13 @@ async function validate(args, draft = false) {
8283
throw new ValidationError(`No push credentials for ${PLATFORMS_TITLES[p]} platform`);
8384
}
8485
}
85-
86-
let creds = await common.db.collection(Creds.collection).find({_id: {$in: msg.platforms.map(p => common.dot(app, `plugins.push.${p}._id`))}}).toArray();
86+
let creds = await common.db.collection(Creds.collection).find({
87+
_id: {
88+
$in: msg.platforms
89+
.map(p => common.dot(app, `plugins.push.${p}._id`))
90+
.map(oid => ObjectId(oid.toString())) // cast to ObjectId (it gets broken after an update in app settings page)
91+
}
92+
}).toArray();
8793
if (creds.length !== msg.platforms.length) {
8894
throw new ValidationError('No push credentials in db');
8995
}

0 commit comments

Comments
 (0)