Make account optional in following and followers

pull/427/merge
Ivan Habunek 2023-11-22 08:22:21 +01:00
rodzic 443f9445b1
commit e961bd696d
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: F5F0623FF5EBCB3D
4 zmienionych plików z 21 dodań i 7 usunięć

Wyświetl plik

@ -1,4 +1,4 @@
[flake8]
exclude=build,tests,tmp,venv,toot/tui/scroll.py
ignore=E128,W503
ignore=E128,W503,W504
max-line-length=120

Wyświetl plik

@ -42,6 +42,10 @@ def test_following(app: App, user: User, friend: User, friend_id, run):
out = run("following", user.username)
assert friend.username in out
# If no account is given defaults to logged in user
out = run("following")
assert friend.username in out
out = run("unfollow", friend.username)
assert out == f"✓ You are no longer following {friend.username}"
@ -82,6 +86,11 @@ def test_following_json(app: App, user: User, friend: User, user_id, friend_id,
relationship = from_dict(Relationship, result)
assert relationship.id == friend_id
# If no account is given defaults to logged in user
[result] = run_json("following", user.username, "--json")
relationship = from_dict(Relationship, result)
assert relationship.id == friend_id
[result] = run_json("followers", friend.username, "--json")
assert result["id"] == user_id

Wyświetl plik

@ -436,7 +436,8 @@ def unfollow(app, user, args):
def following(app, user, args):
account = api.find_account(app, user, args.account)
account = args.account or user.username
account = api.find_account(app, user, account)
accounts = api.following(app, user, account["id"])
if args.json:
print(json.dumps(accounts))
@ -445,7 +446,8 @@ def following(app, user, args):
def followers(app, user, args):
account = api.find_account(app, user, args.account)
account = args.account or user.username
account = api.find_account(app, user, account)
accounts = api.followers(app, user, account["id"])
if args.json:
print(json.dumps(accounts))

Wyświetl plik

@ -191,6 +191,7 @@ common_auth_args = [
account_arg = (["account"], {
"help": "account name, e.g. 'Gargron@mastodon.social'",
})
optional_account_arg = (["account"], {
"nargs": "?",
"help": "account name, e.g. 'Gargron@mastodon.social'",
@ -682,14 +683,16 @@ ACCOUNTS_COMMANDS = [
),
Command(
name="following",
description="List accounts followed by the given account",
arguments=[account_arg, json_arg],
description="List accounts followed by the given account, " +
"or your account if no account given",
arguments=[optional_account_arg, json_arg],
require_auth=True,
),
Command(
name="followers",
description="List accounts following the given account",
arguments=[account_arg, json_arg],
description="List accounts following the given account, " +
"or your account if no account given",
arguments=[optional_account_arg, json_arg],
require_auth=True,
),
Command(