kopia lustrzana https://github.com/halcy/Mastodon.py
add server rules API
rodzic
bfdde7781b
commit
6a630202db
2
TODO.md
2
TODO.md
|
@ -29,7 +29,7 @@ Refer to mastodon changelog and API docs for details when implementing, add or m
|
||||||
|
|
||||||
3.4.0
|
3.4.0
|
||||||
-----
|
-----
|
||||||
* [ ] Add server rules
|
* [x] Add server rules
|
||||||
* [ ] Add POST /api/v1/emails/confirmations to REST API
|
* [ ] Add POST /api/v1/emails/confirmations to REST API
|
||||||
* [ ] Add GET /api/v1/accounts/lookup to REST API
|
* [ ] Add GET /api/v1/accounts/lookup to REST API
|
||||||
* [ ] Add policy param to POST /api/v1/push/subscriptions in REST API
|
* [ ] Add policy param to POST /api/v1/push/subscriptions in REST API
|
||||||
|
|
|
@ -774,8 +774,7 @@ class Mastodon:
|
||||||
"""
|
"""
|
||||||
Basic health check. Returns True if healthy, False if not.
|
Basic health check. Returns True if healthy, False if not.
|
||||||
"""
|
"""
|
||||||
status = self.__api_request(
|
status = self.__api_request('GET', '/health', parse=False).decode("utf-8")
|
||||||
'GET', '/health', parse=False).decode("utf-8")
|
|
||||||
return status in ["OK", "success"]
|
return status in ["OK", "success"]
|
||||||
|
|
||||||
@api_version("3.0.0", "3.0.0", "3.0.0")
|
@api_version("3.0.0", "3.0.0", "3.0.0")
|
||||||
|
@ -807,6 +806,15 @@ class Mastodon:
|
||||||
parse = urlparse(schema_url)
|
parse = urlparse(schema_url)
|
||||||
return self.__api_request('GET', parse.path + parse.params + parse.query + parse.fragment)
|
return self.__api_request('GET', parse.path + parse.params + parse.query + parse.fragment)
|
||||||
|
|
||||||
|
@api_version("3.4.0", "3.4.0", __DICT_VERSION_INSTANCE)
|
||||||
|
def instance_rules(self):
|
||||||
|
"""
|
||||||
|
Retrieve instance rules.
|
||||||
|
|
||||||
|
Returns a list of `id` + `text` dicts, same as the `rules` field in the `instance dicts`_.
|
||||||
|
"""
|
||||||
|
return self.__api_request('GET', '/api/v1/instance/rules')
|
||||||
|
|
||||||
###
|
###
|
||||||
# Reading data: Timelines
|
# Reading data: Timelines
|
||||||
##
|
##
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
interactions:
|
||||||
|
- request:
|
||||||
|
body: null
|
||||||
|
headers:
|
||||||
|
Accept:
|
||||||
|
- '*/*'
|
||||||
|
Accept-Encoding:
|
||||||
|
- gzip, deflate
|
||||||
|
Authorization:
|
||||||
|
- Bearer __MASTODON_PY_TEST_ACCESS_TOKEN
|
||||||
|
Connection:
|
||||||
|
- keep-alive
|
||||||
|
User-Agent:
|
||||||
|
- tests/v311
|
||||||
|
method: GET
|
||||||
|
uri: http://localhost:3000/api/v1/instance/rules
|
||||||
|
response:
|
||||||
|
body:
|
||||||
|
string: '[]'
|
||||||
|
headers:
|
||||||
|
Cache-Control:
|
||||||
|
- no-store
|
||||||
|
Content-Security-Policy:
|
||||||
|
- 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src
|
||||||
|
''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000;
|
||||||
|
style-src ''self'' http://localhost:3000 ''nonce-VfLfKge8CLCQB9dJyA6/cA=='';
|
||||||
|
media-src ''self'' https: data: http://localhost:3000; frame-src ''self''
|
||||||
|
https:; manifest-src ''self'' http://localhost:3000; connect-src ''self''
|
||||||
|
data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000
|
||||||
|
ws://localhost:3035 http://localhost:3035; script-src ''self'' ''unsafe-inline''
|
||||||
|
''unsafe-eval'' http://localhost:3000; child-src ''self'' blob: http://localhost:3000;
|
||||||
|
worker-src ''self'' blob: http://localhost:3000'
|
||||||
|
Content-Type:
|
||||||
|
- application/json; charset=utf-8
|
||||||
|
ETag:
|
||||||
|
- W/"4f53cda18c2baa0c0354bb5f9a3ecbe5"
|
||||||
|
Referrer-Policy:
|
||||||
|
- strict-origin-when-cross-origin
|
||||||
|
Transfer-Encoding:
|
||||||
|
- chunked
|
||||||
|
Vary:
|
||||||
|
- Accept, Origin
|
||||||
|
X-Content-Type-Options:
|
||||||
|
- nosniff
|
||||||
|
X-Download-Options:
|
||||||
|
- noopen
|
||||||
|
X-Frame-Options:
|
||||||
|
- SAMEORIGIN
|
||||||
|
X-Permitted-Cross-Domain-Policies:
|
||||||
|
- none
|
||||||
|
X-Request-Id:
|
||||||
|
- 48fd3107-1ed2-4db1-8ae6-a62ac4897b98
|
||||||
|
X-Runtime:
|
||||||
|
- '0.036615'
|
||||||
|
X-XSS-Protection:
|
||||||
|
- 1; mode=block
|
||||||
|
status:
|
||||||
|
code: 200
|
||||||
|
message: OK
|
||||||
|
version: 1
|
|
@ -72,4 +72,6 @@ def test_directory(api):
|
||||||
assert isinstance(directory, list)
|
assert isinstance(directory, list)
|
||||||
assert len(directory) > 0
|
assert len(directory) > 0
|
||||||
|
|
||||||
|
@pytest.mark.vcr()
|
||||||
|
def test_instance_rules(api):
|
||||||
|
assert isinstance(api.instance_rules(), list)
|
||||||
|
|
Ładowanie…
Reference in New Issue