diff --git a/swibots/api/chat/controllers/message_controller.py b/swibots/api/chat/controllers/message_controller.py index 4634d558..ea48fd12 100644 --- a/swibots/api/chat/controllers/message_controller.py +++ b/swibots/api/chat/controllers/message_controller.py @@ -1,5 +1,4 @@ import asyncio -import mimetypes import os import json import logging @@ -8,7 +7,6 @@ from io import BytesIO from asyncio.tasks import Task from swibots.types import MediaType -from swibots.errors import CancelError from swibots.api.chat.models import ( Message, GroupChatHistory, @@ -368,7 +366,7 @@ async def delete_messages_from_user( async def get_messages_between_users( self, - recipient_id: int, + other_user_id: int, user_id: int = None, page_limit: int = 100, page_offset: int = 0, @@ -376,7 +374,7 @@ async def get_messages_between_users( """Get messages between two users Parameters: - recipient_id (``int``): The recipient id + other_user_id (``int``): The other user id. user_id (``int``, *optional*): The user id. Defaults to the current user id. page_limit (``int``, *optional*): The page limit. Defaults to 100. page_offset (``int``, *optional*): The page offset. Defaults to 0. @@ -389,17 +387,17 @@ async def get_messages_between_users( """ data = { "pageOffset": page_offset, - "pageLimit": 0, + "pageLimit": page_limit, } if user_id is None: user_id = self.client.user.id - log.debug("Getting messages for user %s", recipient_id) + log.debug("Getting messages for user %s", other_user_id) response = await self.client.get( - f"{BASE_PATH}/{user_id}/{recipient_id}?{urlencode(data)}" + f"{BASE_PATH}/{user_id}/{other_user_id}?{urlencode(data)}" ) - return self.client.build_list(Message, response.data["messages"]) + return self.client.build_list(Message, response.data) async def forward_message( self, diff --git a/swibots/api/chat/methods/get_messages_between_users.py b/swibots/api/chat/methods/get_messages_between_users.py index 8d2bca6e..b9ae0731 100644 --- a/swibots/api/chat/methods/get_messages_between_users.py +++ b/swibots/api/chat/methods/get_messages_between_users.py @@ -6,16 +6,16 @@ class GetMessagesBetweenUsers: async def get_messages_between_users( self: "swibots.ApiClient", - user_id: int, other_user_id: int, + user_id: int = None, limit: int = 100, offset: int = 0, ) -> List[Message]: """Get messages between users Parameters: - user_id (``int``): The user id - other_user_id (``int``): The other user id + other_user_id (``int``): The other user id. + user_id (``int``, *optional*): The user id. Defaults to the current user id. limit (``int``, *optional*): The maximum number of messages to retrieve. Defaults to 100. offset (``int``, *optional*): The offset. Defaults to 0. @@ -28,5 +28,5 @@ async def get_messages_between_users( This function does the same as :meth:`~switch.api.chat.controllers.MessageController.get_messages_between_users`. """ return await self.chat_service.messages.get_messages_between_users( - user_id, other_user_id, limit, offset + other_user_id, user_id, limit, offset )