Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug rel. to setRestriction #173

Merged
merged 7 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: kmp-chat
version: 0.11.0
version: 0.11.1
schema: 1
scm: github.com/pubnub/kmp-chat
sdks:
Expand All @@ -21,8 +21,8 @@ sdks:
-
distribution-type: library
distribution-repository: maven
package-name: pubnub-chat-0.11.0
location: https://repo.maven.apache.org/maven2/com/pubnub/pubnub-chat/0.11.0/
package-name: pubnub-chat-0.11.1
location: https://repo.maven.apache.org/maven2/com/pubnub/pubnub-chat/0.11.1/
supported-platforms:
supported-operating-systems:
Android:
Expand Down Expand Up @@ -77,6 +77,11 @@ sdks:
license-url: https://github.com/pubnub/kotlin/blob/master/LICENSE
is-required: Required
changelog:
- date: 2025-02-20
version: 0.11.1
changes:
- type: bug
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."
- date: 2025-01-23
version: 0.11.0
changes:
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let package = Package(
targets: [
.binaryTarget(
name: "PubNubChatRemoteBinaryPackage",
url: "https://github.com/pubnub/kmp-chat/releases/download/kotlin-0.11.0/PubNubChat.xcframework.zip",
url: "https://github.com/pubnub/kmp-chat/releases/download/kotlin-0.11.1/PubNubChat.xcframework.zip",
checksum: "3153a4429665fe51861cfdc3b63cdb873260e777dcb41d52f14301698b2b2a91"
)
]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ You will need the publish and subscribe keys to authenticate your app. Get your
<dependency>
<groupId>com.pubnub</groupId>
<artifactId>pubnub-chat</artifactId>
<version>0.11.0</version>
<version>0.11.1</version>
</dependency>
```

Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ SONATYPE_HOST=DEFAULT
SONATYPE_AUTOMATIC_RELEASE=false
GROUP=com.pubnub
POM_PACKAGING=jar
VERSION_NAME=0.11.5
VERSION_NAME=0.11.1


POM_NAME=PubNub Chat SDK
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.
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ ktlint = "12.1.0"
dokka = "1.9.20"
kotlinx_serialization = "1.7.3"
kotlinx_coroutines = "1.9.0"
pubnub = "10.4.0"
pubnub_swift = "8.3.0"
pubnub = "10.4.1"
pubnub_swift = "8.3.1"

[libraries]
pubnub-kotlin-api = { module = "com.pubnub:pubnub-kotlin-api", version.ref = "pubnub" }
Expand Down
16 changes: 0 additions & 16 deletions kotlin-js-store/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -659,22 +659,6 @@ proxy-from-env@^1.1.0:
resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2"
integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==

[email protected]:
version "8.4.1"
resolved "https://registry.yarnpkg.com/pubnub/-/pubnub-8.4.1.tgz#5f6f19e84d3187dc8aee0a458bd6b05e90d43e6a"
integrity sha512-mPlwVoHJDWPasZx52UfSMiPX5TATm5A+ficSogyqDqTQ4w5EQnwxH+PJdsWc0mPnlT051jM1vIISMeM0fQ30CQ==
dependencies:
agentkeepalive "^3.5.2"
buffer "^6.0.3"
cbor-js "^0.1.0"
cbor-sync "^1.0.4"
form-data "^4.0.0"
lil-uuid "^0.1.1"
node-fetch "^2.7.0"
proxy-agent "^6.3.0"
react-native-url-polyfill "^2.0.0"
text-encoding "^0.7.0"

[email protected]:
version "8.6.0"
resolved "https://registry.yarnpkg.com/pubnub/-/pubnub-8.6.0.tgz#75524e7ed3653090652d160ce83ac089362a0379"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@ class ChatImpl(
}
val channel: String = INTERNAL_MODERATION_PREFIX + restriction.channelId
val userId = restriction.userId
// if "Enforce referential integrity for memberships" is enabled we need to make sure that channel exists in AppContext
return createChannel(channel, type = ChannelType.PUBNUB_PRIVATE).catch { exception ->
if (exception.message == CHANNEL_ID_ALREADY_EXIST) {
Result.success(Unit)
Expand Down Expand Up @@ -753,8 +754,16 @@ class ChatImpl(
)
)
val uuids = listOf(PNMember.Partial(uuidId = userId, custom = custom, null))
pubNub.setChannelMembers(channel = channel, users = uuids)
.alsoAsync { _ ->

// if "Enforce referential integrity for memberships" is enabled we need to make sure that user exists in AppContext
createUser(id = userId).catch { exception ->
if (exception.message == USER_ID_ALREADY_EXIST) {
Result.success(Unit)
} else {
Result.failure(exception)
}
}.thenAsync {
pubNub.setChannelMembers(channel = channel, users = uuids).alsoAsync { _ ->
emitEvent(
channelId = INTERNAL_USER_MODERATION_CHANNEL_PREFIX + userId,
payload = EventContent.Moderation(
Expand All @@ -768,6 +777,7 @@ class ChatImpl(
),
)
}
}
}
moderationEvent.then { }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1438,6 +1438,10 @@ class ChatTest : BaseTest() {
mute = mute,
reason = reason
)
every { getUUIDMetadataEndpoint.async(any()) } calls { (callback1: Consumer<Result<PNUUIDMetadataResult>>) ->
callback1.accept(Result.success(getPNUuidMetadataResult()))
}
every { pubnub.getUUIDMetadata(uuid = userId, includeCustom = true) } returns getUUIDMetadataEndpoint
every { getChannelMetadataEndpoint.async(any()) } calls { (callback1: Consumer<Result<PNChannelMetadataResult>>) ->
callback1.accept(Result.success(getPNChannelMetadataResult("PUBNUB_INTERNAL_MODERATION_myChannelId")))
}
Expand Down