~ihabunek/toot-discuss

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
4 2

[PATCH 0/2] Add TOOT_VISIBILITY for default & boost visibility

Lim Ding Wen <limdingwen@gmail.com>
Details
Message ID
<20221221211236.23436-1-limdingwen@gmail.com>
DKIM signature
missing
Download raw message
This patch introduces the TOOT_VISIBILITY environment variable, which sets the default visibility value. This affects:

- CLI post (can be overriden by switch)
- CLI reblog (ditto)
- TUI post (can be overriden in TUI)
- TUI reblog (no override yet)

Feel free to change to a more modern config thingy. `~/.config/toot/toot.yml` maybe?

Lim Ding Wen (2):
  TOOT_VISIBILITY controls default visibility
  TOOT_VISIBILITY controls boost visibility

 toot/api.py         | 8 ++++----
 toot/commands.py    | 2 +-
 toot/console.py     | 9 +++++++--
 toot/tui/app.py     | 3 ++-
 toot/tui/compose.py | 3 ++-
 5 files changed, 16 insertions(+), 9 deletions(-)

-- 
2.32.1 (Apple Git-133)

[PATCH 1/2] TOOT_VISIBILITY controls default visibility

Lim Ding Wen <limdingwen@gmail.com>
Details
Message ID
<20221221211236.23436-2-limdingwen@gmail.com>
In-Reply-To
<20221221211236.23436-1-limdingwen@gmail.com> (view parent)
DKIM signature
missing
Download raw message
Patch: +3 -2
---
 toot/console.py     | 2 +-
 toot/tui/compose.py | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/toot/console.py b/toot/console.py
index dbb681a..663aab5 100644
--- a/toot/console.py
+++ b/toot/console.py
@@ -348,7 +348,7 @@ POST_COMMANDS = [
            }),
            (["-v", "--visibility"], {
                "type": visibility,
                "default": "public",
                "default": os.getenv("TOOT_VISIBILITY", "public"),
                "help": 'post visibility, one of: %s' % ", ".join(VISIBILITY_CHOICES),
            }),
            (["-s", "--sensitive"], {
diff --git a/toot/tui/compose.py b/toot/tui/compose.py
index 68228b1..4b29958 100644
--- a/toot/tui/compose.py
+++ b/toot/tui/compose.py
@@ -1,5 +1,6 @@
import urwid
import logging
import os

from .constants import VISIBILITY_OPTIONS
from .widgets import Button, EditBox
@@ -30,7 +31,7 @@ class StatusComposer(urwid.Frame):
        self.cw_remove_button = Button("Remove content warning",
            on_press=self.remove_content_warning)

        self.visibility = "public"
        self.visibility = os.getenv("TOOT_VISIBILITY", "public")
        self.visibility_button = Button("Visibility: {}".format(self.visibility),
            on_press=self.choose_visibility)

-- 
2.32.1 (Apple Git-133)

[PATCH 2/2] TOOT_VISIBILITY controls boost visibility

Lim Ding Wen <limdingwen@gmail.com>
Details
Message ID
<20221221211236.23436-3-limdingwen@gmail.com>
In-Reply-To
<20221221211236.23436-1-limdingwen@gmail.com> (view parent)
DKIM signature
missing
Download raw message
Patch: +13 -7
TOOT_VISIBILITY controls default boost visibility from CLI, and the boost visibility from TUI (no option to change in TUI yet)
---
 toot/api.py      | 8 ++++----
 toot/commands.py | 2 +-
 toot/console.py  | 7 ++++++-
 toot/tui/app.py  | 3 ++-
 4 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/toot/api.py b/toot/api.py
index 1ce1ec0..a54de0f 100644
--- a/toot/api.py
+++ b/toot/api.py
@@ -18,10 +18,10 @@ def _account_action(app, user, account, action):
    return http.post(app, user, url).json()


def _status_action(app, user, status_id, action):
def _status_action(app, user, status_id, action, data=None):
    url = '/api/v1/statuses/{}/{}'.format(status_id, action)

    return http.post(app, user, url).json()
    return http.post(app, user, url, data=data).json()


def create_app(domain, scheme='https'):
@@ -187,8 +187,8 @@ def unfavourite(app, user, status_id):
    return _status_action(app, user, status_id, 'unfavourite')


def reblog(app, user, status_id):
    return _status_action(app, user, status_id, 'reblog')
def reblog(app, user, status_id, visibility="public"):
    return _status_action(app, user, status_id, 'reblog', data={"visibility": visibility})


def unreblog(app, user, status_id):
diff --git a/toot/commands.py b/toot/commands.py
index 5cbde45..120c964 100644
--- a/toot/commands.py
+++ b/toot/commands.py
@@ -169,7 +169,7 @@ def unfavourite(app, user, args):


def reblog(app, user, args):
    api.reblog(app, user, args.status_id)
    api.reblog(app, user, args.status_id, visibility=args.visibility)
    print_out("<green>✓ Status reblogged</green>")


diff --git a/toot/console.py b/toot/console.py
index 663aab5..51c1d5e 100644
--- a/toot/console.py
+++ b/toot/console.py
@@ -434,7 +434,12 @@ STATUS_COMMANDS = [
    Command(
        name="reblog",
        description="Reblog a status",
        arguments=[status_id_arg],
        arguments=[status_id_arg,
            (["-v", "--visibility"], {
                "type": visibility,
                "default": os.getenv("TOOT_VISIBILITY", "public"),
                "help": 'boost visibility, one of: %s' % ", ".join(VISIBILITY_CHOICES),
            })],
        require_auth=True,
    ),
    Command(
diff --git a/toot/tui/app.py b/toot/tui/app.py
index 037506e..4293f0c 100644
--- a/toot/tui/app.py
+++ b/toot/tui/app.py
@@ -1,5 +1,6 @@
import logging
import urwid
import os

from concurrent.futures import ThreadPoolExecutor

@@ -484,7 +485,7 @@ class TUI(urwid.Frame):
    def async_toggle_reblog(self, timeline, status):
        def _reblog():
            logger.info("Reblogging {}".format(status))
            api.reblog(self.app, self.user, status.id)
            api.reblog(self.app, self.user, status.id, visibility=os.getenv("TOOT_VISIBILITY", "public"))

        def _unreblog():
            logger.info("Unreblogging {}".format(status))
-- 
2.32.1 (Apple Git-133)
Details
Message ID
<32305250-a294-4c0f-80cf-0a1b1720456c@app.fastmail.com>
In-Reply-To
<20221221211236.23436-1-limdingwen@gmail.com> (view parent)
DKIM signature
missing
Download raw message
Thanks!

-- Ivan
Details
Message ID
<b97fbfa8-a457-4cb6-ad60-fadadb17450c@app.fastmail.com>
In-Reply-To
<32305250-a294-4c0f-80cf-0a1b1720456c@app.fastmail.com> (view parent)
DKIM signature
missing
Download raw message
I changed the name to TOOT_POST_VISIBILITY. In the future I plan to support
overriding any commandline option by settings TOOT_<command>_<option>
variable so this change makes it compatible with future plans.

-- Ivan
Reply to thread Export thread (mbox)