mirror of https://gitlab.com/litecord/litecord.git
guild.channels: subscribe users to the newly created channel
This commit is contained in:
parent
43b0482581
commit
0e3db251b8
|
|
@ -91,6 +91,17 @@ async def create_channel(guild_id):
|
||||||
await create_guild_channel(
|
await create_guild_channel(
|
||||||
guild_id, new_channel_id, channel_type, **j)
|
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)
|
chan = await app.storage.get_channel(new_channel_id)
|
||||||
await app.dispatcher.dispatch_guild(
|
await app.dispatcher.dispatch_guild(
|
||||||
guild_id, 'CHANNEL_CREATE', chan)
|
guild_id, 'CHANNEL_CREATE', chan)
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,8 @@ class GuildDispatcher(DispatcherWithState):
|
||||||
# when subbing a user to the guild, we should sub them
|
# when subbing a user to the guild, we should sub them
|
||||||
# to every channel they have access to, in the guild.
|
# to every channel they have access to, in the guild.
|
||||||
|
|
||||||
|
# TODO: check for permissions
|
||||||
|
|
||||||
await self._chan_action('sub', guild_id, user_id)
|
await self._chan_action('sub', guild_id, user_id)
|
||||||
|
|
||||||
async def unsub(self, guild_id: int, user_id: int):
|
async def unsub(self, guild_id: int, user_id: int):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue