Skip to content

Commit 71388b9

Browse files
authored
fix: allowedGlobalOperations feature config not parsed after login - WPB-20784 🍒 (#3692)
1 parent 6088c8e commit 71388b9

File tree

7 files changed

+24
-126
lines changed

7 files changed

+24
-126
lines changed

wire-ios-data-model/Source/Model/FeatureConfig/Feature.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
import Foundation
2020

21-
private let zmLog = ZMSLog(tag: "Feature")
22-
2321
@objcMembers
2422
public class Feature: ZMManagedObject {
2523

wire-ios-request-strategy/Sources/Request Strategies/Feature configurations/FeatureConfigRequestStrategyTests.swift

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -473,53 +473,6 @@ final class FeatureConfigRequestStrategyTests: MessagingTestBase {
473473

474474
XCTAssertTrue(waitForAllGroupsToBeEmpty(withTimeout: 0.5))
475475
}
476-
477-
func test_ItProcessesEvent_Channels() {
478-
// Mock
479-
mockMLSClientManager
480-
.initializeMLSClientIfNeededForHasRegisteredMLSClientMlsFeatureIsBackendMLSEnabled_MockMethod =
481-
{ _, _, _, _ in }
482-
483-
// Given
484-
syncMOC.performAndWait {
485-
let channels = Feature.Channels(status: .disabled, config: .init())
486-
self.featureRepository.storeChannels(channels)
487-
488-
let config: NSDictionary = [
489-
"allowed_to_create_channels": "team-members",
490-
"allowed_to_open_channels": "admins"
491-
]
492-
493-
let data: NSDictionary = [
494-
"status": "enabled",
495-
"config": config
496-
]
497-
498-
let payload: NSDictionary = [
499-
"type": "feature-config.update",
500-
"data": data,
501-
"name": "channels"
502-
]
503-
504-
let event = ZMUpdateEvent(fromEventStreamPayload: payload, uuid: nil)!
505-
506-
// When
507-
self.sut.processEvents([event], liveEvents: false, prefetchResult: nil)
508-
}
509-
510-
XCTAssertTrue(waitForAllGroupsToBeEmpty(withTimeout: 0.5))
511-
512-
// Then
513-
syncMOC.performGroupedAndWait {
514-
let channels = self.featureRepository.fetchChannels()
515-
XCTAssertEqual(channels.status, .enabled)
516-
XCTAssertEqual(channels.config.allowedToCreateChannels, .teamMembers)
517-
XCTAssertEqual(channels.config.allowedToOpenChannels, .admins)
518-
}
519-
520-
XCTAssertTrue(waitForAllGroupsToBeEmpty(withTimeout: 0.5))
521-
}
522-
523476
}
524477

525478
// MARK: JSON

wire-ios-request-strategy/Sources/Request Strategies/Feature configurations/Payload/FeatureConfigsPayloadProcessor.swift

Lines changed: 5 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,6 @@ struct FeatureConfigsPayloadProcessor {
100100
)
101101
}
102102

103-
if let allowedGlobalOperations = payload.allowedGlobalOperations {
104-
repository.storeAllowedGlobalOperations(
105-
Feature.AllowedGlobalOperations(
106-
status: allowedGlobalOperations.status,
107-
config: allowedGlobalOperations.config
108-
)
109-
)
110-
}
111-
112103
if let mlsMigration = payload.mlsMigration {
113104
repository.storeMLSMigration(
114105
Feature.MLSMigration(
@@ -217,31 +208,6 @@ struct FeatureConfigsPayloadProcessor {
217208
)
218209
)
219210
}
220-
221-
if let channels = payload.channels {
222-
repository.storeChannels(
223-
Feature.Channels(
224-
status: channels.status,
225-
config: channels.config
226-
)
227-
)
228-
}
229-
230-
if let consumableNotifications = payload.consumableNotifications {
231-
repository.storeConsumableNotifications(
232-
Feature.ConsumableNotifications(
233-
status: consumableNotifications.status
234-
)
235-
)
236-
}
237-
238-
if let chatBubblesSimple = payload.chatBubbles {
239-
repository.storeChatBubblesSimple(
240-
Feature.ChatBubblesSimple(
241-
status: chatBubblesSimple.status
242-
)
243-
)
244-
}
245211
}
246212

247213
func processEventPayload(
@@ -279,16 +245,6 @@ struct FeatureConfigsPayloadProcessor {
279245
)
280246
repository.storeSelfDeletingMessages(.init(status: response.status, config: response.config))
281247

282-
case .allowedGlobalOperations:
283-
let response = try decoder.decode(
284-
FeatureStatusWithConfig<Feature.AllowedGlobalOperations.Config>.self,
285-
from: data
286-
)
287-
repository.storeAllowedGlobalOperations(.init(
288-
status: response.status,
289-
config: response.config
290-
))
291-
292248
case .conversationGuestLinks:
293249
let response = try decoder.decode(FeatureStatus.self, from: data)
294250
repository.storeConversationGuestLinks(.init(status: response.status))
@@ -324,17 +280,11 @@ struct FeatureConfigsPayloadProcessor {
324280
let response = try decoder.decode(FeatureStatusWithConfig<Feature.E2EI.Config>.self, from: data)
325281
repository.storeE2EI(.init(status: response.status, config: response.config))
326282

327-
case .channels:
328-
let response = try decoder.decode(FeatureStatusWithConfig<Feature.Channels.Config>.self, from: data)
329-
repository.storeChannels(.init(status: response.status, config: response.config))
330-
331-
case .consumableNotifications:
332-
let response = try decoder.decode(FeatureStatus.self, from: data)
333-
repository.storeConsumableNotifications(.init(status: response.status))
334-
335-
case .chatBubblesSimple:
336-
let response = try decoder.decode(FeatureStatus.self, from: data)
337-
repository.storeChatBubblesSimple(.init(status: response.status))
283+
case .channels, .consumableNotifications, .chatBubblesSimple, .allowedGlobalOperations:
284+
WireLogger.featureConfigs.warn(
285+
"decoding unsupported feature config: \"\(featureName)\", this should not happen",
286+
attributes: .safePublic
287+
)
338288
}
339289
}
340290

wire-ios-sync-engine/Source/UserSession/ZMUserSession/ZMUserSession.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -613,10 +613,10 @@ public final class ZMUserSession: NSObject {
613613
let clientSessionComponent = userSessionComponent.clientSessionComponent(
614614
clientID: clientID,
615615
completionHandlers: .init(
616-
onProcessedCallEvent: onProcessedCallEvent,
617-
onSelfClientInvalidated: onSelfClientInvalidated,
618-
onAuthenticationFailure: onAuthenticationFailure,
619-
onProcessedTypingUsers: onProcessedTypingUsers
616+
onProcessedCallEvent: { [weak self] in self?.onProcessedCallEvent(callEventInfo: $0) },
617+
onSelfClientInvalidated: { [weak self] in await self?.onSelfClientInvalidated() },
618+
onAuthenticationFailure: { [weak self] in self?.onAuthenticationFailure() },
619+
onProcessedTypingUsers: { [weak self] in self?.onProcessedTypingUsers(typingUsersInfo: $0) }
620620
)
621621
)
622622
self.clientSessionComponent = clientSessionComponent
@@ -686,6 +686,7 @@ public final class ZMUserSession: NSObject {
686686
// MARK: - Deinitalize
687687

688688
deinit {
689+
userSessionComponent = nil
689690
require(isTornDown, "tearDown must be called before the ZMUserSession is deallocated")
690691
}
691692

@@ -1393,8 +1394,7 @@ extension ZMUserSession: SyncAgentDelegate {
13931394

13941395
private func fetchAndStoreFeatureConfig() async {
13951396
do {
1396-
var getFeatureConfigAction = GetFeatureConfigsAction()
1397-
try await getFeatureConfigAction.perform(in: notificationContext)
1397+
try await clientSessionComponent?.featureConfigRepository.pullFeatureConfigs()
13981398
} catch {
13991399
WireLogger.featureConfigs.error("Failed getFeatureConfigAction: \(String(reflecting: error))")
14001400
}

wire-ios-sync-engine/Tests/Source/UserSession/ZMUserSessionTests.swift

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,10 @@ final class ZMUserSessionTests: ZMUserSessionTestsBase {
125125
}
126126
}
127127

128-
// TODO: [WPB-16224] Re-enable
129128
func testItSlowSyncsAfterRegisteringClient() async throws {
130129
// GIVEN
130+
mockCoreCryptoProvider.registerMlsTransport_MockMethod = { _ in }
131+
131132
let userClient = await syncMOC.perform {
132133
self.createSelfClient()
133134
}
@@ -136,6 +137,7 @@ final class ZMUserSessionTests: ZMUserSessionTestsBase {
136137
await syncMOC.perform {
137138
self.sut.didRegisterSelfUserClient(userClient)
138139
}
140+
XCTAssertTrue(waitForAllGroupsToBeEmpty(withTimeout: 0.5))
139141

140142
// THEN
141143
let syncStatus = try await syncMOC.perform {
@@ -327,19 +329,13 @@ final class ZMUserSessionTests: ZMUserSessionTestsBase {
327329
// WHEN
328330
sut.didGoOffline()
329331

330-
mockGetFeatureConfigsActionHandler = MockActionHandler<GetFeatureConfigsAction>(
331-
results: [.success(())],
332-
context: syncMOC.notificationContext
333-
)
334-
335332
syncMOC.performAndWait {
336333
sut.didFinishIncrementalSync(isRecovering: false)
337334
}
338335
XCTAssertTrue(waitForAllGroupsToBeEmpty(withTimeout: 1))
339336

340337
// THEN
341338
wait(forConditionToBeTrue: self.sut.networkState == .offline, timeout: 5)
342-
XCTAssertEqual(mockGetFeatureConfigsActionHandler.performedActions.count, 1)
343339
}
344340

345341
func testThatWeSetUserSessionToSynchronizingWhenSyncIsStarted() {
@@ -531,7 +527,6 @@ final class ZMUserSessionTests: ZMUserSessionTestsBase {
531527

532528
XCTAssertEqual(mockRecurringActionService.performActionsIfNeeded_Invocations.count, 1)
533529

534-
XCTAssertEqual(getFeatureConfigsActionHandler.performedActions.count, 1)
535530
XCTAssertEqual(fetchBackendMLSPublicKeysActionHandler.performedActions.count, 1)
536531
}
537532

wire-ios-sync-engine/Tests/Source/UserSession/ZMUserSessionTestsBase.swift

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ class ZMUserSessionTestsBase: MessagingTest {
4343
var mediaManager: MediaManagerType!
4444
var flowManagerMock: FlowManagerMock!
4545
var dataChangeNotificationsCount: UInt = 0
46-
var mockSyncStateDelegate: MockSyncStateDelegate!
47-
var mockGetFeatureConfigsActionHandler: MockActionHandler<GetFeatureConfigsAction>!
4846
var mockFetchBackendMLSPublicKeysActionHandler: MockActionHandler<FetchBackendMLSPublicKeysAction>!
47+
4948
var mockRecurringActionService: MockRecurringActionServiceInterface!
5049
var mockCoreCryptoProvider: MockCoreCryptoProviderProtocol!
5150

@@ -56,7 +55,6 @@ class ZMUserSessionTestsBase: MessagingTest {
5655

5756
WireCallCenterV3Factory.wireCallCenterClass = WireCallCenterV3Mock.self
5857

59-
mockGetFeatureConfigsActionHandler = .init(result: .success(()), context: syncMOC.notificationContext)
6058
let backendPublicKeys = BackendMLSPublicKeys(removal: .init(ed25519: .init([1, 2, 3])))
6159
mockFetchBackendMLSPublicKeysActionHandler = .init(
6260
result: .success(backendPublicKeys),
@@ -133,6 +131,7 @@ class ZMUserSessionTestsBase: MessagingTest {
133131

134132
WireCallCenterV3Factory.wireCallCenterClass = WireCallCenterV3.self
135133

134+
transportSession = nil
136135
backendEnvironment = nil
137136
wireAPIBackendEnvironment = nil
138137
baseURL = nil
@@ -146,14 +145,18 @@ class ZMUserSessionTestsBase: MessagingTest {
146145
mockRecurringActionService = nil
147146
mockEARService.delegate = nil
148147
mockEARService = nil
149-
let sut = sut
150-
self.sut = nil
151-
mockGetFeatureConfigsActionHandler = nil
152148
mockFetchBackendMLSPublicKeysActionHandler = nil
153149
mockCoreCryptoProvider = nil
154-
sut?.tearDown()
150+
mockPushChannel = nil
151+
152+
weak var weakSut: ZMUserSession?
153+
weakSut = sut
154+
sut.tearDown()
155+
sut = nil
155156

156157
super.tearDown()
158+
159+
XCTAssertNil(weakSut, "sut should have been deallocated after tearDown")
157160
}
158161

159162
func createSut() -> ZMUserSession {

wire-ios-sync-engine/Tests/TestsPlans/AllTests.xctestplan

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
"EventProcessingPerformanceTests",
5353
"SessionManagerTests\/testThatSessionManagerSetsUpAPNSEnvironmentOnLaunch()",
5454
"ZMMissingUpdateEventsTranscoderTests",
55-
"ZMUserSessionTests\/testItSlowSyncsAfterRegisteringClient()",
5655
"ZMUserSessionTests\/testItSlowSyncsAfterRegisteringMLSClient()"
5756
],
5857
"target" : {

0 commit comments

Comments
 (0)