From 29fa14bc987b7dda810728ef9a80fd57dd94904f Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Fri, 29 Jul 2022 22:41:53 +0100 Subject: [PATCH] Implement adding the next relay --- core/lib/manage/threshold.py | 5 ++++- core/lib/opensearch.py | 21 ++++++++++--------- .../manage/threshold/irc/network/actions.html | 3 ++- core/views/manage/threshold/irc.py | 21 +++++++++---------- 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/core/lib/manage/threshold.py b/core/lib/manage/threshold.py index 74872e3..0e987ab 100644 --- a/core/lib/manage/threshold.py +++ b/core/lib/manage/threshold.py @@ -90,7 +90,10 @@ def get_aliases(): def add_relay(net, num): - url = f"irc/network/{net}/{num}" + if num: + url = f"irc/network/{net}/{num}" + else: + url = f"irc/network/{net}" payload = {} created = threshold_request(url, payload, method="PUT") return created diff --git a/core/lib/opensearch.py b/core/lib/opensearch.py index a5f714e..6a079c5 100644 --- a/core/lib/opensearch.py +++ b/core/lib/opensearch.py @@ -58,16 +58,17 @@ def annotate_results(results_parsed): # Annotate the number channels the user is on num_chans = annotate_num_chans(net, nicks) for item in results_parsed: - if item["net"] == net: - if "nick" in item: - if item["nick"] in online_info: - item["online"] = online_info[item["nick"]] - if "channel" in item: - if item["channel"] in num_users: - item["num_users"] = num_users[item["channel"]] - if "nick" in item: - if item["nick"] in num_chans: - item["num_chans"] = num_chans[item["nick"]] + if "net" in item: + if item["net"] == net: + if "nick" in item: + if item["nick"] in online_info: + item["online"] = online_info[item["nick"]] + if "channel" in item: + if item["channel"] in num_users: + item["num_users"] = num_users[item["channel"]] + if "nick" in item: + if item["nick"] in num_chans: + item["num_chans"] = num_chans[item["nick"]] def filter_blacklisted(user, response): diff --git a/core/templates/manage/threshold/irc/network/actions.html b/core/templates/manage/threshold/irc/network/actions.html index b3b0253..b0d725b 100644 --- a/core/templates/manage/threshold/irc/network/actions.html +++ b/core/templates/manage/threshold/irc/network/actions.html @@ -7,8 +7,9 @@