Skip to content

Commit c8e159e

Browse files
Fixed bug rel. to setRestriction (#173)
* Fixed bug rel. to setRestriction When "Enforce referential integrity for memberships" then when setting restriction(channelMembers) we need to make sure that both channel and user exist in AppContext. * PubNub kotlin 0.11.1 release. --------- Co-authored-by: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com>
1 parent d913917 commit c8e159e

File tree

8 files changed

+30
-26
lines changed

8 files changed

+30
-26
lines changed

.pubnub.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: kmp-chat
2-
version: 0.11.0
2+
version: 0.11.1
33
schema: 1
44
scm: github.com/pubnub/kmp-chat
55
sdks:
@@ -21,8 +21,8 @@ sdks:
2121
-
2222
distribution-type: library
2323
distribution-repository: maven
24-
package-name: pubnub-chat-0.11.0
25-
location: https://repo.maven.apache.org/maven2/com/pubnub/pubnub-chat/0.11.0/
24+
package-name: pubnub-chat-0.11.1
25+
location: https://repo.maven.apache.org/maven2/com/pubnub/pubnub-chat/0.11.1/
2626
supported-platforms:
2727
supported-operating-systems:
2828
Android:
@@ -77,6 +77,11 @@ sdks:
7777
license-url: https://github.com/pubnub/kotlin/blob/master/LICENSE
7878
is-required: Required
7979
changelog:
80+
- date: 2025-02-20
81+
version: 0.11.1
82+
changes:
83+
- type: bug
84+
text: "Fixed bug related to setting user restriction. The issue occurred when `Enforce referential integrity for memberships` was enabled and a user did not exist in AppContext."
8085
- date: 2025-01-23
8186
version: 0.11.0
8287
changes:

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ let package = Package(
1818
targets: [
1919
.binaryTarget(
2020
name: "PubNubChatRemoteBinaryPackage",
21-
url: "https://github.com/pubnub/kmp-chat/releases/download/kotlin-0.11.0/PubNubChat.xcframework.zip",
21+
url: "https://github.com/pubnub/kmp-chat/releases/download/kotlin-0.11.1/PubNubChat.xcframework.zip",
2222
checksum: "3153a4429665fe51861cfdc3b63cdb873260e777dcb41d52f14301698b2b2a91"
2323
)
2424
]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ You will need the publish and subscribe keys to authenticate your app. Get your
3131
<dependency>
3232
<groupId>com.pubnub</groupId>
3333
<artifactId>pubnub-chat</artifactId>
34-
<version>0.11.0</version>
34+
<version>0.11.1</version>
3535
</dependency>
3636
```
3737

gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ SONATYPE_HOST=DEFAULT
1010
SONATYPE_AUTOMATIC_RELEASE=false
1111
GROUP=com.pubnub
1212
POM_PACKAGING=jar
13-
VERSION_NAME=0.11.5
13+
VERSION_NAME=0.11.1
14+
1415

1516
POM_NAME=PubNub Chat SDK
1617
POM_DESCRIPTION=This SDK offers a set of handy methods to create your own feature-rich chat or add a chat to your existing application.

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ ktlint = "12.1.0"
66
dokka = "1.9.20"
77
kotlinx_serialization = "1.7.3"
88
kotlinx_coroutines = "1.9.0"
9-
pubnub = "10.4.0"
10-
pubnub_swift = "8.3.0"
9+
pubnub = "10.4.1"
10+
pubnub_swift = "8.3.1"
1111

1212
[libraries]
1313
pubnub-kotlin-api = { module = "com.pubnub:pubnub-kotlin-api", version.ref = "pubnub" }

kotlin-js-store/yarn.lock

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -659,22 +659,6 @@ proxy-from-env@^1.1.0:
659659
resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2"
660660
integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==
661661

662-
pubnub@8.4.1:
663-
version "8.4.1"
664-
resolved "https://registry.yarnpkg.com/pubnub/-/pubnub-8.4.1.tgz#5f6f19e84d3187dc8aee0a458bd6b05e90d43e6a"
665-
integrity sha512-mPlwVoHJDWPasZx52UfSMiPX5TATm5A+ficSogyqDqTQ4w5EQnwxH+PJdsWc0mPnlT051jM1vIISMeM0fQ30CQ==
666-
dependencies:
667-
agentkeepalive "^3.5.2"
668-
buffer "^6.0.3"
669-
cbor-js "^0.1.0"
670-
cbor-sync "^1.0.4"
671-
form-data "^4.0.0"
672-
lil-uuid "^0.1.1"
673-
node-fetch "^2.7.0"
674-
proxy-agent "^6.3.0"
675-
react-native-url-polyfill "^2.0.0"
676-
text-encoding "^0.7.0"
677-
678662
pubnub@8.6.0:
679663
version "8.6.0"
680664
resolved "https://registry.yarnpkg.com/pubnub/-/pubnub-8.6.0.tgz#75524e7ed3653090652d160ce83ac089362a0379"

pubnub-chat-impl/src/commonMain/kotlin/com/pubnub/chat/internal/ChatImpl.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ class ChatImpl(
724724
}
725725
val channel: String = INTERNAL_MODERATION_PREFIX + restriction.channelId
726726
val userId = restriction.userId
727+
// if "Enforce referential integrity for memberships" is enabled we need to make sure that channel exists in AppContext
727728
return createChannel(channel, type = ChannelType.PUBNUB_PRIVATE).catch { exception ->
728729
if (exception.message == CHANNEL_ID_ALREADY_EXIST) {
729730
Result.success(Unit)
@@ -753,8 +754,16 @@ class ChatImpl(
753754
)
754755
)
755756
val uuids = listOf(PNMember.Partial(uuidId = userId, custom = custom, null))
756-
pubNub.setChannelMembers(channel = channel, users = uuids)
757-
.alsoAsync { _ ->
757+
758+
// if "Enforce referential integrity for memberships" is enabled we need to make sure that user exists in AppContext
759+
createUser(id = userId).catch { exception ->
760+
if (exception.message == USER_ID_ALREADY_EXIST) {
761+
Result.success(Unit)
762+
} else {
763+
Result.failure(exception)
764+
}
765+
}.thenAsync {
766+
pubNub.setChannelMembers(channel = channel, users = uuids).alsoAsync { _ ->
758767
emitEvent(
759768
channelId = INTERNAL_USER_MODERATION_CHANNEL_PREFIX + userId,
760769
payload = EventContent.Moderation(
@@ -768,6 +777,7 @@ class ChatImpl(
768777
),
769778
)
770779
}
780+
}
771781
}
772782
moderationEvent.then { }
773783
}

pubnub-chat-impl/src/commonTest/kotlin/com/pubnub/kmp/ChatTest.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,6 +1438,10 @@ class ChatTest : BaseTest() {
14381438
mute = mute,
14391439
reason = reason
14401440
)
1441+
every { getUUIDMetadataEndpoint.async(any()) } calls { (callback1: Consumer<Result<PNUUIDMetadataResult>>) ->
1442+
callback1.accept(Result.success(getPNUuidMetadataResult()))
1443+
}
1444+
every { pubnub.getUUIDMetadata(uuid = userId, includeCustom = true) } returns getUUIDMetadataEndpoint
14411445
every { getChannelMetadataEndpoint.async(any()) } calls { (callback1: Consumer<Result<PNChannelMetadataResult>>) ->
14421446
callback1.accept(Result.success(getPNChannelMetadataResult("PUBNUB_INTERNAL_MODERATION_myChannelId")))
14431447
}

0 commit comments

Comments
 (0)