Adds ability to track sent/failed PerUTCOffset in the PushWorker (#4158)
* Adds ability to track sent/failed PerUTCOffset in the PushWorker - for scheduled push notifications at a certain time, it helps keep track of the state * Makes sure we track it all correctly * Adds to Postgres
This commit is contained in:
@@ -47,7 +47,7 @@ export class PushWorker {
|
||||
}
|
||||
}
|
||||
|
||||
run({ body, query, pushStatus, applicationId }: any): Promise<*> {
|
||||
run({ body, query, pushStatus, applicationId, UTCOffset }: any): Promise<*> {
|
||||
const config = new Config(applicationId);
|
||||
const auth = master(config);
|
||||
const where = utils.applyDeviceTokenExists(query.where);
|
||||
@@ -56,13 +56,13 @@ export class PushWorker {
|
||||
if (results.length == 0) {
|
||||
return;
|
||||
}
|
||||
return this.sendToAdapter(body, results, pushStatus, config);
|
||||
return this.sendToAdapter(body, results, pushStatus, config, UTCOffset);
|
||||
}, err => {
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
|
||||
sendToAdapter(body: any, installations: any[], pushStatus: any, config: Config): Promise<*> {
|
||||
sendToAdapter(body: any, installations: any[], pushStatus: any, config: Config, UTCOffset: ?any): Promise<*> {
|
||||
pushStatus = pushStatusHandler(config, pushStatus.objectId);
|
||||
// Check if we have locales in the push body
|
||||
const locales = utils.getLocalesFromPush(body);
|
||||
@@ -75,7 +75,7 @@ export class PushWorker {
|
||||
const promises = Object.keys(grouppedInstallations).map((locale) => {
|
||||
const installations = grouppedInstallations[locale];
|
||||
const body = bodiesPerLocales[locale];
|
||||
return this.sendToAdapter(body, installations, pushStatus, config);
|
||||
return this.sendToAdapter(body, installations, pushStatus, config, UTCOffset);
|
||||
});
|
||||
return Promise.all(promises);
|
||||
}
|
||||
@@ -83,7 +83,7 @@ export class PushWorker {
|
||||
if (!utils.isPushIncrementing(body)) {
|
||||
logger.verbose(`Sending push to ${installations.length}`);
|
||||
return this.adapter.send(body, installations, pushStatus.objectId).then((results) => {
|
||||
return pushStatus.trackSent(results);
|
||||
return pushStatus.trackSent(results, UTCOffset).then(() => results);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ export class PushWorker {
|
||||
const payload = deepcopy(body);
|
||||
payload.data.badge = parseInt(badge);
|
||||
const installations = badgeInstallationsMap[badge];
|
||||
return this.sendToAdapter(payload, installations, pushStatus, config);
|
||||
return this.sendToAdapter(payload, installations, pushStatus, config, UTCOffset);
|
||||
});
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user