-
Notifications
You must be signed in to change notification settings - Fork 445
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
Fix: Contact service only fetched first 500 contacts #114
Conversation
Hmm, I think the startup endpoint should only be needed once, in the ctor, and should be able to update the self.params for future calls to /contacts, so that we don't end up with 3 requests per update. |
Could you be more specific about what you mean by "ctor"? The contacts API will only fetch 500 contacts with each step, so it is necessary to make one request per 500 contacts. |
Sorry, "ctor" -> "construtor" -> Look at the code in This is how the iCloud website works from what I've seen. The initial load calls out to the startup endpoint, for the initial set of data, which is then expanded by calls to eg the contacts endpoint for more data, or the changeset endpoint for diffs to existing data.
|
params_next.update({ | ||
'clientVersion': '2.1', | ||
'prefToken': req.json()["prefToken"], | ||
'syncToken': req.json()["syncToken"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'syncToken': req.json()["syncToken"], | |
'syncToken': self.response["syncToken"], |
params_next = dict(self.params) | ||
params_next.update({ | ||
'clientVersion': '2.1', | ||
'prefToken': req.json()["prefToken"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'prefToken': req.json()["prefToken"], | |
'prefToken': self.response["prefToken"], |
'limit': '0', | ||
'offset': '0', | ||
}) | ||
req = self.session.get( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So there is 2 requests to get 1 result ?
Please do 2 requests if more than 499 contacts only OR 1 request to get 0 to infinite contacts at once.
The iCloud API only pulls 500 contacts at a time. Previously, the contacts service in this library would only fetch the user's first 500 contacts.
This PR resolves the issue, so that all of the user's contacts can be pulled when calling
api.contacts.all()
Fixes #103