aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mastodon/statuses.py')
-rw-r--r--mastodon/statuses.py108
1 files changed, 108 insertions, 0 deletions
diff --git a/mastodon/statuses.py b/mastodon/statuses.py
new file mode 100644
index 0000000..ae891d5
--- /dev/null
+++ b/mastodon/statuses.py
@@ -0,0 +1,108 @@
1
2from .versions import _DICT_VERSION_STATUS, _DICT_VERSION_CARD, _DICT_VERSION_CONTEXT, _DICT_VERSION_ACCOUNT, _DICT_VERSION_SCHEDULED_STATUS
3from .utility import api_version
4
5from .internals import Mastodon as Internals
6
7
8class Mastodon(Internals):
9 ###
10 # Reading data: Statuses
11 ###
12 @api_version("1.0.0", "2.0.0", _DICT_VERSION_STATUS)
13 def status(self, id):
14 """
15 Fetch information about a single toot.
16
17 Does not require authentication for publicly visible statuses.
18
19 Returns a :ref:`status dict <status dict>`.
20 """
21 id = self.__unpack_id(id)
22 url = '/api/v1/statuses/{0}'.format(str(id))
23 return self.__api_request('GET', url)
24
25 @api_version("1.0.0", "3.0.0", _DICT_VERSION_CARD)
26 def status_card(self, id):
27 """
28 Fetch a card associated with a status. A card describes an object (such as an
29 external video or link) embedded into a status.
30
31 Does not require authentication for publicly visible statuses.
32
33 This function is deprecated as of 3.0.0 and the endpoint does not
34 exist anymore - you should just use the "card" field of the status dicts
35 instead. Mastodon.py will try to mimic the old behaviour, but this
36 is somewhat inefficient and not guaranteed to be the case forever.
37
38 Returns a :ref:`card dict <card dict>`.
39 """
40 if self.verify_minimum_version("3.0.0", cached=True):
41 return self.status(id).card
42 else:
43 id = self.__unpack_id(id)
44 url = '/api/v1/statuses/{0}/card'.format(str(id))
45 return self.__api_request('GET', url)
46
47 @api_version("1.0.0", "1.0.0", _DICT_VERSION_CONTEXT)
48 def status_context(self, id):
49 """
50 Fetch information about ancestors and descendants of a toot.
51
52 Does not require authentication for publicly visible statuses.
53
54 Returns a :ref:`context dict <context dict>`.
55 """
56 id = self.__unpack_id(id)
57 url = '/api/v1/statuses/{0}/context'.format(str(id))
58 return self.__api_request('GET', url)
59
60 @api_version("1.0.0", "2.1.0", _DICT_VERSION_ACCOUNT)
61 def status_reblogged_by(self, id):
62 """
63 Fetch a list of users that have reblogged a status.
64
65 Does not require authentication for publicly visible statuses.
66
67 Returns a list of :ref:`account dicts <account dicts>`.
68 """
69 id = self.__unpack_id(id)
70 url = '/api/v1/statuses/{0}/reblogged_by'.format(str(id))
71 return self.__api_request('GET', url)
72
73 @api_version("1.0.0", "2.1.0", _DICT_VERSION_ACCOUNT)
74 def status_favourited_by(self, id):
75 """
76 Fetch a list of users that have favourited a status.
77
78 Does not require authentication for publicly visible statuses.
79
80 Returns a list of :ref:`account dicts <account dicts>`.
81 """
82 id = self.__unpack_id(id)
83 url = '/api/v1/statuses/{0}/favourited_by'.format(str(id))
84 return self.__api_request('GET', url)
85
86 ###
87 # Reading data: Scheduled statuses
88 ###
89 @api_version("2.7.0", "2.7.0", _DICT_VERSION_SCHEDULED_STATUS)
90 def scheduled_statuses(self):
91 """
92 Fetch a list of scheduled statuses
93
94 Returns a list of :ref:`scheduled status dicts <scheduled status dicts>`.
95 """
96 return self.__api_request('GET', '/api/v1/scheduled_statuses')
97
98 @api_version("2.7.0", "2.7.0", _DICT_VERSION_SCHEDULED_STATUS)
99 def scheduled_status(self, id):
100 """
101 Fetch information about the scheduled status with the given id.
102
103 Returns a :ref:`scheduled status dict <scheduled status dict>`.
104 """
105 id = self.__unpack_id(id)
106 url = '/api/v1/scheduled_statuses/{0}'.format(str(id))
107 return self.__api_request('GET', url)
108 \ No newline at end of file
Powered by cgit v1.2.3 (git 2.41.0)