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

CreateDirectConversation() channel ID issue #137

Closed
VIKI-09 opened this issue Oct 9, 2023 · 5 comments
Closed

CreateDirectConversation() channel ID issue #137

VIKI-09 opened this issue Oct 9, 2023 · 5 comments

Comments

@VIKI-09
Copy link

VIKI-09 commented Oct 9, 2023

I encountered a problem while using the createDirectConversation() method. The documentation states that the id is formed as follows: "The channel ID is automatically created out of the user IDs, joined by & and preceded by the direct prefix. For example, the users' channel IDs with agent-12 and agent-13 will be direct.agent-12&agent-13."(https://www.pubnub.com/docs/chat/chat-sdk/build/features/channels/create#method-signature)
BUT, In fact, the Chat SDK creates the channelId using the hash function as follows: const channelId = direct.${cyrb53a(${sortedUsers[0]}&${sortedUsers[1]})} (from the SDK source code). As a result, we get channel id like 'direct.1234567890, which is different from docs example pattern. Why is it implemented this way?
This prevents me from obtaining predictable channel IDs in order to use them in the channel identifier pattern to generate an access token for a specific user. That is, I want to generate a token that will provide the user access only to the private chats to which he belongs.

@VIKI-09 VIKI-09 changed the title https://www.pubnub.com/docs/chat/chat-sdk/build/features/channels/create#method-signature CreateDirectConversation() channel ID issue Oct 9, 2023
@Salet
Copy link
Contributor

Salet commented Oct 12, 2023

This was a last minute change that we unfortunately haven't reflected in the documentation yet. The reason for it was that channel IDs in PubNub have a hard limit on number of characters, and we run into situations where it was exhausted with the previous approach of concatenating user IDs.

Since there are various ways to do that, can you tell us a bit more about your workflow of creating channels and granting access tokens? Are you using wildcards in your PAM implementation? Would adding an optional parameter of channelId to the createDirectConversation help you with it?

@piotr-suwala
Copy link
Contributor

Since the next version (0.3.0) channelId will be an optional parameter for that method.

@kazydek
Copy link
Contributor

kazydek commented Oct 31, 2023

I've also updated the docs to describe how a channel ID is created: https://www.pubnub.com/docs/chat/chat-sdk/build/features/channels/create#input.

@piotr-suwala
Copy link
Contributor

@VIKI-09 Since yesterday's release you may optionally pass your own channelId. If you find the new feature problematic, please create a new issue.

@VIKI-09
Copy link
Author

VIKI-09 commented Nov 8, 2023

@VIKI-09 Since yesterday's release you may optionally pass your own channelId. If you find the new feature problematic, please create a new issue.

Many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants