mirror of
https://git.pleroma.social/pleroma/relay.git
synced 2024-11-21 22:17:59 +00:00
fix actor unfollowing and simplify (un)following
This commit is contained in:
parent
169c7af822
commit
c24a0ce6d5
|
@ -65,7 +65,20 @@ def cli_inbox_list():
|
|||
def cli_inbox_follow(actor):
|
||||
'Follow an actor (Relay must be running)'
|
||||
|
||||
run_in_loop(handle_follow_actor, actor)
|
||||
config = app['config']
|
||||
database = app['database']
|
||||
|
||||
if config.is_banned(actor):
|
||||
return click.echo(f'Error: Refusing to follow banned actor: {actor}')
|
||||
|
||||
if not actor.startswith('http'):
|
||||
actor = f'https://{actor}/actor'
|
||||
|
||||
if database.get_inbox(actor):
|
||||
return click.echo(f'Error: Already following actor: {actor}')
|
||||
|
||||
run_in_loop(follow_remote_actor, actor)
|
||||
click.echo(f'Sent follow message to: {actor}')
|
||||
|
||||
|
||||
@cli_inbox.command('unfollow')
|
||||
|
@ -73,7 +86,16 @@ def cli_inbox_follow(actor):
|
|||
def cli_inbox_unfollow(actor):
|
||||
'Unfollow an actor (Relay must be running)'
|
||||
|
||||
run_in_loop(handle_unfollow_actor(actor))
|
||||
database = app['database']
|
||||
|
||||
if not actor.startswith('http'):
|
||||
actor = f'https://{actor}/actor'
|
||||
|
||||
if not database.get_inbox(actor):
|
||||
return click.echo(f'Error: Not following actor: {actor}')
|
||||
|
||||
run_in_loop(unfollow_remote_actor, actor)
|
||||
click.echo(f'Sent unfollow message to: {actor}')
|
||||
|
||||
|
||||
@cli_inbox.command('add')
|
||||
|
@ -376,32 +398,6 @@ def run_in_loop(func, *args, **kwargs):
|
|||
return loop.run_until_complete(func(*args, **kwargs))
|
||||
|
||||
|
||||
async def handle_follow_actor(app, target):
|
||||
config = app['config']
|
||||
|
||||
if not target.startswith('http'):
|
||||
target = f'https://{target}/actor'
|
||||
|
||||
if config.is_banned(target):
|
||||
return click.echo(f'Error: Refusing to follow banned actor: {target}')
|
||||
|
||||
await follow_remote_actor(target)
|
||||
click.echo(f'Sent follow message to: {target}')
|
||||
|
||||
|
||||
async def handle_unfollow_actor(app, target):
|
||||
database = app['database']
|
||||
|
||||
if not target.startswith('http'):
|
||||
target = f'https://{target}/actor'
|
||||
|
||||
if not database.get_inbox(target):
|
||||
return click.echo(f'Error: Not following actor: {target}')
|
||||
|
||||
await unfollow_remote_actor(target)
|
||||
click.echo(f'Sent unfollow message to: {target}')
|
||||
|
||||
|
||||
async def handle_start_webserver():
|
||||
config = app['config']
|
||||
runner = AppRunner(app, access_log_format='%{X-Forwarded-For}i "%r" %s %b "%{Referer}i" "%{User-Agent}i"')
|
||||
|
|
Loading…
Reference in a new issue