We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Sorry to tag you directly piotr-suwala
But this is something really urgent.
The current implementation of connect on channel entity at least for me is not working as expected.
connect
/* * Streaming messages */ connect(callback: (message: Message) => void) { const listener = { message: (event: MessageEvent) => { if (event.channel !== this.id) return const getMessageResponseBody = this.chat.config.customPayloads.getMessageResponseBody || defaultGetMessageResponseBody if (getMessageResponseBody(event).type !== "text") return callback(Message.fromDTO(this.chat, event)) }, } const removeListener = this.chat.addListener(listener) const unsubscribe = this.chat.subscribe(this.id) return () => { removeListener() unsubscribe() } }
export function defaultGetMessageResponseBody(messageParams: MessageDTOParams) { if (typeof messageParams.message === "string") { return { type: MessageType.TEXT, text: messageParams.message, files: [], } } return messageParams.message }
Adding some debugs to defaultGetMessageResponseBody function:
defaultGetMessageResponseBody
console.debug("e.message =>", e.message) console.debug("typeof e.message =>", typeof e.message) console.debug(`"string" == typeof e.message =>`, "string" == typeof e.message);
I am getting:
index.es.js:260: e.message => {text: 'example', timetoken: 1728918366738} index.es.js:261: typeof e.message => object index.es.js:262: "string" == typeof e.message => false
Hence, all my text messages it's returning on line:
return messageParams.message
that it's an object and do not include type property that is expected in this check on connect method:
type
if (getMessageResponseBody(event).type !== "text") return
The text was updated successfully, but these errors were encountered:
To unblock me I am removing the line
So I can receive all messages regardless the type of it
Sorry, something went wrong.
Hello @manfe
Can you construct your own "getMessageResponseBody" as in this test? https://github.com/pubnub/js-chat/blob/master/lib/tests/message.test.ts#L1656
Something like:
Chat.init({ customPayloads: { getMessageResponseBody: (messageParams: MessageDTOParams) => { return { text: messageParams.message.text, type: MessageTypes.Text, files: messageParams.message.body.files, } }, } })
That worked, thanks!
No branches or pull requests
Sorry to tag you directly piotr-suwala
But this is something really urgent.
The current implementation of
connect
on channel entity at least for me is not working as expected.Adding some debugs to
defaultGetMessageResponseBody
function:I am getting:
Hence, all my text messages it's returning on line:
that it's an object and do not include
type
property that is expected in this check on connect method:The text was updated successfully, but these errors were encountered: