Merge branch 'feature/add_force_remove_relay' into 'master'

implement force-remove in manage.py, should only be used when relay is not running

See merge request pleroma/relay!15
This commit is contained in:
kaniini 2019-07-31 19:21:12 +00:00
commit 47e2eb6556
1 changed files with 21 additions and 1 deletions

View File

@ -1,6 +1,9 @@
import asyncio import asyncio
import sys import sys
import simplejson as json
from .actor import follow_remote_actor, unfollow_remote_actor from .actor import follow_remote_actor, unfollow_remote_actor
from . import CONFIG
from .database import DATABASE from .database import DATABASE
@ -34,11 +37,28 @@ def relay_unfollow():
print('Sent unfollow message to:', target) print('Sent unfollow message to:', target)
def relay_forceremove():
if len(sys.argv) < 3:
print('usage: python3 -m relay.manage force-remove <target>')
exit()
target = sys.argv[2]
following = DATABASE.get('relay-list', [])
if target in following:
following.remove(target)
DATABASE['relay-list'] = following
with open('relay.jsonld', 'w') as f:
json.dump(DATABASE, f)
print('Removed target from DB:', target)
TASKS = { TASKS = {
'list': relay_list, 'list': relay_list,
'follow': relay_follow, 'follow': relay_follow,
'unfollow': relay_unfollow 'unfollow': relay_unfollow,
'force-remove': relay_forceremove
} }