From 36781699c135b3a4cd89973ef2f5079f123a0567 Mon Sep 17 00:00:00 2001 From: Erin Congden Date: Sun, 2 Apr 2017 20:20:38 -0700 Subject: Add (un)muting accounts and reading mutes/blocks --- docs/index.rst | 11 +++++++++++ mastodon/Mastodon.py | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/docs/index.rst b/docs/index.rst index 90e8478..f9915e6 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -139,6 +139,7 @@ Relationship dicts 'following': Boolean denoting whether you follow them 'id': Numerical id (same one as ) 'blocking': Boolean denoting whether you are blocking them + 'muting': Boolean denoting whether you are muting them } Notification dicts @@ -238,6 +239,14 @@ their relationships. .. automethod:: Mastodon.account_relationships .. automethod:: Mastodon.account_search +Reading data: Mutes and blocks +------------------------------ +These functions allow you to get information about accounts that are +muted or blocked by the logged in user. + +.. automethod:: Mastodon.mutes +.. automethod:: Mastodon.blocks + Writing data: Statuses ---------------------- These functions allow you to post statuses to Mastodon and to @@ -260,6 +269,8 @@ These functions allow you to interact with other accounts: To (un)follow and .. automethod:: Mastodon.account_unfollow .. automethod:: Mastodon.account_block .. automethod:: Mastodon.account_unblock +.. automethod:: Mastodon.account_mute +.. automethod:: Mastodon.account_unmute Writing data: Media ------------------- diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 641c415..1c9ca4b 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -329,6 +329,25 @@ class Mastodon: params = self.__generate_params(locals()) return self.__api_request('GET', '/api/v1/accounts/search', params) + ### + # Reading data: Mutes and Blocks + ### + def mutes(self): + """ + Fetch a list of users muted by the authenticated user. + + Returns a list of user dicts. + """ + return self.__api_request('GET', '/api/v1/mutes') + + def blocks(self): + """ + Fetch a list of users blocked by the authenticated user. + + Returns a list of user dicts. + """ + return self.__api_request('GET', '/api/v1/blocks') + ### # Writing data: Statuses ### @@ -462,6 +481,22 @@ class Mastodon: """ return self.__api_request('POST', '/api/v1/accounts/' + str(id) + "/unblock") + def account_mute(self, id): + """ + Mute a user. + + Returns a relationship dict containing the updated relationship to the user. + """ + return self.__api_request('POST', '/api/v1/accounts/' + str(id) + "/mute") + + def account_unmute(self, id): + """ + Unmute a user. + + Returns a relationship dict containing the updated relationship to the user. + """ + return self.__api_request('POST', '/api/v1/accounts/' + str(id) + "/unmute") + ### # Writing data: Media ### -- cgit v1.2.3