Skip to content

Commit

Permalink
Fixes according to review
Browse files Browse the repository at this point in the history
* Deprecate PubNub.IncludeFields and introduce PubNub.UserIncludeFields and PubNub.ChannelIncludeFields
* Replace ObjectsUUIDRouter with ObjectsUserRouter
* Replace other occurences of UUID with User in AppContext related code
* Other minor fixes
* Introduce new method for removing Channel metadata
* Fixes for acceptance tests
  • Loading branch information
jguz-pubnub committed Nov 27, 2024
1 parent f4ae8a3 commit 3e292cf
Show file tree
Hide file tree
Showing 15 changed files with 229 additions and 134 deletions.
16 changes: 8 additions & 8 deletions PubNub.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -280,15 +280,15 @@
35CDFEBA22E77E2B00F3B9F2 /* URLSessionConfiguration+PubNubTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35CDFEB922E77E2B00F3B9F2 /* URLSessionConfiguration+PubNubTests.swift */; };
35CDFEBC22E789B200F3B9F2 /* ConstantsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35CDFEBB22E789B200F3B9F2 /* ConstantsTests.swift */; };
35CDFEC022E7B48000F3B9F2 /* ImportTestResource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35CDFEBF22E7B48000F3B9F2 /* ImportTestResource.swift */; };
35CF548C248971BF0099FE81 /* ObjectsUUIDRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35CF548B248971BF0099FE81 /* ObjectsUUIDRouter.swift */; };
35CF548C248971BF0099FE81 /* ObjectsUserRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35CF548B248971BF0099FE81 /* ObjectsUserRouter.swift */; };
35CF548E248971CD0099FE81 /* ObjectsChannelRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35CF548D248971CD0099FE81 /* ObjectsChannelRouter.swift */; };
35CF5490248971DD0099FE81 /* ObjectsMembershipsRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35CF548F248971DD0099FE81 /* ObjectsMembershipsRouter.swift */; };
35CF54922489912F0099FE81 /* PubNubUserMetadata.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35CF54912489912F0099FE81 /* PubNubUserMetadata.swift */; };
35CF54942489918E0099FE81 /* PubNubChannelMetadata.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35CF54932489918E0099FE81 /* PubNubChannelMetadata.swift */; };
35CF54962489B3760099FE81 /* PubNubMembershipMetadata.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35CF54952489B3760099FE81 /* PubNubMembershipMetadata.swift */; };
35CF549C248ABE8B0099FE81 /* PubNubObjectMetadataPatcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35CF549B248ABE8B0099FE81 /* PubNubObjectMetadataPatcher.swift */; };
35CF549D248D73500099FE81 /* SubscribeObjectPayload.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35AC162C2485E3C600A66030 /* SubscribeObjectPayload.swift */; };
35CF549E248D913A0099FE81 /* ObjectsUUIDRouterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35DA9AB42335491F00867989 /* ObjectsUUIDRouterTests.swift */; };
35CF549E248D913A0099FE81 /* ObjectsUserRouterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35DA9AB42335491F00867989 /* ObjectsUserRouterTests.swift */; };
35CF54A0248D96320099FE81 /* SubscribeRouterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 359287BC23173D490046F7A2 /* SubscribeRouterTests.swift */; };
35CF54A1248DA6430099FE81 /* ObjectsChannelRouterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3562DBC22345066F006DFFBC /* ObjectsChannelRouterTests.swift */; };
35CF54A3248DA8650099FE81 /* ObjectsMembershipsRouterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35CF54A2248DA8650099FE81 /* ObjectsMembershipsRouterTests.swift */; };
Expand Down Expand Up @@ -909,7 +909,7 @@
35CDFEB922E77E2B00F3B9F2 /* URLSessionConfiguration+PubNubTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URLSessionConfiguration+PubNubTests.swift"; sourceTree = "<group>"; };
35CDFEBB22E789B200F3B9F2 /* ConstantsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConstantsTests.swift; sourceTree = "<group>"; };
35CDFEBF22E7B48000F3B9F2 /* ImportTestResource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImportTestResource.swift; sourceTree = "<group>"; };
35CF548B248971BF0099FE81 /* ObjectsUUIDRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjectsUUIDRouter.swift; sourceTree = "<group>"; };
35CF548B248971BF0099FE81 /* ObjectsUserRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjectsUserRouter.swift; sourceTree = "<group>"; };
35CF548D248971CD0099FE81 /* ObjectsChannelRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjectsChannelRouter.swift; sourceTree = "<group>"; };
35CF548F248971DD0099FE81 /* ObjectsMembershipsRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjectsMembershipsRouter.swift; sourceTree = "<group>"; };
35CF54912489912F0099FE81 /* PubNubUserMetadata.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PubNubUserMetadata.swift; sourceTree = "<group>"; };
Expand All @@ -934,7 +934,7 @@
35DA9AAC2331674000867989 /* .swiftformat */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = .swiftformat; sourceTree = "<group>"; };
35DA9AB02334479800867989 /* objects_uuid_all_success.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = objects_uuid_all_success.json; path = Tests/PubNubTests/Mocking/Responses/Objects/objects_uuid_all_success.json; sourceTree = SOURCE_ROOT; };
35DA9AB2233447F200867989 /* objects_uuid_fetch_success.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = objects_uuid_fetch_success.json; sourceTree = "<group>"; };
35DA9AB42335491F00867989 /* ObjectsUUIDRouterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjectsUUIDRouterTests.swift; sourceTree = "<group>"; };
35DA9AB42335491F00867989 /* ObjectsUserRouterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjectsUserRouterTests.swift; sourceTree = "<group>"; };
35DB0C4A2874768C001E1F76 /* FlatJSONCodable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlatJSONCodable.swift; sourceTree = "<group>"; };
35DB0C4C287476BF001E1F76 /* OptionalChange.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OptionalChange.swift; sourceTree = "<group>"; };
35E381FC23149BA900A17549 /* AutomaticRetryTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AutomaticRetryTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1306,7 +1306,7 @@
35293A792368F9680049A71F /* MessageActionsRouter.swift */,
35CF548D248971CD0099FE81 /* ObjectsChannelRouter.swift */,
35CF548F248971DD0099FE81 /* ObjectsMembershipsRouter.swift */,
35CF548B248971BF0099FE81 /* ObjectsUUIDRouter.swift */,
35CF548B248971BF0099FE81 /* ObjectsUserRouter.swift */,
35A6C77C22FB159F00E97CC5 /* PresenceRouter.swift */,
35A6C7A722FBCC8B00E97CC5 /* PushRouter.swift */,
3534D4E322C57659008E89FA /* PublishRouter.swift */,
Expand Down Expand Up @@ -1716,7 +1716,7 @@
359287B3231720C20046F7A2 /* PublishRouterTests.swift */,
359287BC23173D490046F7A2 /* SubscribeRouterTests.swift */,
3557CDFF237F6380004BBACC /* TimeRouterTests.swift */,
35DA9AB42335491F00867989 /* ObjectsUUIDRouterTests.swift */,
35DA9AB42335491F00867989 /* ObjectsUserRouterTests.swift */,
3562DBC22345066F006DFFBC /* ObjectsChannelRouterTests.swift */,
35CF54A2248DA8650099FE81 /* ObjectsMembershipsRouterTests.swift */,
);
Expand Down Expand Up @@ -3604,7 +3604,7 @@
3DBFF2BB2C203EDC00142985 /* KMPUploadable.swift in Sources */,
35A66A8022F861BA00AC67A9 /* AutomaticRetry.swift in Sources */,
357D1C1B22CB04C4003625BA /* Bool+PubNub.swift in Sources */,
35CF548C248971BF0099FE81 /* ObjectsUUIDRouter.swift in Sources */,
35CF548C248971BF0099FE81 /* ObjectsUserRouter.swift in Sources */,
3585033222CD138300A11D9A /* Set+PubNub.swift in Sources */,
358C641C238C5232009CE354 /* FCMAndroidPayload.swift in Sources */,
35FAC1E72357C2AE0096E418 /* PubNubError.swift in Sources */,
Expand Down Expand Up @@ -3784,7 +3784,7 @@
3D38A0102B35AF6B006928E7 /* SubscribeEffectsTests.swift in Sources */,
3D38A0142B35AF6B006928E7 /* PresenceTransitionTests.swift in Sources */,
OBJ_49 /* PubNubTests.swift in Sources */,
35CF549E248D913A0099FE81 /* ObjectsUUIDRouterTests.swift in Sources */,
35CF549E248D913A0099FE81 /* ObjectsUserRouterTests.swift in Sources */,
3DB925642B7A2BF5001B7E90 /* SubscriptionSetTests.swift in Sources */,
35458BA3230CB3570085B502 /* SubscribeSessionFactoryTests.swift in Sources */,
3580A5A222F13C6500B12E5E /* SessionStreamAwait.swift in Sources */,
Expand Down
6 changes: 3 additions & 3 deletions PubNubSpace/Sources/Space+PubNub.swift
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public extension PubNubSpaceInterface {
) {
let router = ObjectsChannelRouter(
.all(
include: PubNub.IncludeFields(custom: includeCustom).channelIncludeFields,
include: PubNub.ChannelIncludeFields(custom: includeCustom).includeFields,
totalCount: includeTotalCount,
filter: filter,
sort: sort.map { $0.routerParameter },
Expand Down Expand Up @@ -229,7 +229,7 @@ public extension PubNubSpaceInterface {
completion: @escaping (Result<PubNubSpace, Error>) -> Void
) {
let router = ObjectsChannelRouter(
.fetch(metadataId: spaceId, include: PubNub.IncludeFields(custom: includeCustom).channelIncludeFields),
.fetch(metadataId: spaceId, include: PubNub.ChannelIncludeFields(custom: includeCustom).includeFields),
configuration: requestConfig.customConfiguration ?? configuration
)

Expand Down Expand Up @@ -265,7 +265,7 @@ public extension PubNubSpaceInterface {
channelDescription: description,
custom: custom?.flatJSON
),
include: PubNub.IncludeFields(custom: includeCustom).channelIncludeFields
include: PubNub.ChannelIncludeFields(custom: includeCustom).includeFields
),
configuration: requestConfig.customConfiguration ?? configuration
)
Expand Down
2 changes: 1 addition & 1 deletion PubNubUser/Sources/PubNubUser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ extension PubNubUser: Codable {
// MARK: Object v2 Migration

public extension PubNubUserMetadata {
/// Converts Object V2 UUID Metadata to a Space entity
/// Converts Object V2 User Metadata to a User entity
///
/// - returns: The `PubNubUser` built from the Object V2 data
func convert() -> PubNubUser {
Expand Down
16 changes: 8 additions & 8 deletions PubNubUser/Sources/User+PubNub.swift
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ public extension PubNubUserInterface {
requestConfig: PubNub.RequestConfiguration = .init(),
completion: @escaping ((Result<(users: [PubNubUser], next: PubNubHashedPage?), Error>) -> Void)
) {
let router = ObjectsUUIDRouter(
let router = ObjectsUserRouter(
.all(
include: PubNub.IncludeFields(custom: includeCustom).userIncludeFields,
include: PubNub.UserIncludeFields(custom: includeCustom).includeFields,
totalCount: includeTotalCount,
filter: filter,
sort: sort.map { $0.routerParameter },
Expand All @@ -226,7 +226,7 @@ public extension PubNubUserInterface {
completion(result.map { (
users: $0.payload.data,
next: PubNub.Page(next: $0.payload.next, prev: $0.payload.prev, totalCount: $0.payload.totalCount)
) })
)})
}
}

Expand All @@ -236,10 +236,10 @@ public extension PubNubUserInterface {
requestConfig: PubNub.RequestConfiguration = .init(),
completion: @escaping (Result<PubNubUser, Error>) -> Void
) {
let router = ObjectsUUIDRouter(
let router = ObjectsUserRouter(
.fetch(
metadataId: userId ?? (requestConfig.customConfiguration?.uuid ?? configuration.uuid),
include: PubNub.IncludeFields(custom: includeCustom).userIncludeFields
include: PubNub.UserIncludeFields(custom: includeCustom).includeFields
),
configuration: requestConfig.customConfiguration ?? configuration
)
Expand Down Expand Up @@ -268,7 +268,7 @@ public extension PubNubUserInterface {
requestConfig: PubNub.RequestConfiguration = .init(),
completion: ((Result<PubNubUser, Error>) -> Void)?
) {
let router = ObjectsUUIDRouter(
let router = ObjectsUserRouter(
.set(
metadata: PubNubUserMetadataBase(
metadataId: userId ?? (requestConfig.customConfiguration?.uuid ?? configuration.uuid),
Expand All @@ -280,7 +280,7 @@ public extension PubNubUserInterface {
email: email,
custom: custom?.flatJSON
),
include: PubNub.IncludeFields(custom: includeCustom).userIncludeFields
include: PubNub.UserIncludeFields(custom: includeCustom).includeFields
),
configuration: requestConfig.customConfiguration ?? configuration
)
Expand Down Expand Up @@ -329,7 +329,7 @@ public extension PubNubUserInterface {
requestConfig: PubNub.RequestConfiguration = .init(),
completion: ((Result<Void, Error>) -> Void)?
) {
let router = ObjectsUUIDRouter(
let router = ObjectsUserRouter(
.remove(metadataId: userId ?? (requestConfig.customConfiguration?.uuid ?? configuration.uuid)),
configuration: requestConfig.customConfiguration ?? configuration
)
Expand Down
20 changes: 10 additions & 10 deletions PubNubUser/Tests/Test+PubNubUserInterface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class PubNubUserInterfaceTests: XCTestCase {
func testUser_FetchUsers() {
let expectation = XCTestExpectation(description: "Fetch Users API")

let testRouterEndpoint = ObjectsUUIDRouter.Endpoint.all(
let testRouterEndpoint = ObjectsUserRouter.Endpoint.all(
customFields: true,
totalCount: true,
filter: nil,
Expand All @@ -113,7 +113,7 @@ class PubNubUserInterfaceTests: XCTestCase {

// Validate Inputs
mockSession.validateRouter = { router in
XCTAssertEqual(testRouterEndpoint, (router as? ObjectsUUIDRouter)?.endpoint)
XCTAssertEqual(testRouterEndpoint, (router as? ObjectsUserRouter)?.endpoint)
}

// Provide Output
Expand Down Expand Up @@ -141,14 +141,14 @@ class PubNubUserInterfaceTests: XCTestCase {
func testUser_FetchUser_ConfigUserId() {
let expectation = XCTestExpectation(description: "Fetch User API")

let testRouterEndpoint = ObjectsUUIDRouter.Endpoint.fetch(
let testRouterEndpoint = ObjectsUserRouter.Endpoint.fetch(
metadataId: pubnub.configuration.userId,
customFields: true
)

// Validate Inputs
mockSession.validateRouter = { router in
XCTAssertEqual(testRouterEndpoint, (router as? ObjectsUUIDRouter)?.endpoint)
XCTAssertEqual(testRouterEndpoint, (router as? ObjectsUserRouter)?.endpoint)
}

// Provide Output
Expand All @@ -173,7 +173,7 @@ class PubNubUserInterfaceTests: XCTestCase {
func testUser_CreateUser() {
let expectation = XCTestExpectation(description: "Fetch User API")

let testRouterEndpoint = ObjectsUUIDRouter.Endpoint.set(
let testRouterEndpoint = ObjectsUserRouter.Endpoint.set(
metadata: PubNubUserMetadataBase(
metadataId: pubnub.configuration.userId,
name: testUser.name,
Expand All @@ -191,7 +191,7 @@ class PubNubUserInterfaceTests: XCTestCase {

// Validate Inputs
mockSession.validateRouter = { router in
XCTAssertEqual(testRouterEndpoint, (router as? ObjectsUUIDRouter)?.endpoint)
XCTAssertEqual(testRouterEndpoint, (router as? ObjectsUserRouter)?.endpoint)
}

// Provide Output
Expand Down Expand Up @@ -227,7 +227,7 @@ class PubNubUserInterfaceTests: XCTestCase {
func testUser_UpdateUser() {
let expectation = XCTestExpectation(description: "Fetch User API")

let testRouterEndpoint = ObjectsUUIDRouter.Endpoint.set(
let testRouterEndpoint = ObjectsUserRouter.Endpoint.set(
metadata: PubNubUserMetadataBase(
metadataId: pubnub.configuration.userId,
name: testUser.name,
Expand All @@ -245,7 +245,7 @@ class PubNubUserInterfaceTests: XCTestCase {

// Validate Inputs
mockSession.validateRouter = { router in
XCTAssertEqual(testRouterEndpoint, (router as? ObjectsUUIDRouter)?.endpoint)
XCTAssertEqual(testRouterEndpoint, (router as? ObjectsUserRouter)?.endpoint)
}

// Provide Output
Expand Down Expand Up @@ -281,13 +281,13 @@ class PubNubUserInterfaceTests: XCTestCase {
func testUser_RemoveUser() {
let expectation = XCTestExpectation(description: "Fetch User API")

let testRouterEndpoint = ObjectsUUIDRouter.Endpoint.remove(
let testRouterEndpoint = ObjectsUserRouter.Endpoint.remove(
metadataId: pubnub.configuration.uuid
)

// Validate Inputs
mockSession.validateRouter = { router in
XCTAssertEqual(testRouterEndpoint, (router as? ObjectsUUIDRouter)?.endpoint)
XCTAssertEqual(testRouterEndpoint, (router as? ObjectsUserRouter)?.endpoint)
}

// Provide Output
Expand Down
Loading

0 comments on commit 3e292cf

Please sign in to comment.