mirror of https://gitlab.com/litecord/litecord.git
dm_channels: add dummy functions for _gdm
- storage: fix error
This commit is contained in:
parent
72cbd8017b
commit
5fc6732892
|
|
@ -24,11 +24,51 @@ from litecord.blueprints.auth import token_check
|
|||
from litecord.blueprints.checks import channel_check
|
||||
from litecord.enums import ChannelType
|
||||
from litecord.errors import BadRequest, Forbidden
|
||||
from litecord.snowflake import get_snowflake
|
||||
|
||||
log = Logger(__name__)
|
||||
bp = Blueprint('dm_channels', __name__)
|
||||
|
||||
|
||||
async def _gdm_create(user_id, peer_id) -> int:
|
||||
"""Create a group dm, given two users.
|
||||
|
||||
Returns the new GDM id.
|
||||
"""
|
||||
channel_id = get_snowflake()
|
||||
|
||||
# TODO
|
||||
|
||||
return channel_id
|
||||
|
||||
|
||||
async def _gdm_add_recipient(channel_id: int, peer_id: int, *, user_id=None):
|
||||
"""Add a recipient to a Group DM.
|
||||
|
||||
Dispatches:
|
||||
- A system message with the join (depending of user_id)
|
||||
- A CHANNEL_CREATE to the peer.
|
||||
- A CHANNEL_UPDATE to all remaining recipients.
|
||||
"""
|
||||
|
||||
# TODO
|
||||
pass
|
||||
|
||||
|
||||
async def _gdm_remove_recipient(channel_id: int, peer_id: int, *, user_id=None):
|
||||
"""Remove a member from a GDM.
|
||||
|
||||
Dispatches:
|
||||
- A system message with the leave or forced removal (depending if user_id)
|
||||
exists or not.
|
||||
- A CHANNEL_DELETE to the peer.
|
||||
- A CHANNEL_UPDATE to all remaining recipients.
|
||||
"""
|
||||
|
||||
# TODO
|
||||
pass
|
||||
|
||||
|
||||
@bp.route('/<int:dm_chan>/receipients/<int:peer_id>', methods=['PUT'])
|
||||
async def add_to_group_dm(dm_chan, peer_id):
|
||||
"""Adds a member to a group dm OR creates a group dm."""
|
||||
|
|
|
|||
|
|
@ -353,7 +353,7 @@ class Storage:
|
|||
|
||||
return list(map(_overwrite_convert, overwrite_rows))
|
||||
|
||||
async def _gdm_recipient_ids(self, channel_id: int) -> List[int]:
|
||||
async def gdm_recipient_ids(self, channel_id: int) -> List[int]:
|
||||
"""Get the list of user IDs that are recipients of the
|
||||
given Group DM."""
|
||||
user_ids = await self.db.fetch("""
|
||||
|
|
@ -370,7 +370,7 @@ class Storage:
|
|||
async def _gdm_recipients(self, channel_id: int) -> List[int]:
|
||||
"""Get the list of users that are recipients of the
|
||||
given Group DM."""
|
||||
recipients = await self._gdm_recipient_ids(channel_id)
|
||||
recipients = await self.gdm_recipient_ids(channel_id)
|
||||
res = []
|
||||
|
||||
for user_id in recipients:
|
||||
|
|
@ -435,7 +435,6 @@ class Storage:
|
|||
""", channel_id)
|
||||
|
||||
drow = dict(gdm_row)
|
||||
recipients
|
||||
drow['recipients'] = await self._gdm_recipients(channel_id)
|
||||
|
||||
return drow
|
||||
|
|
|
|||
Loading…
Reference in New Issue