Closed berkayturanci closed 2 years ago
Now I see the problem in here;
"You cannot add/remove members for channels created this way."
Still is there a way to understand the owner of the channel with the latest SDK version?
Hi @berkayturanci,
It is important to note that if you are creating a 1-1 channel (as shown in your last comment) you cannot mutate the members given the nature of the channel.
In order to do so, you need to create a group channel. This can help:
// A unique identifier of a channel
let id = UUID().uuidString
// A `ChannelId` for the new channel. `ChannelId` is a combination of channel's type and a unique identifier of the channel.
let cid = ChannelId(type: .messaging, id: id)
let controller = chatClient.channelController(
createChannelWithId: cid, // Assign `cid` for the new channel
members: [chatClient.currentUserId], // Add users to the new channel
extraData: .init(name: "My new channel", imageURL: nil) // Set the name for the channel
)
Thanks, @polqf, it resolves my add member problem. Is there a way to understand which user is the channel owner by just looking at the channel members? (my first question)
Hi @berkayturanci,
To check who is the channel owner, from you member list controller, you could create a query to get the channel members and then filter to get the owner. From the query you'll get a list of ChatChannelMember
and each member contains a property named memberRole
.
Quering Members ChatChannelMember
Regards, Hugo
Hello @hugobernalstream,
Actually, I tried the same thing but the creator of the channel doesn't have the owner - member role as you can see from the screenshot;
That is why I try to understand the owner by looking at the channel, createdBy by variable.
So in our case, "Ege" is the creator of the channel and should have owner permission where he doesn't.
@berkayturanci you are right, the user that owns the channel is the one referenced in channel.createdBy
.
Owning a channel does not change the role for a member but you can configure your app so that owners have additional grants (eg. add/remove members).
Hi @berkayturanci,
Were you able to configure your app to do what you want?
Thank you, Nuno
Closing this one for inactivity.
Let us know if you have any further questions.
Best, Nuno
Yes, I resolved the problem. Thanks @nuno-vieira
What did you do?
I am trying to add a feature to the app where channel owners can add members to existing chat groups.
What did you expect to happen?
I expect to see new members can be added to the existing groups by group owners.
What happened instead?
I got HTTP 403 with code 17 which do not allow me to do that.
GetStream Environment
GetStream Chat version: Tried with 4.15.0 and 4.19.0 GetStream Chat frameworks: StreamChat, StreamChatUI iOS version: 15.5 Swift version: Swift 5 Xcode version: 13.4.1 Device: All Devices
Additional context
I got two problem actually. With 4.15.0 I can understand who creates the channel by checking member.role value which is "owner". However with 4.19.0 I cannot understand who created the channel since member.role is now "member". I saw that there was a change in the 4.16.0 version but cannot figure out the latest usage. I can make this control by checking channel.createdBy part but is there any other solution?
Second problem is that, I cannot add members to existing channels. System gives HTTP 403 with code 17 which shows user do not have permission for that. However from the "Roles and Permission" dashboards I gave both "Update Channel Members" and "Update Own Channel Members" to all roles. Still got this error from the response. We uses permission v2.
Lastly I checked the demo app where I can add members to the groups with demo app.
The user who tries to add member to the group has owner ability.