Added admin_domain_blocks endpoints

This commit is contained in:
spla 2022-08-26 11:34:16 +02:00
pare 89a6bd2bac
commit 11d9da9291

Veure arxiu

@ -193,10 +193,12 @@ class Mastodon:
'admin:read': [
'admin:read:accounts',
'admin:read:reports',
'admin:read:domain_blocks',
],
'admin:write': [
'admin:write:accounts',
'admin:write:reports',
'admin:write:domain_blocks',
],
}
__VALID_SCOPES = ['read', 'write', 'follow', 'push', 'admin:read', 'admin:write'] + \
@ -235,6 +237,7 @@ class Mastodon:
__DICT_VERSION_MARKER = "3.0.0"
__DICT_VERSION_REACTION = "3.1.0"
__DICT_VERSION_ANNOUNCEMENT = bigger_version("3.1.0", __DICT_VERSION_REACTION)
__DICT_VERSION_DOMAIN_BLOCKS = "3.5.3"
###
# Registering apps
@ -2972,7 +2975,47 @@ class Mastodon:
"""
id = self.__unpack_id(id)
return self.__api_request('POST', '/api/v1/admin/reports/{0}/resolve'.format(id))
@api_version("3.5.3", "3.5.3", __DICT_VERSION_DOMAIN_BLOCKS)
def admin_domain_blocks_list(self):
"""
List domain blocks.
"""
return self.__api_request('GET', '/api/v1/admin/domain_blocks')
@api_version("3.5.3", "3.5.3", __DICT_VERSION_DOMAIN_BLOCKS)
def admin_domain_blocks(self, id):
"""
Shows one domain block by id.
"""
id = self.__unpack_id(id)
return self.__api_request('GET', '/api/v1/admin/domain_blocks/{0}'.format(id))
@api_version("3.5.3", "3.5.3", __DICT_VERSION_DOMAIN_BLOCKS)
def admin_domain_blocks_delete(self, id):
"""
Shows one domain block by id.
"""
id = self.__unpack_id(id)
return self.__api_request('DELETE', '/api/v1/admin/domain_blocks/{0}'.format(id))
@api_version("3.5.3", "3.5.3", __DICT_VERSION_DOMAIN_BLOCKS)
def admin_domain_blocks_create(self, domain=None, severity=None, reject_media=None, reject_reports=None, obfuscate=None):
"""
To create a new domain block.
If it conflicts with an existing one, returns an error with an attribute `existing_domain_block` with the rendered domain block.
"""
if severity == None:
severity = 'silence'
if reject_media == None:
reject_media = 'false'
if reject_reports == None:
reject_reports = 'false'
if obfuscate == None:
obfuscate = 'false'
params = self.__generate_params(locals())
return self.__api_request('POST', '/api/v1/admin/domain_blocks', params)
###
# Push subscription crypto utilities
###