Use standard webpush for UnifiedPush only
This commit is contained in:
parent
00e90e5f21
commit
66824aadb9
3 changed files with 12 additions and 7 deletions
|
@ -39,7 +39,7 @@ public class UnifiedPushNotificationReceiver extends MessagingReceiver{
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
PublicKeySet ks = endpoint.getPubKeySet();
|
PublicKeySet ks = endpoint.getPubKeySet();
|
||||||
if (ks != null){
|
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 {
|
} else {
|
||||||
// ks should never be null on new endpoint
|
// ks should never be null on new endpoint
|
||||||
account.getPushSubscriptionManager().registerAccountForPush(null, endpoint.getUrl());
|
account.getPushSubscriptionManager().registerAccountForPush(null, endpoint.getUrl());
|
||||||
|
|
|
@ -166,17 +166,21 @@ public class PushSubscriptionManager{
|
||||||
|
|
||||||
//work-around for adding the randomAccountId
|
//work-around for adding the randomAccountId
|
||||||
String newEndpoint = endpoint;
|
String newEndpoint = endpoint;
|
||||||
if (endpoint.startsWith("https://app.joinmastodon.org/relay-to/fcm/"))
|
Boolean standard = true;
|
||||||
|
if (endpoint.startsWith("https://app.joinmastodon.org/relay-to/fcm/")){
|
||||||
newEndpoint+=pushAccountID;
|
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(()->{
|
MastodonAPIController.runInBackground(()->{
|
||||||
Log.d(TAG, "registerAccountForPush: started for "+accountID);
|
Log.d(TAG, "registerAccountForPush: started for "+accountID);
|
||||||
new RegisterForPushNotifications(endpoint,
|
new RegisterForPushNotifications(endpoint,
|
||||||
|
standard,
|
||||||
p256dh,
|
p256dh,
|
||||||
auth,
|
auth,
|
||||||
subscription==null ? PushSubscription.Alerts.ofAll() : subscription.alerts,
|
subscription==null ? PushSubscription.Alerts.ofAll() : subscription.alerts,
|
||||||
|
|
|
@ -4,10 +4,11 @@ import org.joinmastodon.android.api.MastodonAPIRequest;
|
||||||
import org.joinmastodon.android.model.PushSubscription;
|
import org.joinmastodon.android.model.PushSubscription;
|
||||||
|
|
||||||
public class RegisterForPushNotifications extends MastodonAPIRequest<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);
|
super(HttpMethod.POST, "/push/subscription", PushSubscription.class);
|
||||||
Request r=new Request();
|
Request r=new Request();
|
||||||
r.subscription.endpoint=endpoint;
|
r.subscription.endpoint=endpoint;
|
||||||
|
r.subscription.standard = standard;
|
||||||
r.data.alerts=alerts;
|
r.data.alerts=alerts;
|
||||||
r.policy=policy;
|
r.policy=policy;
|
||||||
r.subscription.keys.p256dh=encryptionKey;
|
r.subscription.keys.p256dh=encryptionKey;
|
||||||
|
@ -28,7 +29,7 @@ public class RegisterForPushNotifications extends MastodonAPIRequest<PushSubscri
|
||||||
private static class Subscription{
|
private static class Subscription{
|
||||||
public String endpoint;
|
public String endpoint;
|
||||||
// Use standard push notifications if available
|
// Use standard push notifications if available
|
||||||
public Boolean standard = true;
|
public Boolean standard;
|
||||||
public Keys keys=new Keys();
|
public Keys keys=new Keys();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue