mirror of https://gitlab.com/litecord/litecord.git
add theoretical impl for gdm invites
This commit is contained in:
parent
a260e07152
commit
7bde2dd7a1
|
|
@ -103,6 +103,7 @@ async def use_invite(user_id, invite_code):
|
||||||
await delete_invite(invite_code)
|
await delete_invite(invite_code)
|
||||||
raise InvalidInvite('Too many uses')
|
raise InvalidInvite('Too many uses')
|
||||||
|
|
||||||
|
# TODO: if group dm invite, guild_id is null.
|
||||||
guild_id = inv['guild_id']
|
guild_id = inv['guild_id']
|
||||||
await invite_precheck(user_id, guild_id)
|
await invite_precheck(user_id, guild_id)
|
||||||
|
|
||||||
|
|
@ -151,25 +152,29 @@ async def use_invite(user_id, invite_code):
|
||||||
|
|
||||||
@bp.route('/channels/<int:channel_id>/invites', methods=['POST'])
|
@bp.route('/channels/<int:channel_id>/invites', methods=['POST'])
|
||||||
async def create_invite(channel_id):
|
async def create_invite(channel_id):
|
||||||
|
"""Create an invite to a channel."""
|
||||||
user_id = await token_check()
|
user_id = await token_check()
|
||||||
|
|
||||||
j = validate(await request.get_json(), INVITE)
|
j = validate(await request.get_json(), INVITE)
|
||||||
_ctype, guild_id = await channel_check(user_id, channel_id)
|
|
||||||
|
|
||||||
|
chantype, maybe_guild_id = await channel_check(user_id, channel_id)
|
||||||
|
chantype = ChannelType(chantype)
|
||||||
|
|
||||||
|
# NOTE: this works on group dms, since it returns ALL_PERMISSIONS on
|
||||||
|
# non-guild channels.
|
||||||
await channel_perm_check(user_id, channel_id, 'create_invites')
|
await channel_perm_check(user_id, channel_id, 'create_invites')
|
||||||
|
|
||||||
chantype = await app.storage.get_chan_type(channel_id)
|
if chantype not in (ChannelType.GUILD_TEXT,
|
||||||
|
ChannelType.GUILD_VOICE,
|
||||||
# can't create invites for channels that aren't text
|
ChannelType.GROUP_DM):
|
||||||
# or voice.
|
|
||||||
|
|
||||||
# TODO: once group dms are in, this should change to account.
|
|
||||||
if chantype not in (ChannelType.GUILD_TEXT.value,
|
|
||||||
ChannelType.GUILD_VOICE.value):
|
|
||||||
raise BadRequest('Invalid channel type')
|
raise BadRequest('Invalid channel type')
|
||||||
|
|
||||||
invite_code = gen_inv_code()
|
invite_code = gen_inv_code()
|
||||||
|
|
||||||
|
if chantype in (ChannelType.GUILD_TEXT, ChannelType.GUILD_VOICE):
|
||||||
|
guild_id = maybe_guild_id
|
||||||
|
else:
|
||||||
|
guild_id = None
|
||||||
|
|
||||||
await app.db.execute(
|
await app.db.execute(
|
||||||
"""
|
"""
|
||||||
INSERT INTO invites
|
INSERT INTO invites
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue