mirror of
https://github.com/ihabunek/toot
synced 2025-02-15 03:20:42 +01:00
Migrate thread command
This commit is contained in:
parent
dc376f67d8
commit
88bd6df85b
10
toot/aapi.py
10
toot/aapi.py
@ -116,3 +116,13 @@ async def post_status(
|
||||
}
|
||||
|
||||
return await request(ctx, "POST", "/api/v1/statuses", json=data, headers=headers)
|
||||
|
||||
|
||||
async def get_status(ctx: Context, status_id) -> Response:
|
||||
url = f"/api/v1/statuses/{status_id}"
|
||||
return await request(ctx, "GET", url)
|
||||
|
||||
|
||||
async def get_status_context(ctx: Context, status_id) -> Response:
|
||||
url = f"/api/v1/statuses/{status_id}/context"
|
||||
return await request(ctx, "GET", url)
|
||||
|
@ -1,4 +1,5 @@
|
||||
|
||||
import asyncio
|
||||
import sys
|
||||
import platform
|
||||
|
||||
@ -68,20 +69,28 @@ def timeline(app, user, args, generator=None):
|
||||
break
|
||||
|
||||
|
||||
def thread(app, user, args):
|
||||
toot = api.single_status(app, user, args.status_id)
|
||||
context = api.context(app, user, args.status_id)
|
||||
thread = []
|
||||
for item in context['ancestors']:
|
||||
thread.append(item)
|
||||
async def thread(ctx: Context, args):
|
||||
if args.json:
|
||||
context_response = await aapi.get_status_context(ctx, args.status_id)
|
||||
print_out(context_response.body)
|
||||
else:
|
||||
status_response, context_response = await asyncio.gather(
|
||||
aapi.get_status(ctx, args.status_id),
|
||||
aapi.get_status_context(ctx, args.status_id),
|
||||
)
|
||||
status = status_response.json
|
||||
context = context_response.json
|
||||
thread = []
|
||||
for item in context["ancestors"]:
|
||||
thread.append(item)
|
||||
|
||||
thread.append(toot)
|
||||
thread.append(status)
|
||||
|
||||
for item in context['descendants']:
|
||||
thread.append(item)
|
||||
for item in context["descendants"]:
|
||||
thread.append(item)
|
||||
|
||||
statuses = [from_dict(Status, s) for s in thread]
|
||||
print_timeline(statuses)
|
||||
statuses = [from_dict(Status, s) for s in thread]
|
||||
print_timeline(statuses)
|
||||
|
||||
|
||||
async def post(ctx, args):
|
||||
|
Loading…
x
Reference in New Issue
Block a user