Remove push subscription when logging out of account

This commit is contained in:
Shadowfacts 2024-04-08 22:50:39 -04:00
parent 241e6f7e3a
commit 7a47b09b39
1 changed files with 7 additions and 0 deletions

View File

@ -8,6 +8,8 @@
import Foundation import Foundation
import UserAccounts import UserAccounts
import PushNotifications
import Pachyderm
@MainActor @MainActor
class LogoutService { class LogoutService {
@ -20,7 +22,12 @@ class LogoutService {
} }
func run() { func run() {
let accountInfo = self.accountInfo
Task.detached { Task.detached {
if await PushManager.shared.pushSubscription(account: accountInfo) != nil {
_ = try? await self.mastodonController.run(Pachyderm.PushSubscription.delete())
await PushManager.shared.removeSubscription(account: accountInfo)
}
try? await self.mastodonController.client.revokeAccessToken() try? await self.mastodonController.client.revokeAccessToken()
} }
MastodonController.removeForAccount(accountInfo) MastodonController.removeForAccount(accountInfo)