-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
72 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...ify/Client/Wallet/ProtocolEngine/wc_notifyDelete/NotifyDeleteSubscriptionSubscriber.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import Foundation | ||
import Combine | ||
|
||
class NotifyDeleteSubscriptionSubscriber { | ||
|
||
private let networkingInteractor: NetworkInteracting | ||
private let kms: KeyManagementServiceProtocol | ||
private let logger: ConsoleLogging | ||
private let notifySubscriptionsBuilder: NotifySubscriptionsBuilder | ||
private let notifySubscriptionsUpdater: NotifySubsctiptionsUpdater | ||
|
||
init( | ||
networkingInteractor: NetworkInteracting, | ||
kms: KeyManagementServiceProtocol, | ||
logger: ConsoleLogging, | ||
notifySubscriptionsBuilder: NotifySubscriptionsBuilder, | ||
notifySubscriptionsUpdater: NotifySubsctiptionsUpdater | ||
) { | ||
self.networkingInteractor = networkingInteractor | ||
self.kms = kms | ||
self.logger = logger | ||
self.notifySubscriptionsBuilder = notifySubscriptionsBuilder | ||
self.notifySubscriptionsUpdater = notifySubscriptionsUpdater | ||
|
||
subscribeForDeleteResponse() | ||
} | ||
} | ||
|
||
private extension NotifyDeleteSubscriptionSubscriber { | ||
|
||
func subscribeForDeleteResponse() { | ||
networkingInteractor.subscribeOnResponse( | ||
protocolMethod: NotifyDeleteProtocolMethod(), | ||
requestOfType: NotifyDeletePayload.Wrapper.self, | ||
responseOfType: NotifyDeleteResponsePayload.Wrapper.self, | ||
errorHandler: logger | ||
) { [unowned self] payload in | ||
|
||
let (responsePayload, _) = try NotifyDeleteResponsePayload.decodeAndVerify(from: payload.response) | ||
|
||
let subscriptions = try await notifySubscriptionsBuilder.buildSubscriptions(responsePayload.subscriptions) | ||
|
||
try await notifySubscriptionsUpdater.update(subscriptions: subscriptions, for: responsePayload.account) | ||
|
||
logger.debug("Received Notify Delete response") | ||
|
||
networkingInteractor.unsubscribe(topic: payload.topic) | ||
kms.deleteSymmetricKey(for: payload.topic) | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters