GetStream / stream-chat-js

JS / Browser Client - Build Chat with GetStream.io
https://getstream.io/chat/
Other
182 stars 76 forks source link

Error: StreamChat error code 4: UpdateChannel failed with error #1021

Closed alexander01202 closed 2 years ago

alexander01202 commented 2 years ago

Your doc is so confusing!!!. How do I remove some one from a team after adding them?? It's not specified anywhere. Also do I need to call the create method anytime I want to create a new channel?? e.g const channel = await client.channel('messaging',${arr[i].channelKey}, { name:${homeArr[i].name}, }).create();

Because in some place in your doc you don't call this method and you don't equally give any reason.

Also are the channels public? Can everyone that is connected access them??

If yes. how do I make them private? I want to create a group for only certain people and no one else. I have seen your teams channel type but in future I would need to remove them from the group and I there's nowhere in the docs that says how to remove from a team channel type or do I just ban them??

Does deleting a channel only delete for a particular user or it deletes for everyone else who has access to that channel ??

I have been able to get show a channel list and access the channel. I do not know how to add/remove a user. My code fails here: `for (let i = 0; i < Arr.length; i++) {

    const channel = client.channel('messaging', ${Arr[i].channelKey}, {
      name: $Arr[i].name},
    }); 

    channel.create()
    await channel.updatePartial({ set:{ name:${Arr[i].name} } })
    await channel.addMembers([${displayName}], { text: ${displayName} joined the channel. });
  }   `

I get the error :

Error: StreamChat error code 4: UpdateChannel failed with error: "The following users are involved in channel update operation, but don't exist: [Alex]. Please create the user objects before setting up the channel."

I have created the user object already using connectUser api but it keeps failing. Your docs tells me to add a member this way and it doesn't work. Just so confusing

AnatolyRugalev commented 2 years ago

Hey @alexander01202, thanks for reaching out to us. This is a JavaScript SDK repository, and it seems that you don't have any issues with the SDK itself. Please use our customer support form to send this kind of questions next time: https://getstream.io/contact/support/

How do I remove some one from a team after adding them??

You add users to teams with partialUpdateUsers method like this:

await client.partialUpdateUsers([{id: "my_user", set: {teams: ["team_a", "team_b"]}])

You can remove user from the team by just updating user with new set of teams, in this example, to remove user from team_b your invocation will look like this:

await client.partialUpdateUsers([{id: "my_user", set: {teams: ["team_a"]}])

Read more about this in our multi-tenancy documentation:

Also do I need to call the create method anytime I want to create a new channel??

No, in our API channel will be created automatically when we see it for the first time. channel.query(), channel.watch() and channel.create() all will create a channel for you.

Also are the channels public? Can everyone that is connected access them??

Not every channel is public by default. It depends on permission settings and by default they are set up in such a way that only channels with type livestream are public. You can find more in our documentation for permission system. I suggest you to upgrade to version 2 if you are still on the old one. This will let you change permission settings using UI in the dashboard.

I have seen your teams channel type but in future I would need to remove them from the group and I there's nowhere in the docs that says how to remove from a team channel type or do I just ban them??

Users don't belong to channel types, but they can join different channels. Think of channel types as group of channels with different features (e.g. DMs, group chats and announcement channels). To remove user from the channel, you can call channel.removeMembers(["user_1", "user_2"]). team channel type is a builtin channel type that doesn't have anything to do with multi-tenant applications. You don't have to use it to assign users to teams.

Does deleting a channel only delete for a particular user or it deletes for everyone else who has access to that channel ??

It deletes channel for everyone. Usually only channel owners and admins should have a permission to do so. Please refer to permissions documentation to learn how to fine tune permissions.

I have been able to get show a channel list and access the channel. I do not know how to add/remove a user.

You are on a right track, however, you should user IDs, not user names. In your code you are trying to add user using id Alex which does not exist, because Alex is a user name, not user ID.

AnatolyRugalev commented 2 years ago

Please reopen the issue if you feel like your problem was not solved

alexander01202 commented 2 years ago

Hello. When I remove members it still shows in the channel List. How do I totally remove them. I do not want it to show in the channel list again

NishantIndigloo commented 1 month ago

[log] callState.status -----------> Disconnected{reason: Timeout} I am getting this error.