Add support for more audience fields. (#4145)

* Add support for more audience fields.

* Only update audience when defined audience_id.
This commit is contained in:
Anthony Mosca
2017-09-12 11:36:21 +09:30
committed by Florent Vilmart
parent 9fbb5e29e8
commit 4dce3bd63c
6 changed files with 160 additions and 17 deletions

View File

@@ -54,6 +54,20 @@ export class PushController {
}).then(() => {
onPushStatusSaved(pushStatus.objectId);
return badgeUpdate();
}).then(() => {
// Update audience lastUsed and timesUsed
if (body.audience_id) {
const audienceId = body.audience_id;
var updateAudience = {
lastUsed: { __type: "Date", iso: new Date().toISOString() },
timesUsed: { __op: "Increment", "amount": 1 }
};
const write = new RestWrite(config, master(config), '_Audience', {objectId: audienceId}, updateAudience);
write.execute();
}
// Don't wait for the audience update promise to resolve.
return Promise.resolve();
}).then(() => {
if (body.hasOwnProperty('push_time') && config.hasPushScheduledSupport) {
return Promise.resolve();

View File

@@ -113,12 +113,14 @@ const defaultColumns = Object.freeze({
},
_GlobalConfig: {
"objectId": {type: 'String'},
"params": {type: 'Object'}
"params": {type: 'Object'}
},
_Audience: {
"objectId": {type:'String'},
"name": {type:'String'},
"query": {type:'String'} //storing query as JSON string to prevent "Nested keys should not contain the '$' or '.' characters" error
"objectId": {type:'String'},
"name": {type:'String'},
"query": {type:'String'}, //storing query as JSON string to prevent "Nested keys should not contain the '$' or '.' characters" error
"lastUsed": {type:'Date'},
"timesUsed": {type:'Number'}
}
});