fix(UnifiedPushHelper.java): check if vapidkey parameter is null before proceeding
This will only happen on very unlikely circumstances, but it happened to me, so it's fixed now
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
package org.joinmastodon.android.utils;
|
package org.joinmastodon.android.utils;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.joinmastodon.android.api.requests.oauth.GetOauthToken;
|
||||||
import org.joinmastodon.android.api.session.AccountSession;
|
import org.joinmastodon.android.api.session.AccountSession;
|
||||||
import org.joinmastodon.android.api.session.AccountSessionManager;
|
import org.joinmastodon.android.api.session.AccountSessionManager;
|
||||||
import org.unifiedpush.android.connector.UnifiedPush;
|
import org.unifiedpush.android.connector.UnifiedPush;
|
||||||
@@ -29,6 +31,12 @@ public class UnifiedPushHelper {
|
|||||||
|
|
||||||
public static void registerAllAccounts(@NonNull Context context) {
|
public static void registerAllAccounts(@NonNull Context context) {
|
||||||
for (AccountSession accountSession : AccountSessionManager.getInstance().getLoggedInAccounts()){
|
for (AccountSession accountSession : AccountSessionManager.getInstance().getLoggedInAccounts()){
|
||||||
|
// Sometimes this is null when the account's server has died (don't ask me how I know this)
|
||||||
|
if (accountSession.app.vapidKey == null) {
|
||||||
|
// TODO: throw this on a translatable string and tell the user to log out and back in
|
||||||
|
Toast.makeText(context, "Error on unified push subscription: no valid vapid key for account " + accountSession.getFullUsername(), Toast.LENGTH_LONG).show();
|
||||||
|
break;
|
||||||
|
}
|
||||||
UnifiedPush.register(
|
UnifiedPush.register(
|
||||||
context,
|
context,
|
||||||
accountSession.getID(),
|
accountSession.getID(),
|
||||||
|
|||||||
Reference in New Issue
Block a user