From aa3e678c7b8306f1922a2b6de1198b3e677b8d01 Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Thu, 15 Jun 2017 23:13:34 +0200 Subject: [PATCH] Domain blocking + documentation --- docs/index.rst | 13 +++++++++++++ mastodon/Mastodon.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/docs/index.rst b/docs/index.rst index 90cc8e2..c59940d 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -343,6 +343,11 @@ Reading data: Reports .. automethod:: Mastodon.reports +Reading data: Domain blocks +--------------------------- + +.. automethod:: Mastodon.domain_blocks + Writing data: Statuses ---------------------- These functions allow you to post statuses to Mastodon and to @@ -390,6 +395,14 @@ Writing data: Reports .. automethod:: Mastodon.report +Writing data: Domain blocks +--------------------------- +These methods allow you to block and unblock all statuses from a domain +for the logged-in user. + +.. automethod:: Mastodon.domain_block +.. automethod:: Mastodon.domain_unblock + Streaming --------- These functions allow access to the streaming API. diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 3cf889a..e66711b 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -467,6 +467,18 @@ class Mastodon: params = self.__generate_params(locals()) return self.__api_request('GET', '/api/v1/follow_requests', params) + ### + # Reading data: Domain blocks + ### + def domain_blocks(self, max_id = None, since_id = None, limit = None): + """ + Fetch the authenticated user's blocked domain. + + Returns a list of blocked domain URLs. + """ + params = self.__generate_params(locals()) + return self.__api_request('GET', '/api/v1/domain_blocks', params) + ### # Writing data: Statuses ### @@ -713,6 +725,23 @@ class Mastodon: media_file_description = (file_name, media_file, mime_type) return self.__api_request('POST', '/api/v1/media', files = {'file': media_file_description}) + ### + # Writing data: Domain blocks + ### + def domain_block(self, domain = None): + """ + Add a block for all statuses originating from the specified domain for the logged-in user. + """ + params = self.__generate_params(locals()) + return self.__api_request('POST', '/api/v1/domain_blocks', params) + + def domain_unblock(self, domain = None): + """ + Remove a domain block for the logged-in user. + """ + params = self.__generate_params(locals()) + return self.__api_request('DELETE', '/api/v1/domain_blocks', params) + ### # Streaming ###