2022-11-30 23:39:08 +00:00
|
|
|
# conversations.py - conversation endpoints
|
|
|
|
|
2023-06-19 21:35:03 +00:00
|
|
|
from mastodon.versions import _DICT_VERSION_CONVERSATION
|
|
|
|
from mastodon.utility import api_version
|
2022-11-30 23:39:08 +00:00
|
|
|
|
2023-06-19 21:35:03 +00:00
|
|
|
from mastodon.internals import Mastodon as Internals
|
|
|
|
from typing import Union, Optional
|
|
|
|
from mastodon.types import IdType, PaginatableList, Conversation
|
2023-01-02 13:39:16 +00:00
|
|
|
|
|
|
|
class Mastodon(Internals):
|
2022-11-30 23:39:08 +00:00
|
|
|
###
|
|
|
|
# Reading data: Conversations
|
|
|
|
###
|
|
|
|
@api_version("2.6.0", "2.6.0", _DICT_VERSION_CONVERSATION)
|
2023-06-19 21:35:03 +00:00
|
|
|
def conversations(self, max_id: Optional[Union[Conversation, IdType]] = None, min_id: Optional[Union[Conversation, IdType]] = None, since_id:
|
|
|
|
Optional[Union[Conversation, IdType]] = None, limit: Optional[int] = None) -> PaginatableList[Conversation]:
|
2022-11-30 23:39:08 +00:00
|
|
|
"""
|
|
|
|
Fetches a user's conversations.
|
|
|
|
"""
|
|
|
|
if max_id is not None:
|
2023-06-19 21:35:03 +00:00
|
|
|
max_id = self.__unpack_id(max_id)
|
2022-11-30 23:39:08 +00:00
|
|
|
|
|
|
|
if min_id is not None:
|
2023-06-19 21:35:03 +00:00
|
|
|
min_id = self.__unpack_id(min_id)
|
2022-11-30 23:39:08 +00:00
|
|
|
|
|
|
|
if since_id is not None:
|
2023-06-19 21:35:03 +00:00
|
|
|
since_id = self.__unpack_id(since_id)
|
2022-11-30 23:39:08 +00:00
|
|
|
|
|
|
|
params = self.__generate_params(locals())
|
|
|
|
return self.__api_request('GET', "/api/v1/conversations/", params)
|
|
|
|
|
|
|
|
###
|
|
|
|
# Writing data: Conversations
|
|
|
|
###
|
|
|
|
@api_version("2.6.0", "2.6.0", _DICT_VERSION_CONVERSATION)
|
2023-06-19 21:35:03 +00:00
|
|
|
def conversations_read(self, id: Union[Conversation, IdType]):
|
2022-11-30 23:39:08 +00:00
|
|
|
"""
|
|
|
|
Marks a single conversation as read.
|
|
|
|
|
2023-06-19 21:35:03 +00:00
|
|
|
The returned object reflects the conversation's new read status.
|
2022-11-30 23:39:08 +00:00
|
|
|
"""
|
|
|
|
id = self.__unpack_id(id)
|
2022-12-02 21:04:23 +00:00
|
|
|
return self.__api_request('POST', f'/api/v1/conversations/{id}/read')
|