mirror of
https://git.pleroma.social/pleroma/relay.git
synced 2024-11-21 22:17:59 +00:00
remove run_in_loop function
This commit is contained in:
parent
c66f9d34b3
commit
70e4870ba9
|
@ -76,7 +76,7 @@ def cli_inbox_follow(actor):
|
||||||
if database.get_inbox(actor):
|
if database.get_inbox(actor):
|
||||||
return click.echo(f'Error: Already following actor: {actor}')
|
return click.echo(f'Error: Already following actor: {actor}')
|
||||||
|
|
||||||
actor_data = run_in_loop(misc.request, actor, sign_headers=True)
|
actor_data = asyncio.run(misc.request(actor, sign_headers=True))
|
||||||
|
|
||||||
if not actor_data:
|
if not actor_data:
|
||||||
return click.echo(f'Error: Failed to fetch actor: {actor}')
|
return click.echo(f'Error: Failed to fetch actor: {actor}')
|
||||||
|
@ -84,7 +84,7 @@ def cli_inbox_follow(actor):
|
||||||
database.add_inbox(actor_data.shared_inbox)
|
database.add_inbox(actor_data.shared_inbox)
|
||||||
database.save()
|
database.save()
|
||||||
|
|
||||||
run_in_loop(misc.follow_remote_actor, actor)
|
asyncio.run(misc.follow_remote_actor(actor))
|
||||||
click.echo(f'Sent follow message to actor: {actor}')
|
click.echo(f'Sent follow message to actor: {actor}')
|
||||||
|
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ def cli_inbox_unfollow(actor):
|
||||||
|
|
||||||
if database.del_inbox(actor):
|
if database.del_inbox(actor):
|
||||||
database.save()
|
database.save()
|
||||||
run_in_loop(misc.unfollow_remote_actor, actor)
|
asyncio.run(misc.unfollow_remote_actor(actor))
|
||||||
return click.echo(f'Sent unfollow message to: {actor}')
|
return click.echo(f'Sent unfollow message to: {actor}')
|
||||||
|
|
||||||
return click.echo(f'Error: Not following actor: {actor}')
|
return click.echo(f'Error: Not following actor: {actor}')
|
||||||
|
@ -236,7 +236,7 @@ def cli_software_ban(name, fetch_nodeinfo):
|
||||||
return click.echo('Banned all relay software')
|
return click.echo('Banned all relay software')
|
||||||
|
|
||||||
if fetch_nodeinfo:
|
if fetch_nodeinfo:
|
||||||
software = run_in_loop(fetch_nodeinfo, name)
|
software = asyncio.run(misc.fetch_nodeinfo(name))
|
||||||
|
|
||||||
if not software:
|
if not software:
|
||||||
click.echo(f'Failed to fetch software name from domain: {name}')
|
click.echo(f'Failed to fetch software name from domain: {name}')
|
||||||
|
@ -268,7 +268,7 @@ def cli_software_unban(name, fetch_nodeinfo):
|
||||||
return click.echo('Unbanned all relay software')
|
return click.echo('Unbanned all relay software')
|
||||||
|
|
||||||
if fetch_nodeinfo:
|
if fetch_nodeinfo:
|
||||||
software = run_in_loop(fetch_nodeinfo, name)
|
software = asyncio.run(misc.fetch_nodeinfo(name))
|
||||||
|
|
||||||
if not software:
|
if not software:
|
||||||
click.echo(f'Failed to fetch software name from domain: {name}')
|
click.echo(f'Failed to fetch software name from domain: {name}')
|
||||||
|
@ -401,11 +401,6 @@ def relay_run():
|
||||||
loop.run_forever()
|
loop.run_forever()
|
||||||
|
|
||||||
|
|
||||||
def run_in_loop(func, *args, **kwargs):
|
|
||||||
loop = asyncio.new_event_loop()
|
|
||||||
return loop.run_until_complete(func(*args, **kwargs))
|
|
||||||
|
|
||||||
|
|
||||||
async def handle_start_webserver():
|
async def handle_start_webserver():
|
||||||
config = app['config']
|
config = app['config']
|
||||||
runner = AppRunner(app, access_log_format='%{X-Forwarded-For}i "%r" %s %b "%{Referer}i" "%{User-Agent}i"')
|
runner = AppRunner(app, access_log_format='%{X-Forwarded-For}i "%r" %s %b "%{Referer}i" "%{User-Agent}i"')
|
||||||
|
|
|
@ -140,6 +140,7 @@ async def fetch_nodeinfo(domain):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
## todo: remove follow_remote_actor and unfollow_remote_actor
|
||||||
async def follow_remote_actor(actor_uri):
|
async def follow_remote_actor(actor_uri):
|
||||||
config = app['config']
|
config = app['config']
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue