mirror of https://gitlab.com/litecord/litecord.git
blueprints.channels: fix close_channel for dms
- dispatcher: add sub() and unsub() alias methods
This commit is contained in:
parent
20332805b8
commit
919e5ff903
|
|
@ -195,12 +195,16 @@ async def close_channel(channel_id):
|
||||||
# the request via removing the link between them and
|
# the request via removing the link between them and
|
||||||
# the channel on dm_channel_state
|
# the channel on dm_channel_state
|
||||||
await app.db.execute("""
|
await app.db.execute("""
|
||||||
DELETE FROM dm_channel_state (user_id, dm_id)
|
DELETE FROM dm_channel_state
|
||||||
VALUES ($1, $2)
|
WHERE user_id = $1 AND dm_id = $2
|
||||||
""", user_id, channel_id)
|
""", user_id, channel_id)
|
||||||
|
|
||||||
|
# unsubscribe
|
||||||
|
await app.dispatcher.unsub('channel', channel_id, user_id)
|
||||||
|
|
||||||
# nothing happens to the other party of the dm channel
|
# nothing happens to the other party of the dm channel
|
||||||
await app.dispacher.dispatch_user(user_id, 'CHANNEL_DELETE', chan)
|
await app.dispatcher.dispatch_user(user_id, 'CHANNEL_DELETE', chan)
|
||||||
|
|
||||||
return jsonify(chan)
|
return jsonify(chan)
|
||||||
|
|
||||||
if ctype == ChannelType.GROUP_DM:
|
if ctype == ChannelType.GROUP_DM:
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,12 @@ class EventDispatcher:
|
||||||
backend, key, identifier, backend)
|
backend, key, identifier, backend)
|
||||||
return await self.action(backend, 'unsub', key, identifier)
|
return await self.action(backend, 'unsub', key, identifier)
|
||||||
|
|
||||||
|
async def sub(self, backend, key, identifier):
|
||||||
|
return await self.subscribe(backend, key, identifier)
|
||||||
|
|
||||||
|
async def unsub(self, backend, key, identifier):
|
||||||
|
return await self.unsubscribe(backend, key, identifier)
|
||||||
|
|
||||||
async def dispatch(self, backend_str: str, key: Any, *args, **kwargs):
|
async def dispatch(self, backend_str: str, key: Any, *args, **kwargs):
|
||||||
"""Dispatch an event to the backend.
|
"""Dispatch an event to the backend.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue