From ca0b6c115bcb8f6b79b22f5ccd648a2d6b7d7fc5 Mon Sep 17 00:00:00 2001 From: Erin Congden Date: Sun, 2 Apr 2017 20:53:32 -0700 Subject: Added follow requests support --- docs/index.rst | 16 ++++++++++++++++ mastodon/Mastodon.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/docs/index.rst b/docs/index.rst index 9dc37e5..8be642a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -99,6 +99,7 @@ User dicts 'header': URL for their header image 'id': Same as 'username': The username (what you @ them with) + 'locked': Denotes whether the account can be followed without a follow request } Toot dicts @@ -140,6 +141,7 @@ Relationship dicts 'id': Numerical id (same one as ) 'blocking': Boolean denoting whether you are blocking them 'muting': Boolean denoting whether you are muting them + 'requested': Boolean denoting whether you have sent them a follow request } Notification dicts @@ -254,6 +256,13 @@ by the authenticated user. .. authomethod:: Mastodon.favourites +Reading data: Follow requests +----------------------------- +This function allows you to get a list of pending incoming follow +requests for the authenticated user. + +.. automethod:: Mastodon.follow_requests + Writing data: Statuses ---------------------- These functions allow you to post statuses to Mastodon and to @@ -279,6 +288,13 @@ These functions allow you to interact with other accounts: To (un)follow and .. automethod:: Mastodon.account_mute .. automethod:: Mastodon.account_unmute +Writing data: Follow requests +----------------------------- +These functions allow you to accept or reject incoming follow requests. + +.. automethod:: Mastodon.follow_request_authorize +.. automethod:: Mastodon.follow_request_reject + Writing data: Media ------------------- This function allows you to upload media to Mastodon. The returned diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index d42c13f..06fe8a1 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -359,6 +359,18 @@ class Mastodon: """ return self.__api_request('GET', '/api/v1/favourites') + ### + # Reading data: Follow requests + ### + def follow_requests(self, max_id = None, since_id = None, limit = None): + """ + Fetch the authenticated user's incoming follow requests. + + Returns a list of user dicts. + """ + params = self.__generate_params(locals()) + return self.__api_request('GET', '/api/v1/follow_requests', params) + ### # Writing data: Statuses ### @@ -509,6 +521,25 @@ class Mastodon: """ return self.__api_request('POST', '/api/v1/accounts/' + str(id) + "/unmute") + ### + # Writing data: Follow requests + ### + def follow_request_authorize(self, id): + """ + Accept an incoming follow request. + + Returns a user dict of the authorized account. + """ + return self.__api_request('POST', '/api/v1/follow_requests/' + str(id) + "/authorize") + + def follow_request_reject(self, id): + """ + Reject an incoming follow request. + + Returns a user dict of the rejected account. + """ + return self.__api_request('POST', '/api/v1/follow_requests/' + str(id) + "/reject") + ### # Writing data: Media ### -- cgit v1.2.3