mirror of https://gitlab.com/litecord/litecord.git
dm_channels: add sub/unsub logic on add/remove of recipient
- fix gdm remove call on remove_from_group_dm
This commit is contained in:
parent
228468635f
commit
da669e5fb2
|
|
@ -87,6 +87,7 @@ async def _gdm_add_recipient(channel_id: int, peer_id: int, *, user_id=None):
|
|||
chan = await app.storage.get_channel(channel_id)
|
||||
await app.dispatcher.dispatch('user', peer_id, 'CHANNEL_CREATE', chan)
|
||||
await app.dispatcher.dispatch('channel', channel_id, 'CHANNEL_UPDATE', chan)
|
||||
await app.dispatcher.sub('channel', peer_id)
|
||||
|
||||
if user_id:
|
||||
await send_sys_message(
|
||||
|
|
@ -115,6 +116,8 @@ async def _gdm_remove_recipient(channel_id: int, peer_id: int, *, user_id=None):
|
|||
}
|
||||
)
|
||||
|
||||
await app.dispatcher.unsub('channel', peer_id)
|
||||
|
||||
if user_id:
|
||||
await send_sys_message(
|
||||
app, channel_id, MessageType.RECIPIENT_REMOVE,
|
||||
|
|
@ -155,8 +158,8 @@ async def add_to_group_dm(dm_chan, peer_id):
|
|||
)
|
||||
|
||||
|
||||
@bp.route('/<int:dm_chan>/recipients/<int:user_id>', methods=['DELETE'])
|
||||
async def remove_from_group_dm(dm_chan, user_id):
|
||||
@bp.route('/<int:dm_chan>/recipients/<int:peer_id>', methods=['DELETE'])
|
||||
async def remove_from_group_dm(dm_chan, peer_id):
|
||||
"""Remove users from group dm."""
|
||||
user_id = await token_check()
|
||||
_ctype, owner_id = await channel_check(
|
||||
|
|
@ -166,5 +169,5 @@ async def remove_from_group_dm(dm_chan, user_id):
|
|||
if owner_id != user_id:
|
||||
raise Forbidden('You are now the owner of the group DM')
|
||||
|
||||
await _gdm_remove_recipient(dm_chan, user_id)
|
||||
await _gdm_remove_recipient(dm_chan, peer_id)
|
||||
return '', 204
|
||||
|
|
|
|||
Loading…
Reference in New Issue