Add spoiler text and sensitive options to post

issue #63
pull/65/head
Ivan Habunek 2018-06-07 10:04:50 +02:00
rodzic 9f23ba4d55
commit fa4e4e6357
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: CDBD63C43A30BB95
5 zmienionych plików z 31 dodań i 5 usunięć

Wyświetl plik

@ -1,12 +1,16 @@
Changelog
---------
**0.17.1 (2017-01-15)**
**0.18.0 (TBA)**
* Add `--sensitive` and `--spoiler-text` options to `toot post` (#63)
**0.17.1 (2018-01-15)**
* Create config folder if it does not exist (#40)
* Fix packaging to include `toot.ui` package (#41)
**0.17.0 (2017-01-15)**
**0.17.0 (2018-01-15)**
* Changed configuration file format to allow switching between multiple logged
in accounts (#32)

Wyświetl plik

@ -37,6 +37,8 @@ def test_post_defaults(mock_post, capsys):
'status': 'Hello world',
'visibility': 'public',
'media_ids[]': None,
'sensitive': False,
'spoiler_text': None,
})
out, err = capsys.readouterr()
@ -47,7 +49,7 @@ def test_post_defaults(mock_post, capsys):
@mock.patch('toot.http.post')
def test_post_with_options(mock_post, capsys):
args = ['Hello world', '--visibility', 'unlisted']
args = ['Hello world', '--visibility', 'unlisted', '--sensitive', '--spoiler-text', 'Spoiler!']
mock_post.return_value = MockResponse({
'url': 'https://habunek.com/@ihabunek/1234567890'
@ -59,6 +61,8 @@ def test_post_with_options(mock_post, capsys):
'status': 'Hello world',
'media_ids[]': None,
'visibility': 'unlisted',
'sensitive': True,
'spoiler_text': "Spoiler!",
})
out, err = capsys.readouterr()

Wyświetl plik

@ -76,11 +76,14 @@ def request_access_token(app, authorization_code):
return http.process_response(response).json()
def post_status(app, user, status, visibility='public', media_ids=None):
def post_status(app, user, status, visibility='public', media_ids=None,
sensitive=False, spoiler_text=None):
return http.post(app, user, '/api/v1/statuses', {
'status': status,
'media_ids[]': media_ids,
'visibility': visibility,
'sensitive': sensitive,
'spoiler_text': spoiler_text,
}).json()

Wyświetl plik

@ -92,7 +92,13 @@ def post(app, user, args):
if not args.text:
raise ConsoleError("You must specify either text or media to post.")
response = api.post_status(app, user, args.text, args.visibility, media_ids)
response = api.post_status(
app, user, args.text,
visibility=args.visibility,
media_ids=media_ids,
sensitive=args.sensitive,
spoiler_text=args.spoiler_text,
)
print_out("Toot posted: <green>{}</green>".format(response.get('url')))

Wyświetl plik

@ -170,6 +170,15 @@ POST_COMMANDS = [
"type": visibility,
"default": "public",
"help": 'post visibility, one of: %s' % ", ".join(VISIBILITY_CHOICES),
}),
(["-s", "--sensitive"], {
"action": 'store_true',
"default": False,
"help": "mark the media as NSFW",
}),
(["-p", "--spoiler-text"], {
"type": str,
"help": 'text to be shown as a warning before the actual content',
})
],
require_auth=True,