From 2c46f05cbb2754b1bd035972e4e183e5ab0dc193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Tue, 4 Feb 2025 10:32:19 +0100 Subject: [PATCH] Add missing streamMessageReports method in JS (#170) * PubNub js 0.11.4 release. --------- Co-authored-by: marcin.cebo Co-authored-by: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com> --- gradle.properties | 2 +- js-chat/.pubnub.yml | 7 ++++++- js-chat/package.json | 2 +- js-chat/tests/channel.test.ts | 21 +++++++++++++++++++ .../src/jsMain/kotlin/ChannelJs.kt | 5 +++++ 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index b159594f..411e2e09 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ SONATYPE_HOST=DEFAULT SONATYPE_AUTOMATIC_RELEASE=false GROUP=com.pubnub POM_PACKAGING=jar -VERSION_NAME=0.11.3 +VERSION_NAME=0.11.4 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. diff --git a/js-chat/.pubnub.yml b/js-chat/.pubnub.yml index 59ddf5e6..78f208a8 100644 --- a/js-chat/.pubnub.yml +++ b/js-chat/.pubnub.yml @@ -1,10 +1,15 @@ name: pubnub-js-chat -version: 0.11.3 +version: 0.11.4 scm: github.com/pubnub/js-chat schema: 1 files: - lib/dist/index.js changelog: + - date: 2025-02-04 + version: 0.11.4 + changes: + - type: bug + text: "Added missing streamMessageReports method in JS." - date: 2025-01-30 version: 0.11.3 changes: diff --git a/js-chat/package.json b/js-chat/package.json index 632ec8c6..bfab2117 100644 --- a/js-chat/package.json +++ b/js-chat/package.json @@ -40,7 +40,7 @@ "module": "dist/index.es.js", "types": "dist/index.d.ts", "react-native": "dist/index.es.js", - "version": "0.11.3", + "version": "0.11.4", "name": "@pubnub/chat", "dependencies": { "pubnub": "8.6.0", diff --git a/js-chat/tests/channel.test.ts b/js-chat/tests/channel.test.ts index 7a427014..1e5393ae 100644 --- a/js-chat/tests/channel.test.ts +++ b/js-chat/tests/channel.test.ts @@ -351,6 +351,27 @@ describe("Channel test", () => { expect(errorOccurred).toBe(true) }) + test("streamMessageReport should receive reported message", async () => { + const messageTextToReport = "lalalal" + const reason = "rude"; + let receivedEvent + + const unsubscribe = channel.streamMessageReports((event) => { + receivedEvent = event + }) + + const { timetoken } = await channel.sendText(messageTextToReport); + await sleep(1000) // delayForHistory + const message = await channel.getMessage(timetoken); + + await message.report(reason); + await sleep(500) + + expect(receivedEvent.payload.text).toEqual(messageTextToReport); + expect(receivedEvent.payload.reason).toEqual(reason); + unsubscribe(); // Cleanup + }); + test("should stream channel updates and invoke the callback", async () => { let updatedChannel channel = await channel.update({ type: "public" }) diff --git a/pubnub-chat-impl/src/jsMain/kotlin/ChannelJs.kt b/pubnub-chat-impl/src/jsMain/kotlin/ChannelJs.kt index 02863d70..b3c72934 100644 --- a/pubnub-chat-impl/src/jsMain/kotlin/ChannelJs.kt +++ b/pubnub-chat-impl/src/jsMain/kotlin/ChannelJs.kt @@ -284,6 +284,11 @@ open class ChannelJs internal constructor(internal val channel: Channel, interna }.asPromise() } + fun streamMessageReports(callback: (EventJs) -> Unit): () -> Unit = + channel.streamMessageReports { event -> + callback(event.toJs(chatJs)) + }::close + @Deprecated("Only for internal MessageDraft V1 use") fun getUserSuggestions(text: String, options: GetSuggestionsParams?): Promise> { val limit = options?.limit