1
0
Fork 1
mirror of https://codeberg.org/tom79/Fedilab.git synced 2025-03-27 09:09:57 +02:00

Unregister push endpoint onUnregistered

This commit is contained in:
sim 2025-02-25 10:20:03 +01:00
parent b26b10c651
commit ec60b63c68
2 changed files with 25 additions and 1 deletions
app/src/main/java/app/fedilab/android/mastodon

View file

@ -45,6 +45,23 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class PushNotifications {
public static void unregisterPushNotifications(Context context, String slug) {
new Thread(() -> {
String[] slugArray = slug.split("@");
BaseAccount accountDb = null;
try {
accountDb = new Account(context).getUniqAccount(slugArray[0], slugArray[1]);
} catch (DBException e) {
e.printStackTrace();
}
if (accountDb == null) {
return;
}
MastodonNotificationsService mastodonNotificationsService = init(context, accountDb.instance);
mastodonNotificationsService.deletePushsubscription(accountDb.token);
});
}
public static void registerPushNotifications(Context context, PushEndpoint pushEndpoint, String slug) {

View file

@ -56,6 +56,13 @@ public class PushServiceImpl extends PushService {
}
@Override
public void onUnregistered(@NonNull String s) {
public void onUnregistered(@NonNull String slug) {
Context context = getApplicationContext();
if (context != null) {
synchronized (this) {
PushNotifications
.unregisterPushNotifications(context, slug);
}
}
}
}