Domain blocking + documentation

This commit is contained in:
Lorenz Diener 2017-06-15 23:13:34 +02:00
pare b57b66ebb5
commit aa3e678c7b
S'han modificat 2 arxius amb 42 adicions i 0 eliminacions

Veure arxiu

@ -343,6 +343,11 @@ Reading data: Reports
.. automethod:: Mastodon.reports .. automethod:: Mastodon.reports
Reading data: Domain blocks
---------------------------
.. automethod:: Mastodon.domain_blocks
Writing data: Statuses Writing data: Statuses
---------------------- ----------------------
These functions allow you to post statuses to Mastodon and to These functions allow you to post statuses to Mastodon and to
@ -390,6 +395,14 @@ Writing data: Reports
.. automethod:: Mastodon.report .. 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 Streaming
--------- ---------
These functions allow access to the streaming API. These functions allow access to the streaming API.

Veure arxiu

@ -467,6 +467,18 @@ class Mastodon:
params = self.__generate_params(locals()) params = self.__generate_params(locals())
return self.__api_request('GET', '/api/v1/follow_requests', params) 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 # Writing data: Statuses
### ###
@ -713,6 +725,23 @@ class Mastodon:
media_file_description = (file_name, media_file, mime_type) media_file_description = (file_name, media_file, mime_type)
return self.__api_request('POST', '/api/v1/media', files = {'file': media_file_description}) 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 # Streaming
### ###