Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added sendScheduledPushes endpoint #6079

Closed
wants to merge 1 commit into from
Closed

added sendScheduledPushes endpoint #6079

wants to merge 1 commit into from

Conversation

mrmarcsmith
Copy link
Contributor

This PR resolves issue #6066. There are no foreseeable breaking changes.
It should be noted that this adds an additional field, "pushDate", to _PushStatus that is only populated when saving scheduled pushes. Regular pushes don't have this property set. The "pushDate" field is the "date" version of "pushTime" which is a "string". "pushDate" is used to greatly reduce the amount of processing that needs to be done to see if there are any pushes to be sent. without is we would need to fetch all scheduled pushes every time and parse their "string" type "pushTime" objects.

@mrmarcsmith
Copy link
Contributor Author

@acinader @dplewis @davimacedo let me know if you have time to check out this PR. I'm happy to answer any questions about it.

Copy link
Contributor

@acinader acinader left a comment

Choose a reason for hiding this comment

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

@mrmarcsmith I'm taking a look. You should run spell check on it and remove commented out code, please.


await reconfigureServer({
scheduledPush: true,
appId: Parse.applicationId,
Copy link
Contributor

Choose a reason for hiding this comment

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

do you need to reset masterkey, appid, serverurl? isn't it already set if you don't do?

Copy link
Contributor

@acinader acinader left a comment

Choose a reason for hiding this comment

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

nice! I have some questions and comments.


// translate parseObject to body
const body = {};
if (pushObject.has('pushTime')) body.push_time = pushObject.get('pushTime');
Copy link
Contributor

Choose a reason for hiding this comment

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

please use {} with all control statements (if, while, etc.). I'll look at making eslint more proactive.

}

const pushTime = PushController.getPushTime(body);
if (pushTime && pushTime.date !== 'undefined') {
Copy link
Contributor

Choose a reason for hiding this comment

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

you probably mean pushTime.date !=== undefined, you could cover this case in test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I grabbed this section of code from the current PushController.sendPush function, so we should investigate if that is a bug already released to the public. In the mean time, I'll write a test case testing this in my section of code and report back

body['push_time'] = PushController.formatPushTime(pushTime);
}

// TODO: currently we increment the badge when we schedule the push.
Copy link
Contributor

Choose a reason for hiding this comment

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

My $.02: make the breaking change

@@ -87,6 +87,7 @@ const defaultColumns: { [string]: SchemaFields } = Object.freeze({
},
_PushStatus: {
pushTime: { type: 'String' },
pushDate: { type: 'Date' }, // to improve speed for tolling Scheduled Pushs
Copy link
Contributor

Choose a reason for hiding this comment

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

polling?


// always returns { result: true }
static handlePOST(req) {
if (req.auth.isReadOnly) {
Copy link
Contributor

Choose a reason for hiding this comment

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

A question for @dplewis and/or @davimacedo: why don't we need to check for the master key? I grepped through the routers to find cases and we don't ever check, i just don't know why.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

riiight. thanks.

let expDate;

if (pushObject.has('expiry')) {
// Has an expiration date
Copy link
Contributor

Choose a reason for hiding this comment

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

redundant comment

// Has an expiration date
expDate = pushObject.get('expiry');
} else if (pushObject.has('expiration_interval')) {
// Has an expiration Interval
Copy link
Contributor

Choose a reason for hiding this comment

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

same

ScheduledPushRouter.sendPushFromPushStatus(pushObject, req);
}
},
{ useMasterKey: true }
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe use req.auth.master here to enforce security?

.sendScheduledPush(object, req.config, req.auth)
.catch(err => {
req.config.loggerController.error(
`_PushStatus : error while sending push`,
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't need the ` here, you can use '

@mrmarcsmith
Copy link
Contributor Author

I haven’t forgotten about this, just been on Pat Leave. I’ll make these changes when I come back.

@dplewis
Copy link
Member

dplewis commented Apr 15, 2021

@mrmarcsmith Is this branch still available? I can finish up this PR for you if you want.

@mtrezza
Copy link
Member

mtrezza commented Sep 3, 2021

⚠️ Important change for merging PRs from Parse Server 5.0 onwards!

We are planning to release the first beta version of Parse Server 5.0 in October 2021.

If a PR contains a breaking change and is not merged before the beta release of Parse Server 5.0, it cannot be merged until the end of 2022. Instead it has to follow the Deprecation Policy and phase-in breaking changes to be merged during the course of 2022.

One of the most voiced community feedbacks was the demand for predictability in breaking changes to make it easy to upgrade Parse Server. We have made a first step towards this by introducing the Deprecation Policy in February 2021 that assists to phase-in breaking changes, giving developers time to adapt. We will follow-up with the introduction of Release Automation and a branch model that will allow breaking changes only with a new major release, scheduled for the beginning of each calendar year.

We understand that some PRs are a long time in the making and we very much appreciate your contribution. We want to make it easy for PRs that contain a breaking change and were created before the introduction of the Deprecation Policy. These PRs can be merged with a breaking change without being phased-in before the beta release of Parse Server 5.0. We are making this exception because we appreciate that this is a time of transition that requires additional effort from contributors to adapt. We encourage everyone to prepare their PRs until the end of September and account for review time and possible adaptions.

If a PR contains a breaking change and should be merged before the beta release, please mention @parse-community/server-maintenance and we will coordinate with you to merge the PR.

Thanks for your contribution and support during this transition to Parse Server release automation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants