mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2025-06-23 21:50:10 +03:00
Unregister push endpoint onUnregistered
This commit is contained in:
parent
b26b10c651
commit
ec60b63c68
2 changed files with 25 additions and 1 deletions
|
@ -45,6 +45,23 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
||||||
|
|
||||||
public class PushNotifications {
|
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) {
|
public static void registerPushNotifications(Context context, PushEndpoint pushEndpoint, String slug) {
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,13 @@ public class PushServiceImpl extends PushService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue