Add account notes

pull/257/head
halcy 2022-11-13 14:22:43 +02:00
rodzic adcddefd59
commit 750527416f
5 zmienionych plików z 143 dodań i 25 usunięć

Wyświetl plik

@ -14,7 +14,7 @@ Refer to mastodon changelog and API docs for details when implementing, add or m
3.2.0
-----
* [ ] Add personal notes for accounts
* [x] Add personal notes for accounts
* [x] Add customizable thumbnails for audio and video attachments
* [x] Add color extraction for thumbnails
@ -62,5 +62,5 @@ Refer to mastodon changelog and API docs for details when implementing, add or m
General improvements that would be good to do before doing another release:
* [ ] Split mastodon.py into parts in some way that makes sense, it's getting very unwieldy
* [ ] Fix the CI
* [x] Fix the CI
* [ ] Get test coverage like, real high

Wyświetl plik

@ -493,6 +493,7 @@ Relationship dicts
# logged-in users Timeline
'endorsed': # Boolean denoting wheter the specified user is being endorsed / featured by the
# logged-in user
'note': # A free text note the logged in user has created for this account (not publicly visible)
}
Filter dicts
@ -1176,6 +1177,7 @@ These functions allow you to interact with other accounts: To (un)follow and
.. automethod:: Mastodon.account_pin
.. automethod:: Mastodon.account_unpin
.. automethod:: Mastodon.account_update_credentials
.. automethod:: Mastodon.account_note_set
Writing data: Featured tags
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Wyświetl plik

@ -215,7 +215,7 @@ class Mastodon:
__DICT_VERSION_INSTANCE = bigger_version("3.1.4", __DICT_VERSION_ACCOUNT)
__DICT_VERSION_HASHTAG = "2.3.4"
__DICT_VERSION_EMOJI = "3.0.0"
__DICT_VERSION_RELATIONSHIP = "2.5.0"
__DICT_VERSION_RELATIONSHIP = "3.2.0"
__DICT_VERSION_NOTIFICATION = bigger_version(bigger_version("1.0.0", __DICT_VERSION_ACCOUNT), __DICT_VERSION_STATUS)
__DICT_VERSION_CONTEXT = bigger_version("1.0.0", __DICT_VERSION_STATUS)
__DICT_VERSION_LIST = "2.1.0"
@ -2260,6 +2260,16 @@ class Mastodon:
url = '/api/v1/accounts/{0}/unpin'.format(str(id))
return self.__api_request('POST', url)
def account_note_set(self, id, comment):
"""
Set a note (visible to the logged in user only) for the given account.
returns a `status dict`_ with the `note` updated.
"""
id = self.__unpack_id(id)
params = self.__generate_params(locals(), ["id"])
return self.__api_request('POST', '/api/v1/accounts/{0}/note'.format(str(id)), params)
###
# Writing data: Featured hashtags
###

Wyświetl plik

@ -0,0 +1,123 @@
interactions:
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2
Connection:
- keep-alive
User-Agent:
- tests/v311
method: GET
uri: http://localhost:3000/api/v1/accounts/verify_credentials
response:
body:
string: '{"id":"109336199753389764","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"discoverable":null,"group":false,"created_at":"2022-11-13T00:00:00.000Z","note":"","url":"http://localhost:3000/@admin","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":0,"statuses_count":0,"last_status_at":null,"noindex":false,"source":{"privacy":"public","sensitive":false,"language":null,"note":"","fields":[],"follow_requests_count":0},"emojis":[],"fields":[],"role":{"id":"3","name":"Owner","permissions":"1048575","color":"","highlighted":true}}'
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-TRItETB4W72vy3k5XQZRAA=='';
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/"a576b865af5fce00b4019a62d9c55f75"
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:
- 53684e14-3054-47ec-aa8f-7450b0c38056
X-Runtime:
- '0.025567'
X-XSS-Protection:
- 1; mode=block
status:
code: 200
message: OK
- request:
body: comment=top+ebayer+gerne+wieder
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- Bearer __MASTODON_PY_TEST_ACCESS_TOKEN
Connection:
- keep-alive
Content-Length:
- '31'
Content-Type:
- application/x-www-form-urlencoded
User-Agent:
- tests/v311
method: POST
uri: http://localhost:3000/api/v1/accounts/109336199753389764/note
response:
body:
string: '{"id":"109336199753389764","following":false,"showing_reblogs":false,"notifying":false,"languages":null,"followed_by":false,"blocking":false,"blocked_by":false,"muting":false,"muting_notifications":false,"requested":false,"domain_blocking":false,"endorsed":false,"note":"top
ebayer gerne wieder"}'
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-3t+BKMJ4b8EcyKFsQ7MZOg=='';
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/"c3ead4efc220cb74679970c3bb3bd0cf"
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:
- 91546468-a591-49ad-ac52-f2c5ab510161
X-Runtime:
- '0.037352'
X-XSS-Protection:
- 1; mode=block
status:
code: 200
message: OK
version: 1

Wyświetl plik

@ -233,26 +233,9 @@ def test_suggested_tags(api):
@pytest.mark.vcr()
def test_featured_tags(api):
featured_tag = api.featured_tag_create("ringtones")
"""try:
status = api.status_post("cool free #ringtones")
time.sleep(2)
featured_tag = api.featured_tag_create("ringtones")
assert featured_tag
tag_list = api.featured_tags()
assert featured_tag.name in list(map(lambda x: x.name, tag_list))
api.featured_tag_delete(featured_tag)
tag_list = api.featured_tags()
assert not featured_tag.name in list(map(lambda x: x.name, tag_list))
finally:
api.status_delete(status)"""
@pytest.mark.vcr()
def test_account_notes(api, api2):
relationship = api.account_note_set(api2.account_verify_credentials(), "top ebayer gerne wieder")
assert relationship
assert relationship.note == "top ebayer gerne wieder"