Use standard webpush for UnifiedPush only

This commit is contained in:
sim 2025-01-14 16:13:31 +01:00
parent 00e90e5f21
commit 66824aadb9
3 changed files with 12 additions and 7 deletions

View file

@ -39,7 +39,7 @@ public class UnifiedPushNotificationReceiver extends MessagingReceiver{
if (account != null) {
PublicKeySet ks = endpoint.getPubKeySet();
if (ks != null){
account.getPushSubscriptionManager().registerAccountForPush(null, endpoint.getUrl(), ks.getPubKey(), ks.getAuth());
account.getPushSubscriptionManager().registerAccountForPush(null, true, endpoint.getUrl(), ks.getPubKey(), ks.getAuth());
} else {
// ks should never be null on new endpoint
account.getPushSubscriptionManager().registerAccountForPush(null, endpoint.getUrl());

View file

@ -166,17 +166,21 @@ public class PushSubscriptionManager{
//work-around for adding the randomAccountId
String newEndpoint = endpoint;
if (endpoint.startsWith("https://app.joinmastodon.org/relay-to/fcm/"))
newEndpoint += pushAccountID;
Boolean standard = true;
if (endpoint.startsWith("https://app.joinmastodon.org/relay-to/fcm/")){
newEndpoint+=pushAccountID;
standard = false;
}
registerAccountForPush(subscription, newEndpoint, encodedPublicKey, encodedAuthKey);
registerAccountForPush(subscription, standard, newEndpoint, encodedPublicKey, encodedAuthKey);
});
}
public void registerAccountForPush(PushSubscription subscription, String endpoint, String p256dh, String auth){
public void registerAccountForPush(PushSubscription subscription, Boolean standard, String endpoint, String p256dh, String auth){
MastodonAPIController.runInBackground(()->{
Log.d(TAG, "registerAccountForPush: started for "+accountID);
new RegisterForPushNotifications(endpoint,
standard,
p256dh,
auth,
subscription==null ? PushSubscription.Alerts.ofAll() : subscription.alerts,

View file

@ -4,10 +4,11 @@ import org.joinmastodon.android.api.MastodonAPIRequest;
import org.joinmastodon.android.model.PushSubscription;
public class RegisterForPushNotifications extends MastodonAPIRequest<PushSubscription>{
public RegisterForPushNotifications(String endpoint, String encryptionKey, String authKey, PushSubscription.Alerts alerts, PushSubscription.Policy policy){
public RegisterForPushNotifications(String endpoint, Boolean standard, String encryptionKey, String authKey, PushSubscription.Alerts alerts, PushSubscription.Policy policy){
super(HttpMethod.POST, "/push/subscription", PushSubscription.class);
Request r=new Request();
r.subscription.endpoint=endpoint;
r.subscription.standard = standard;
r.data.alerts=alerts;
r.policy=policy;
r.subscription.keys.p256dh=encryptionKey;
@ -28,7 +29,7 @@ public class RegisterForPushNotifications extends MastodonAPIRequest<PushSubscri
private static class Subscription{
public String endpoint;
// Use standard push notifications if available
public Boolean standard = true;
public Boolean standard;
public Keys keys=new Keys();
}