From 06d9d4c19e6ffe30dc049f9a9dba0c851a2057a3 Mon Sep 17 00:00:00 2001 From: gled Date: Tue, 11 Jun 2019 10:48:49 -0700 Subject: [PATCH] implement force-remove in manage.py, should only be used when relay is not running --- relay/manage.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/relay/manage.py b/relay/manage.py index 542a008..4912fb1 100644 --- a/relay/manage.py +++ b/relay/manage.py @@ -1,6 +1,9 @@ import asyncio import sys +import simplejson as json + from .actor import follow_remote_actor, unfollow_remote_actor +from . import CONFIG from .database import DATABASE @@ -34,11 +37,28 @@ def relay_unfollow(): print('Sent unfollow message to:', target) +def relay_forceremove(): + if len(sys.argv) < 3: + print('usage: python3 -m relay.manage force-remove ') + 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 = { 'list': relay_list, 'follow': relay_follow, - 'unfollow': relay_unfollow + 'unfollow': relay_unfollow, + 'force-remove': relay_forceremove }