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:
LucasGGamerM
2025-04-19 21:47:38 -03:00
parent ab72435347
commit 8598dc2608

View File

@@ -1,9 +1,11 @@
package org.joinmastodon.android.utils;
import android.content.Context;
import android.widget.Toast;
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.AccountSessionManager;
import org.unifiedpush.android.connector.UnifiedPush;
@@ -29,6 +31,12 @@ public class UnifiedPushHelper {
public static void registerAllAccounts(@NonNull Context context) {
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(
context,
accountSession.getID(),