How to update a channel using the SDK with a user added after channel creation

I’m trying to update a channel via the Javascript SDK with updateChannel with a user who has been added to a public channel after it’s creation via joinChannel and I get the following error:

{error: "AccessDeniedError", message: "Access is denied. You do not have the permissions required to perform this action.", timestamp: "2021-07-11T01:36:54.821Z"}

I seem to be able to update the channel successfully if I do so as one of the original members of the channel, i.e. provided during channel creation, so I assume theres some sort of privileges only original members have. I also tried testing adding the new user via the API but running into the same issue. Is there another method available to add a member to an existing channel with the same privileges as the original members?

Hey @kmystic524,

Welcome to ChatKitty Community!

Yeah, only channel moderators are allowed to update channels. As you’ve observed, the original channel members defined when creating a channel are automatically assigned the moderator role.

Currently, there isn’t a method exposed to add new channel moderators but I can add a new SDK method to do so.

Thanks for verifying the behavior, a method would be super helpful for me! I’m trying to make an “admin” type role who can join and modify any existing channel. Thanks!

1 Like

Hey @kmystic524!

You can now add moderators with update channel permissions using the SDK.

Thank you! I’ll take a look and reach out if I have any questions.

Hi Aaron,

I tested out the new method but I’m unable to call it, I get the same AccessDeniedError. It’s worth noting that I’m calling the method with an “admin” user who is now a member of the channel.

Here some more context for my use case:

  • There are three types of users: Sellers, Buyers and Admins
  • Public channels are created using the API to remain creator-less when a Buyer wants to contact a Seller, with only those two members
  • Both Sellers and Buyers can see a list of the channels they’ve joined
  • Admins can see not only the list of channels they’ve joined (in case they are also a Buyer or Seller) but also all of the channels they have not joined
    – An admin needs to be able to join and moderate all channels
    – This is done via the sdk as an admin, the reasoning behind not adding them as a member during channel creation is because admins can be created after a channel has been created and I would want them to see previous channels.

Regards,
Kira

Thanks for describing your use case. The way addChannelModerator works is that it needs to be called by one of the channel’s original members, who are granted channel moderator permissions at channel creation.

From your description, it looks like I’ll need to add a new concept of “application admin user” that has the same permissions as the platform API, including joining and modifying any channel as you mentioned. This application admin role would be granted to a user and able to be revoked only by using the platform API.

What do you think about this approach?

Sorry for the long delay in response, that approach works for me!

1 Like

No worries! I’ll implement it this week. :slight_smile: