Bug 1346061 part 3 - Trigger a sync/email-verification-check on empty FxA push message. r=Grisha,nalexander

MozReview-Commit-ID: ABUm6LZij4M

--HG--
extra : rebase_source : 4818f95bf7dbe3f1c9891f3aeb7ade4c83d58870
This commit is contained in:
Edouard Oger 2017-03-22 13:10:09 -04:00
Родитель 965ba52d24
Коммит 466b73fea5
1 изменённых файлов: 13 добавлений и 2 удалений

Просмотреть файл

@ -38,8 +38,8 @@ public class FxAccountPushHandler {
if (message == null) {
// An empty body means we should check the verification state of the account (FxA sends this
// when the account email is verified for example).
// TODO: We're only registering the push endpoint when we are in the Married state, that's why we're skipping the message :(
Log.d(LOG_TAG, "Skipping empty message");
// See notifyUpdate in https://github.com/mozilla/fxa-auth-server/blob/master/lib/push.js
handleVerification(context);
return;
}
try {
@ -61,6 +61,17 @@ public class FxAccountPushHandler {
}
}
private static void handleVerification(Context context) {
AndroidFxAccount fxAccount = AndroidFxAccount.fromContext(context);
if (fxAccount == null) {
Log.e(LOG_TAG, "The Android account does not exist anymore");
return;
}
Log.i(LOG_TAG, "Received 'accountVerified' push event, requesting immediate sync");
// This will trigger an email verification check and a sync.
fxAccount.requestImmediateSync(null, null);
}
private static void handleCollectionChanged(Context context, JSONObject data) throws JSONException {
JSONArray collections = data.getJSONArray("collections");
int len = collections.length();