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

View File

@ -8,6 +8,8 @@
import Foundation
import UserAccounts
import PushNotifications
import Pachyderm
@MainActor
class LogoutService {
@ -20,7 +22,12 @@ class LogoutService {
}
func run() {
let accountInfo = self.accountInfo
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()
}
MastodonController.removeForAccount(accountInfo)