Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions spec/PushController.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ describe('PushController', () => {
isMaster: true
}

var pushController = new PushController(pushAdapter, Parse.applicationId, defaultConfiguration.push);
var pushController = new PushController();
reconfigureServer({
push: { adapter: pushAdapter }
}).then(() => {
Expand Down Expand Up @@ -231,7 +231,7 @@ describe('PushController', () => {
isMaster: true
}

var pushController = new PushController(pushAdapter, Parse.applicationId, defaultConfiguration.push);
var pushController = new PushController();
reconfigureServer({
push: { adapter: pushAdapter }
}).then(() => {
Expand Down Expand Up @@ -285,7 +285,7 @@ describe('PushController', () => {
var auth = {
isMaster: true
}
var pushController = new PushController(pushAdapter, Parse.applicationId, defaultConfiguration.push);
var pushController = new PushController();
reconfigureServer({
push: { adapter: pushAdapter }
}).then(() => {
Expand Down Expand Up @@ -356,7 +356,7 @@ describe('PushController', () => {
var auth = {
isMaster: true
}
var pushController = new PushController(pushAdapter, Parse.applicationId, defaultConfiguration.push);
var pushController = new PushController();
reconfigureServer({
push: { adapter: pushAdapter }
}).then(() => {
Expand Down Expand Up @@ -406,7 +406,7 @@ describe('PushController', () => {
}
}

var pushController = new PushController(pushAdapter, Parse.applicationId, defaultConfiguration.push);
var pushController = new PushController();
reconfigureServer({
push: { adapter: pushAdapter }
}).then(() => {
Expand Down Expand Up @@ -451,7 +451,7 @@ describe('PushController', () => {
}
}

var pushController = new PushController(pushAdapter, Parse.applicationId, defaultConfiguration.push);
var pushController = new PushController();
reconfigureServer({
push: { adapter: pushAdapter }
}).then(() => {
Expand Down
1 change: 1 addition & 0 deletions src/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class Config {
this.pushController = cacheInfo.pushController;
this.pushControllerQueue = cacheInfo.pushControllerQueue;
this.pushWorker = cacheInfo.pushWorker;
this.hasPushSupport = cacheInfo.hasPushSupport;
this.loggerController = cacheInfo.loggerController;
this.userController = cacheInfo.userController;
this.authDataManager = cacheInfo.authDataManager;
Expand Down
20 changes: 2 additions & 18 deletions src/Controllers/PushController.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,10 @@ import { pushStatusHandler } from '../StatusHandler';
import { isPushIncrementing,
validatePushType } from '../Push/utils';

export class PushController extends AdaptableController {
constructor(adapter, appId, options) {
super(adapter, appId, options);
}

get pushIsAvailable() {
return !!this.adapter;
}
export class PushController {

sendPush(body = {}, where = {}, config, auth, onPushStatusSaved = () => {}) {
var pushAdapter = this.adapter;
if (!this.pushIsAvailable) {
throw new Parse.Error(Parse.Error.PUSH_MISCONFIGURED,
'Push adapter is not available');
}
if (!this.options) {
if (!config.hasPushSupport) {
throw new Parse.Error(Parse.Error.PUSH_MISCONFIGURED,
'Missing push configuration');
}
Expand Down Expand Up @@ -102,10 +90,6 @@ export class PushController extends AdaptableController {
}
return expirationTime.valueOf();
}

expectedAdapterType() {
return PushAdapter;
}
}

export default PushController;
13 changes: 8 additions & 5 deletions src/ParseServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,17 @@ class ParseServer {

const pushQueueOptions = (push || {}).queueOptions || {};

if (push.queueOptions) {
if ((push || {}).queueOptions) {
delete push.queueOptions;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uh oh. options should be immutable!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't work for me since I have immutable configuration.....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright, I should make a copy through Object.assign()

}
// Pass the push options too as it works with the default
const pushControllerAdapter = loadAdapter(push && push.adapter, ParsePushAdapter, push || {});
const pushAdapter = loadAdapter(push && push.adapter, ParsePushAdapter, push || {});
// We pass the options and the base class for the adatper,
// Note that passing an instance would work too
const pushController = new PushController(pushControllerAdapter, appId, push);
const pushController = new PushController();

const hasPushSupport = pushAdapter && push;

const {
batchSize,
channel,
Expand All @@ -190,7 +192,7 @@ class ParseServer {
const pushControllerQueue = new PushQueue(pushQueueOptions);
let pushWorker;
if (!disablePushWorker) {
pushWorker = new PushWorker(pushControllerAdapter, pushQueueOptions);
pushWorker = new PushWorker(pushAdapter, pushQueueOptions);
}

const emailControllerAdapter = loadAdapter(emailAdapter);
Expand Down Expand Up @@ -247,7 +249,8 @@ class ParseServer {
schemaCacheTTL,
enableSingleSchemaCache,
pushWorker,
pushControllerQueue
pushControllerQueue,
hasPushSupport
});

// To maintain compatibility. TODO: Remove in some version that breaks backwards compatability
Expand Down
4 changes: 2 additions & 2 deletions src/Routers/FeaturesRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export class FeaturesRouter extends PromiseRouter {
from: true,
},
push: {
immediatePush: req.config.pushController.pushIsAvailable,
immediatePush: req.config.hasPushSupport,
scheduledPush: false,
storedPushData: req.config.pushController.pushIsAvailable,
storedPushData: req.config.hasPushSupport,
pushAudiences: false,
},
schemas: {
Expand Down