diff --git a/litecord/blueprints/guild/channels.py b/litecord/blueprints/guild/channels.py index f8c5132..f453b75 100644 --- a/litecord/blueprints/guild/channels.py +++ b/litecord/blueprints/guild/channels.py @@ -91,6 +91,17 @@ async def create_channel(guild_id): await create_guild_channel( guild_id, new_channel_id, channel_type, **j) + # TODO: do a better method + # subscribe the currently subscribed users to the new channel + # by getting all user ids and subscribing each one by one. + + # since GuildDispatcher calls Storage.get_channel_ids, + # it will subscribe all users to the newly created channel. + guild_pubsub = app.dispatcher.backends['guild'] + user_ids = guild_pubsub.state[guild_id] + for uid in user_ids: + await app.dispatcher.sub('guild', guild_id, uid) + chan = await app.storage.get_channel(new_channel_id) await app.dispatcher.dispatch_guild( guild_id, 'CHANNEL_CREATE', chan) diff --git a/litecord/pubsub/guild.py b/litecord/pubsub/guild.py index 6613fcb..fcb0f05 100644 --- a/litecord/pubsub/guild.py +++ b/litecord/pubsub/guild.py @@ -46,6 +46,8 @@ class GuildDispatcher(DispatcherWithState): # when subbing a user to the guild, we should sub them # to every channel they have access to, in the guild. + # TODO: check for permissions + await self._chan_action('sub', guild_id, user_id) async def unsub(self, guild_id: int, user_id: int):