New endpoints

master
spla 3 months ago
parent 05744034b8
commit b53ab9d358
  1. 7
      README.md
  2. 82
      mastodon/Mastodon.py
  3. 2
      setup.py

@ -47,6 +47,11 @@ pip3 install Mastodonplus.py
```
#### New features
* 26.8.2022. Added New endpoints: /api/v1/admin/domain_blocks (list,show by id, delete and create)
* 26.8.2022. Mastodon v3.5.x. Added New endpoints: /api/v1/admin/domain_blocks (list,show by id, delete and create)
* 27.8.2022. Mastodon v3.1.4. Added 'remote" param to GET /api/v1/timelines/public REST API
* 27.8.2022. Mastodon v3.1.4. Added GET /api/v1/streaming/public/remote (Mastodon.stream_remote())
* 06.9.2022. Mastodon v3.2.0. Added POST /api/v1/accounts/:account_id/note with comment param. (Mastodon.accounts_note(id=account_id, comment='comment')
* 06.9.2022. Mastodon v3.5.x. Added GET /api/v1/admin/ip_blocks (Mastodon.admin_ip_blocks_list(max_id=None, min_id=None, since_id=None, limit=None)
* 06.9.2022. Mastodon v3.5.x. Added DELETE /api/v1/admin/ip_blocks/:id (Mastodon.admin_ip_blocks_delete(id=None)
* 06.9.2022. Mastodon v3.5.x. Added POST /api/v1/admin/ip_blocks (Mastodon.admin_ip_blocks_create(self, ip=None, severity=None, comment=None, expires_in=None)
severity possible values are: sign_up_requires_approval, sign_up_block, no_access

@ -194,11 +194,13 @@ class Mastodon:
'admin:read:accounts',
'admin:read:reports',
'admin:read:domain_blocks',
'admin:read:ip_blocks',
],
'admin:write': [
'admin:write:accounts',
'admin:write:reports',
'admin:write:domain_blocks',
'admin:write:ip_blocks',
],
}
__VALID_SCOPES = ['read', 'write', 'follow', 'push', 'admin:read', 'admin:write'] + \
@ -238,6 +240,7 @@ class Mastodon:
__DICT_VERSION_REACTION = "3.1.0"
__DICT_VERSION_ANNOUNCEMENT = bigger_version("3.1.0", __DICT_VERSION_REACTION)
__DICT_VERSION_DOMAIN_BLOCKS = "3.5.3"
__DICT_VERSION_IP_BLOCKS = "3.5.3"
###
# Registering apps
@ -750,10 +753,10 @@ class Mastodon:
"""
if max_id != None:
max_id = self.__unpack_id(max_id)
if min_id != None:
min_id = self.__unpack_id(min_id)
if since_id != None:
since_id = self.__unpack_id(since_id)
@ -1187,14 +1190,27 @@ class Mastodon:
"""
Get all of the logged-in users lists which the specified user is
a member of.
Returns a list of `list dicts`_.
"""
id = self.__unpack_id(id)
params = self.__generate_params(locals(), ['id'])
url = '/api/v1/accounts/{0}/lists'.format(str(id))
return self.__api_request('GET', url, params)
@api_version("3.5.3", "3.5.3", __DICT_VERSION_LIST)
def accounts_note(self, id, comment=None):
"""
Add personal notes for accounts
"""
if comment != None:
comment = comment
id = self.__unpack_id(id)
params = self.__generate_params(locals(), ['id'])
url = '/api/v1/accounts/{0}/note'.format(id)
return self.__api_request('POST', url, params)
###
# Reading data: Featured hashtags
###
@ -2997,13 +3013,13 @@ class Mastodon:
@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.
Delete 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):
def admin_domain_blocks_create(self, domain=None, severity=None, reject_media=None, reject_reports=None, private_comment=None, public_comment=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.
@ -3014,11 +3030,64 @@ class Mastodon:
reject_media = 'false'
if reject_reports == None:
reject_reports = 'false'
if private_comment != None:
private_comment = private_comment
if public_comment != None:
public_comment = public_comment
if obfuscate == None:
obfuscate = 'false'
params = self.__generate_params(locals())
return self.__api_request('POST', '/api/v1/admin/domain_blocks', params)
@api_version("3.5.3", "3.5.3", __DICT_VERSION_IP_BLOCKS)
def admin_ip_blocks_list(self, max_id=None, min_id=None, since_id=None, limit=None):
"""
List IP blocks.
"""
if max_id != None:
max_id = self.__unpack_id(max_id)
if min_id != None:
min_id = self.__unpack_id(min_id)
if since_id != None:
since_id = self.__unpack_id(since_id)
params_initial = locals()
params = self.__generate_params(params_initial)
return self.__api_request('GET', '/api/v1/admin/ip_blocks', params)
@api_version("3.5.3", "3.5.3", __DICT_VERSION_IP_BLOCKS)
def admin_ip_blocks_delete(self, id):
"""
Delete one IP block by id.
"""
id = self.__unpack_id(id)
return self.__api_request('DELETE', '/api/v1/admin/ip_blocks/{0}'.format(id))
@api_version("3.5.3", "3.5.3", __DICT_VERSION_IP_BLOCKS)
def admin_ip_blocks_create(self, ip=None, severity=None, comment=None, expires_in=None):
"""
To create a new IP block.
severity possible values:
sign_up_requires_approval
sign_up_block
no_access
"""
if ip == None:
return("Missing required IP.")
if severity == None:
severity = 'sign_up_requires_approval'
if comment == None:
comment = "blocked"
if expires_in == None:
expires_in = 86400
params = self.__generate_params(locals())
return self.__api_request('POST', '/api/v1/admin/ip_blocks', params)
###
# Push subscription crypto utilities
###
@ -3224,7 +3293,6 @@ class Mastodon:
"""
return self.__stream('/api/v1/streaming/public/remote', listener, run_async=run_async, timeout=timeout, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec)
@api_version("1.1.0", "1.4.2", __DICT_VERSION_STATUS)
def stream_hashtag(self, tag, listener, local=False, run_async=False, timeout=__DEFAULT_STREAM_TIMEOUT, reconnect_async=False, reconnect_async_wait_sec=__DEFAULT_STREAM_RECONNECT_WAIT_SEC):
"""

@ -1,6 +1,6 @@
import setuptools
VERSION = '1.5.5.2'
VERSION = '1.5.5.4'
test_deps = [
'pytest',

Loading…
Cancel
Save