dms: add gdm creation on create_group_dm

This commit is contained in:
Luna 2019-02-19 19:02:51 -03:00
parent 73da3e0c8e
commit 658b3465c8
2 changed files with 13 additions and 4 deletions

View File

@ -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
)

View File

@ -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))