add policy for push

This commit is contained in:
Thomas 2023-02-19 19:10:10 +01:00
parent e013dc96c0
commit 8c49260a67
6 changed files with 14 additions and 16 deletions

View file

@ -144,9 +144,9 @@ dependencies {
implementation "ch.acra:acra-limiter:5.9.3"
implementation "ch.acra:acra-dialog:5.9.6"
implementation "com.madgag.spongycastle:bctls-jdk15on:1.58.0.0"
implementation 'com.github.UnifiedPush:android-connector:2.0.1'
implementation 'com.github.UnifiedPush:android-connector:2.1.1'
// implementation 'com.github.UnifiedPush:android-foss_embedded_fcm_distributor:1.0.0-beta1'
playstoreImplementation('com.github.UnifiedPush:android-embedded_fcm_distributor:2.1.3') {
playstoreImplementation('com.github.UnifiedPush:android-embedded_fcm_distributor:2.2.0') {
exclude group: 'com.google.firebase', module: 'firebase-core'
exclude group: 'com.google.firebase', module: 'firebase-analytics'
exclude group: 'com.google.firebase', module: 'firebase-measurement-connector'
@ -191,20 +191,11 @@ dependencies {
playstoreImplementation "androidx.mediarouter:mediarouter:1.3.0"
playstoreImplementation 'com.google.android.gms:play-services-cast-framework:21.0.1'
playstoreImplementation "com.google.android.gms:play-services-cast-tv:19.0.1"
playstoreImplementation "com.google.android.gms:play-services-cast:21.0.1"
playstoreImplementation "androidx.mediarouter:mediarouter:1.3.0"
playstoreImplementation 'com.google.android.gms:play-services-cast-framework:21.0.1'
//----> Other flavors
fdroidImplementation 'su.litvak.chromecast:api-v2:0.11.3'
fdroidImplementation 'com.fasterxml.jackson.core:jackson-core:2.12.0'
fdroidImplementation 'org.slf4j:slf4j-simple:1.7.30'
fdroidImplementation 'com.github.evozi:Cyanea:1.0.7'
fdroidImplementation 'su.litvak.chromecast:api-v2:0.11.3'
fdroidImplementation 'com.fasterxml.jackson.core:jackson-core:2.12.0'
fdroidImplementation 'org.slf4j:slf4j-simple:1.7.30'
}
def getCurrentFlavor() {

View file

@ -75,7 +75,8 @@ public interface MastodonNotificationsService {
@Field("data[alerts][status]") boolean status,
@Field("data[alerts][update]") boolean update,
@Field("data[alerts][admin.sign_up]") boolean admin_sign_up,
@Field("data[alerts][admin.report]") boolean admin_report
@Field("data[alerts][admin.report]") boolean admin_report,
@Field("data[policy]") String policy
);
@ -93,7 +94,8 @@ public interface MastodonNotificationsService {
@Field("data[alerts][favourite]") boolean favourite,
@Field("data[alerts][reblog]") boolean reblog,
@Field("data[alerts][mention]") boolean mention,
@Field("data[alerts][poll]") boolean poll
@Field("data[alerts][poll]") boolean poll,
@Field("data[policy]") String policy
);
@DELETE("push/subscription")

View file

@ -22,6 +22,8 @@ public class PushSubscription {
public String id;
@SerializedName("endpoint")
public String endpoint;
@SerializedName("policy")
public String policy;
@SerializedName("alerts")
public Alerts alerts;
@SerializedName("server_key")

View file

@ -95,7 +95,7 @@ public class PushNotifications {
notif_status,
notif_updates,
notif_signup,
notif_report);
notif_report, "all");
if (pushSubscriptionCall != null) {
try {
Response<PushSubscription> pushSubscriptionResponse = pushSubscriptionCall.execute();

View file

@ -16,6 +16,7 @@ package app.fedilab.android.mastodon.services;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import androidx.annotation.NonNull;
@ -23,6 +24,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.unifiedpush.android.connector.MessagingReceiver;
import app.fedilab.android.mastodon.helper.Helper;
import app.fedilab.android.mastodon.helper.NotificationsHelper;
import app.fedilab.android.mastodon.helper.PushNotifications;
@ -38,6 +40,7 @@ public class CustomReceiver extends MessagingReceiver {
@Override
public void onMessage(@NotNull Context context, @NotNull byte[] message, @NotNull String slug) {
// Called when a new message is received. The message contains the full POST body of the push message
Log.v(Helper.TAG, "onMessage: " + slug);
new Thread(() -> {
try {
/*Notification notification = ECDHFedilab.decryptNotification(context, slug, message);

View file

@ -314,7 +314,7 @@ public class NotificationsVM extends AndroidViewModel {
MastodonNotificationsService mastodonNotificationsService = init(instance);
new Thread(() -> {
PushSubscription pushSubscription = null;
Call<PushSubscription> pushSubscriptionCall = mastodonNotificationsService.pushSubscription(token, endpoint, keys_p256dh, keys_auth, follow, favourite, reblog, mention, poll, status, updates, signup, report);
Call<PushSubscription> pushSubscriptionCall = mastodonNotificationsService.pushSubscription(token, endpoint, keys_p256dh, keys_auth, follow, favourite, reblog, mention, poll, status, updates, signup, report, "all");
if (pushSubscriptionCall != null) {
try {
Response<PushSubscription> pushSubscriptionResponse = pushSubscriptionCall.execute();
@ -390,7 +390,7 @@ public class NotificationsVM extends AndroidViewModel {
MastodonNotificationsService mastodonNotificationsService = init(instance);
new Thread(() -> {
PushSubscription pushSubscription = null;
Call<PushSubscription> pushSubscriptionCall = mastodonNotificationsService.updatePushSubscription(token, follow, favourite, reblog, mention, poll);
Call<PushSubscription> pushSubscriptionCall = mastodonNotificationsService.updatePushSubscription(token, follow, favourite, reblog, mention, poll, "all");
if (pushSubscriptionCall != null) {
try {
Response<PushSubscription> pushSubscriptionResponse = pushSubscriptionCall.execute();