While trying getstream.io chat features for an existing site, I found a couple of things that are not clear in the documentation.
To initiate a new "private" channel with a limited amount of members, one can call client.channel().create() with the list of members ids.
That works, as soon as the users ids have been seen by stream before. Edit: The error I'm getting when trying to create a channel with members ids:
GetOrCreateChannel failed with error: "The following users are specified in channel.members but don't exist: [2924820248]. Please create the user objects before setting up the channel.
Since the website (and users) existed before introducing getstream, I would like to register all the existing users with getstream.
And that seems to be supported via the user API endpoint, or via the python sdk users.add.
Update: apparently even calling users.add doesn't solve the issue :/
The rest is almost irrelevant at this point... but leaving here for posterity...
Unfortunately. calling users.add seems to return 502, no matter what I'm passing as arguments. The authorization (API_KEY and API_KEY_SECRET) seems to be correct, as if I remove/change them, the response is a permission denied instead.
I tried passing different location (us-east, eu-west, dublin, or none at all), and calling these API endpoint directly as well, to no avail.
I tried with or without data argument as well, but doesn't seem to make any difference.
How does one uses this users.add?
Python code:
import stream
client = stream.connect(api_key=STREAM_API_KEY, api_secret=STREAM_API_KEY_SECRET, location='us-east')
client.users.add('my-user-id', {'name': 'Bob'})
curl:
curl -H "Content-Type: application/json" -H "Authorization: AUTH_STRING" -H "stream-auth-type: jwt" -d '{"id": "my-user-id", "data": {"name": "Bob"}}' "https://api.stream-io-api.com/api/v1.0/user/?api_key=API_KEY"
response:
HTTP/2 502
date: Sun, 03 Nov 2019 14:51:56 GMT
content-length: 0
server: nginx
access-control-allow-origin: *
x-ratelimit-limit: 1000
x-ratelimit-remaining: 998
x-ratelimit-reset: 1572792720
Edit: It seems something is definitely wrong with stream itself, as creating another app in their dashboard and trying with the different keys associated to that new app seems to work fine and return 201 instead of 502 (having changed nothing else in the code).
The region/location for the problematic app is shown as "dublin" in the dashboard, and that app was created as a "development" app, but I changed it to a prod app after I find out the working one was created as prod. But still no luck. Can't figure out what's wrong with that app config/settings. At this point, I can't do much more without directly asking their support
Further update: Looks like all apps I create in eu-west are returning 502, whereas all the us-east are working just fine. Waiting for stream to come back to me
Latest update: Finally got a response from their support stating there was an issue in their Dublin setup, and that has now been fixed.
Apparently adding users (for chat) should be done via setUser
(client-side) or updateUsers (server-side)
https://getstream.io/chat/docs/python/#update_users
Important piece of information I missed from the doc:
If you're looking to sync your userbase you'll want to use the updateUser(s) method instead
So I guess users in feeds != users in chat