diff --git a/litecord/blueprints/dm_channels.py b/litecord/blueprints/dm_channels.py index f4e4327..b86d545 100644 --- a/litecord/blueprints/dm_channels.py +++ b/litecord/blueprints/dm_channels.py @@ -46,7 +46,7 @@ async def _raw_gdm_remove(channel_id, user_id): """, channel_id, user_id) -async def _gdm_create(user_id, peer_id) -> int: +async def gdm_create(user_id, peer_id) -> int: """Create a group dm, given two users. Returns the new GDM id. @@ -183,7 +183,7 @@ async def add_to_group_dm(dm_chan, peer_id): raise BadRequest('Cant insert peer into dm') if ctype == ChannelType.DM: - dm_chan = await _gdm_create( + dm_chan = await gdm_create( user_id, other_id ) diff --git a/litecord/blueprints/dms.py b/litecord/blueprints/dms.py index 149ff1a..4289161 100644 --- a/litecord/blueprints/dms.py +++ b/litecord/blueprints/dms.py @@ -30,6 +30,10 @@ from ..snowflake import get_snowflake from .auth import token_check +from litecord.blueprints.dm_channels import ( + gdm_create, gdm_add_recipient +) + log = Logger(__name__) bp = Blueprint('dms', __name__) @@ -122,5 +126,10 @@ async def create_group_dm(p_user_id: int): # its a group dm with 1 user... a dm! return await create_dm(user_id, int(recipients[0])) - # TODO: group dms - return 'group dms not implemented', 500 + # create a group dm with multiple users + channel_id = await gdm_create(user_id, recipients[0]) + + for recipient in recipients[1:]: + await gdm_add_recipient(channel_id, recipient) + + return jsonify(await app.storage.get_channel(channel_id))