diff --git a/CHANGELOG.md b/CHANGELOG.md index 25db14a..9c6932c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/tests/test_console.py b/tests/test_console.py index 2d3ae85..18fa4cf 100644 --- a/tests/test_console.py +++ b/tests/test_console.py @@ -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() diff --git a/toot/api.py b/toot/api.py index f0c8f77..7d31367 100644 --- a/toot/api.py +++ b/toot/api.py @@ -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() diff --git a/toot/commands.py b/toot/commands.py index d80135e..7662be0 100644 --- a/toot/commands.py +++ b/toot/commands.py @@ -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: {}".format(response.get('url'))) diff --git a/toot/console.py b/toot/console.py index 20edce1..8613775 100644 --- a/toot/console.py +++ b/toot/console.py @@ -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,