add avatar/header delete

pull/397/head
halcy 2025-02-14 23:45:52 +02:00
rodzic ca735b4e05
commit a7a03415a8
6 zmienionych plików z 188 dodań i 33 usunięć

Wyświetl plik

@ -28,6 +28,9 @@ v2.0.0 (IN PROGRESS)
* Add canonical domain block support (`admin_canonical_email_blocks`, `admin_canonical_email_block`, `admin_canonical_email_block_create`, `admin_canonical_email_block_delete`)
* Add trending link timeline (`timeline_link`)
* Update suggestions endpoint and return value
* Add with_suspended parameter to account_relationships
* Add forward_to_domains parameter to reports
* Add `account_delete_avatar` and `account_delete_header`
v1.8.1
------

Wyświetl plik

@ -45,6 +45,9 @@ Writing
.. _status_unpin():
.. automethod:: Mastodon.status_unpin
.. automethod:: Mastodon.account_delete_avatar
.. automethod:: Mastodon.account_delete_header
Following and followers
-----------------------
These functions allow you to get information about the logged in users followers and users that the logged in users follows as well as follow requests and follow suggestions, and to

Wyświetl plik

@ -240,10 +240,12 @@ class Mastodon(Internals):
return self.__api_request('GET', f'/api/v1/accounts/{id}/followers', params)
@api_version("1.0.0", "1.4.0", _DICT_VERSION_RELATIONSHIP)
def account_relationships(self, id: Union[List[Union[Account, IdType]], Union[Account, IdType]]) -> NonPaginatableList[Relationship]:
def account_relationships(self, id: Union[List[Union[Account, IdType]], Union[Account, IdType]], with_suspended: Optional[bool] = None) -> NonPaginatableList[Relationship]:
"""
Fetch relationship (following, followed_by, blocking, follow requested) of
the logged in user to a given account. `id` can be a list.
Pass `with_suspended = True` to include relationships with suspended accounts.
"""
id = self.__unpack_id(id)
params = self.__generate_params(locals())
@ -485,3 +487,17 @@ class Mastodon(Internals):
"""
id = self.__unpack_id(id)
return self.__api_request('GET', f'/api/v1/accounts/{id}/featured_tags')
@api_version("4.2.0", "4.2.0", _DICT_VERSION_ACCOUNT)
def account_delete_avatar(self):
"""
Delete the logged-in user's avatar.
"""
self.__api_request('DELETE', '/api/v1/profile/avatar')
@api_version("4.2.0", "4.2.0", _DICT_VERSION_ACCOUNT)
def account_delete_header(self):
"""
Delete the logged-in user's header.
"""
self.__api_request('DELETE', '/api/v1/profile/header')

Wyświetl plik

@ -30,7 +30,7 @@ class Mastodon(Internals):
###
@api_version("1.1.0", "3.5.0", _DICT_VERSION_REPORT)
def report(self, account_id: Union[Account, IdType], status_ids: Optional[Union[Status, IdType]] = None, comment: Optional[str] = None,
forward: bool = False, category: Optional[str] = None, rule_ids: Optional[List[Union[Rule, IdType]]] = None) -> Report:
forward: bool = False, category: Optional[str] = None, rule_ids: Optional[List[Union[Rule, IdType]]] = None, forward_to_domains: Optional[List[str]] = None) -> Report:
"""
Report statuses to the instances administrators.
@ -41,7 +41,9 @@ class Mastodon(Internals):
to the rules returned by the :ref:`instance() <instance()>` API).
Set `forward` to True to forward a report of a remote user to that users
instance as well as sending it to the instance local administrators.
instance as well as sending it to the instance local administrators. Set
forward_to_domains to a list of domains to forward the report to (only domains of
people mentioned in the status), or omitto forward to the domain of the reported status.
"""
if category is not None and not category in ["spam", "violation", "other"]:
raise MastodonIllegalArgumentError("Invalid report category (must be spam, violation or other)")

Wyświetl plik

@ -1,21 +1,21 @@
interactions:
- request:
body: !!binary |
LS0zNzE2Mzk5NjQxZDdkYmNiZmQ0ZDRmMmNjZGMwNmUzMQ0KQ29udGVudC1EaXNwb3NpdGlvbjog
Zm9ybS1kYXRhOyBuYW1lPSJkaXNwbGF5X25hbWUiDQoNCkpvaG4gTGVubm9uDQotLTM3MTYzOTk2
NDFkN2RiY2JmZDRkNGYyY2NkYzA2ZTMxDQpDb250ZW50LURpc3Bvc2l0aW9uOiBmb3JtLWRhdGE7
IG5hbWU9Im5vdGUiDQoNCkkgd2FsayBmdW5ueQ0KLS0zNzE2Mzk5NjQxZDdkYmNiZmQ0ZDRmMmNj
ZGMwNmUzMQ0KQ29udGVudC1EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJmaWVsZHNfYXR0
cmlidXRlc1swXVtuYW1lXSINCg0KYnJlYWQNCi0tMzcxNjM5OTY0MWQ3ZGJjYmZ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LkmWXo9TfelSoHhykWUoovQTO33qdoivLumOvT8UqVFWbbHaEokDtzf5qMy4XCMTEjfPbPilS
oFOFzByxzhRey1WUSaxVdtqVKgaCiiCrnK5pkwMTGX4pUqBTtsYnLjJ4xUrWDGZB1d1z+KVKguWW
3ctzMCb7u1NAIwEky3zsvWlSoIzwuWI/YpgkyI8qxk4wZ/WlSoGNPcbo46Oebs70qVKg/9kNCi0t
MzcxNjM5OTY0MWQ3ZGJjYmZkNGQ0ZjJjY2RjMDZlMzEtLQ0K
MDI4NDdkZjQxMmE3MzBlOTRhMThiYTZiM2Q1ZTMzODEtLQ0K
headers:
Accept:
- '*/*'
@ -1903,7 +1903,7 @@ interactions:
Content-Length:
- '107709'
Content-Type:
- multipart/form-data; boundary=3716399641d7dbcbfd4d4f2ccdc06e31
- multipart/form-data; boundary=02847df412a730e94a18ba6b3d5e3381
User-Agent:
- tests/v311
method: PATCH
@ -1912,26 +1912,26 @@ interactions:
body:
string: '{"id":"113998801242326861","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John
Lennon","locked":true,"bot":false,"discoverable":null,"indexable":false,"group":false,"created_at":"2025-02-13T00:00:00.000Z","note":"\u003cp\u003eI
walk funny\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test","uri":"http://localhost:3000/users/mastodonpy_test","avatar":"http://localhost:3000/system/accounts/avatars/113/998/801/242/326/861/original/2fbdd693e64a250a.jpg","avatar_static":"http://localhost:3000/system/accounts/avatars/113/998/801/242/326/861/original/2fbdd693e64a250a.jpg","header":"http://localhost:3000/system/accounts/headers/113/998/801/242/326/861/original/d2e111d42adab7b8.jpg","header_static":"http://localhost:3000/system/accounts/headers/113/998/801/242/326/861/original/d2e111d42adab7b8.jpg","followers_count":0,"following_count":0,"statuses_count":0,"last_status_at":null,"hide_collections":null,"noindex":false,"source":{"privacy":"private","sensitive":false,"language":null,"note":"I
walk funny\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test","uri":"http://localhost:3000/users/mastodonpy_test","avatar":"http://localhost:3000/system/accounts/avatars/113/998/801/242/326/861/original/d6b3d4cd6b984a05.jpg","avatar_static":"http://localhost:3000/system/accounts/avatars/113/998/801/242/326/861/original/d6b3d4cd6b984a05.jpg","header":"http://localhost:3000/system/accounts/headers/113/998/801/242/326/861/original/eb5eb4f719e4cfbd.jpg","header_static":"http://localhost:3000/system/accounts/headers/113/998/801/242/326/861/original/eb5eb4f719e4cfbd.jpg","followers_count":0,"following_count":1,"statuses_count":5,"last_status_at":"2025-02-13","hide_collections":null,"noindex":false,"source":{"privacy":"private","sensitive":false,"language":null,"note":"I
walk funny","fields":[{"name":"bread","value":"toasty.","verified_at":null},{"name":"lasagna","value":"no!!!","verified_at":null}],"follow_requests_count":0,"hide_collections":null,"discoverable":null,"indexable":false},"emojis":[],"roles":[],"fields":[{"name":"bread","value":"toasty.","verified_at":null},{"name":"lasagna","value":"no!!!","verified_at":null}],"role":{"id":"-99","name":"","permissions":"65536","color":"","highlighted":false}}'
headers:
Cache-Control:
- private, no-store
Content-Length:
- '1474'
- '1482'
Content-Security-Policy:
- default-src 'none'; frame-ancestors 'none'; form-action 'none'
Content-Type:
- application/json; charset=utf-8
ETag:
- W/"be3c2e8d192cc18569b15b1a033a0e40"
- W/"0ca1838b6028b1a93891fcb39204cadc"
Referrer-Policy:
- strict-origin-when-cross-origin
Server-Timing:
- cache_read.active_support;dur=0.04, sql.active_record;dur=19.15, cache_generate.active_support;dur=1.78,
cache_write.active_support;dur=0.10, instantiation.active_record;dur=0.55,
start_processing.action_controller;dur=0.00, transaction.active_record;dur=24.07,
render.active_model_serializers;dur=6.87, process_action.action_controller;dur=177.98
- cache_read.active_support;dur=0.46, sql.active_record;dur=5.93, cache_generate.active_support;dur=2.28,
cache_write.active_support;dur=0.12, instantiation.active_record;dur=0.58,
start_processing.action_controller;dur=0.00, transaction.active_record;dur=32.38,
render.active_model_serializers;dur=5.81, process_action.action_controller;dur=137.24
X-Content-Type-Options:
- nosniff
X-Frame-Options:
@ -1943,11 +1943,139 @@ interactions:
X-RateLimit-Remaining:
- '299'
X-RateLimit-Reset:
- '2025-02-13T21:55:00.419819Z'
- '2025-02-14T21:45:00.276087Z'
X-Request-Id:
- 0cf47d62-9244-4163-9e06-e9df5202a22c
- 37b95eb4-9d4a-40f1-b8c0-928e5da1a47e
X-Runtime:
- '0.196151'
- '0.157442'
X-XSS-Protection:
- '0'
vary:
- Authorization, Origin
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- Bearer __MASTODON_PY_TEST_ACCESS_TOKEN
Connection:
- keep-alive
Content-Length:
- '0'
User-Agent:
- tests/v311
method: DELETE
uri: http://localhost:3000/api/v1/profile/avatar
response:
body:
string: '{"id":"113998801242326861","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John
Lennon","locked":true,"bot":false,"discoverable":null,"indexable":false,"group":false,"created_at":"2025-02-13T00:00:00.000Z","note":"\u003cp\u003eI
walk funny\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test","uri":"http://localhost:3000/users/mastodonpy_test","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/system/accounts/headers/113/998/801/242/326/861/original/eb5eb4f719e4cfbd.jpg","header_static":"http://localhost:3000/system/accounts/headers/113/998/801/242/326/861/original/eb5eb4f719e4cfbd.jpg","followers_count":0,"following_count":1,"statuses_count":5,"last_status_at":"2025-02-13","hide_collections":null,"noindex":false,"source":{"privacy":"private","sensitive":false,"language":null,"note":"I
walk funny","fields":[{"name":"bread","value":"toasty.","verified_at":null},{"name":"lasagna","value":"no!!!","verified_at":null}],"follow_requests_count":0,"hide_collections":null,"discoverable":null,"indexable":false},"emojis":[],"roles":[],"fields":[{"name":"bread","value":"toasty.","verified_at":null},{"name":"lasagna","value":"no!!!","verified_at":null}],"role":{"id":"-99","name":"","permissions":"65536","color":"","highlighted":false}}'
headers:
Cache-Control:
- private, no-store
Content-Length:
- '1384'
Content-Security-Policy:
- default-src 'none'; frame-ancestors 'none'; form-action 'none'
Content-Type:
- application/json; charset=utf-8
ETag:
- W/"a553b843cd56aa5cb857879d326eeb5e"
Referrer-Policy:
- strict-origin-when-cross-origin
Server-Timing:
- cache_read.active_support;dur=0.04, sql.active_record;dur=4.88, cache_generate.active_support;dur=1.68,
cache_write.active_support;dur=0.11, instantiation.active_record;dur=0.47,
start_processing.action_controller;dur=0.01, transaction.active_record;dur=4.42,
render.active_model_serializers;dur=5.77, process_action.action_controller;dur=35.18
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- SAMEORIGIN
X-Permitted-Cross-Domain-Policies:
- none
X-RateLimit-Limit:
- '300'
X-RateLimit-Remaining:
- '299'
X-RateLimit-Reset:
- '2025-02-14T21:45:00.463839Z'
X-Request-Id:
- 6cd1bcd5-25b5-4aa8-9fca-a5542f694800
X-Runtime:
- '0.067245'
X-XSS-Protection:
- '0'
vary:
- Authorization, Origin
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- Bearer __MASTODON_PY_TEST_ACCESS_TOKEN
Connection:
- keep-alive
Content-Length:
- '0'
User-Agent:
- tests/v311
method: DELETE
uri: http://localhost:3000/api/v1/profile/header
response:
body:
string: '{"id":"113998801242326861","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John
Lennon","locked":true,"bot":false,"discoverable":null,"indexable":false,"group":false,"created_at":"2025-02-13T00:00:00.000Z","note":"\u003cp\u003eI
walk funny\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test","uri":"http://localhost:3000/users/mastodonpy_test","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":0,"following_count":1,"statuses_count":5,"last_status_at":"2025-02-13","hide_collections":null,"noindex":false,"source":{"privacy":"private","sensitive":false,"language":null,"note":"I
walk funny","fields":[{"name":"bread","value":"toasty.","verified_at":null},{"name":"lasagna","value":"no!!!","verified_at":null}],"follow_requests_count":0,"hide_collections":null,"discoverable":null,"indexable":false},"emojis":[],"roles":[],"fields":[{"name":"bread","value":"toasty.","verified_at":null},{"name":"lasagna","value":"no!!!","verified_at":null}],"role":{"id":"-99","name":"","permissions":"65536","color":"","highlighted":false}}'
headers:
Cache-Control:
- private, no-store
Content-Length:
- '1286'
Content-Security-Policy:
- default-src 'none'; frame-ancestors 'none'; form-action 'none'
Content-Type:
- application/json; charset=utf-8
ETag:
- W/"6ad3936fb309ffa67d4a8a321d490993"
Referrer-Policy:
- strict-origin-when-cross-origin
Server-Timing:
- cache_read.active_support;dur=0.04, sql.active_record;dur=4.79, cache_generate.active_support;dur=1.59,
cache_write.active_support;dur=0.11, instantiation.active_record;dur=0.53,
start_processing.action_controller;dur=0.01, transaction.active_record;dur=4.23,
render.active_model_serializers;dur=4.30, process_action.action_controller;dur=34.85
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- SAMEORIGIN
X-Permitted-Cross-Domain-Policies:
- none
X-RateLimit-Limit:
- '300'
X-RateLimit-Remaining:
- '299'
X-RateLimit-Reset:
- '2025-02-14T21:45:00.521435Z'
X-Request-Id:
- bb1b06ae-5966-423b-9429-5ec68cf5c3db
X-Runtime:
- '0.053655'
X-XSS-Protection:
- '0'
vary:

Wyświetl plik

@ -142,6 +142,9 @@ def test_account_update_credentials(api):
assert account["fields"][1].name == "lasagna"
assert account["fields"][1].value == "no!!!"
api.account_delete_avatar()
api.account_delete_header()
@pytest.mark.vcr()
def test_account_update_credentials_too_many_fields(api):
with pytest.raises(MastodonAPIError):