Skip to content

Commit 07ae85e

Browse files
marvelmflovilmart
authored andcommitted
Prefix default push channel with applicationId (#4182)
1 parent a5ce9fc commit 07ae85e

File tree

2 files changed

+61
-2
lines changed

2 files changed

+61
-2
lines changed

spec/PushQueue.spec.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import Config from "../src/Config";
2+
import {PushQueue} from "../src/Push/PushQueue";
3+
4+
describe('PushQueue', () => {
5+
describe('With a defined channel', () => {
6+
it('should be propagated to the PushWorker and PushQueue', (done) => {
7+
reconfigureServer({
8+
push: {
9+
queueOptions: {
10+
disablePushWorker: false,
11+
channel: 'my-specific-channel'
12+
},
13+
adapter: {
14+
send() {
15+
return Promise.resolve();
16+
},
17+
getValidPushTypes() {
18+
return [];
19+
}
20+
}
21+
}
22+
})
23+
.then(() => {
24+
const config = new Config(Parse.applicationId);
25+
expect(config.pushWorker.channel).toEqual('my-specific-channel', 'pushWorker.channel');
26+
expect(config.pushControllerQueue.channel).toEqual('my-specific-channel', 'pushWorker.channel');
27+
})
28+
.then(done, done.fail);
29+
});
30+
});
31+
32+
describe('Default channel', () => {
33+
it('should be prefixed with the applicationId', (done) => {
34+
reconfigureServer({
35+
push: {
36+
queueOptions: {
37+
disablePushWorker: false
38+
},
39+
adapter: {
40+
send() {
41+
return Promise.resolve();
42+
},
43+
getValidPushTypes() {
44+
return [];
45+
}
46+
}
47+
}
48+
})
49+
.then(() => {
50+
const config = new Config(Parse.applicationId);
51+
expect(PushQueue.defaultPushChannel()).toEqual('test-parse-server-push');
52+
expect(config.pushWorker.channel).toEqual('test-parse-server-push');
53+
expect(config.pushControllerQueue.channel).toEqual('test-parse-server-push');
54+
})
55+
.then(done, done.fail);
56+
});
57+
});
58+
});

src/Push/PushQueue.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ParseMessageQueue } from '../ParseMessageQueue';
22
import rest from '../rest';
33
import { applyDeviceTokenExists } from './utils';
4+
import Parse from 'parse/node';
45

56
const PUSH_CHANNEL = 'parse-server-push';
67
const DEFAULT_BATCH_SIZE = 100;
@@ -13,13 +14,13 @@ export class PushQueue {
1314
// config object of the publisher, right now it only contains the redisURL,
1415
// but we may extend it later.
1516
constructor(config: any = {}) {
16-
this.channel = config.channel || PUSH_CHANNEL;
17+
this.channel = config.channel || PushQueue.defaultPushChannel();
1718
this.batchSize = config.batchSize || DEFAULT_BATCH_SIZE;
1819
this.parsePublisher = ParseMessageQueue.createPublisher(config);
1920
}
2021

2122
static defaultPushChannel() {
22-
return PUSH_CHANNEL;
23+
return `${Parse.applicationId}-${PUSH_CHANNEL}`;
2324
}
2425

2526
enqueue(body, where, config, auth, pushStatus) {

0 commit comments

Comments
 (0)