mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-11-18 17:47:54 +01:00
fixes for inactive follows/ empty list postprocessing
for
This commit is contained in:
@@ -108,14 +108,14 @@ class DiscoverInactiveFollows(DVMTaskInterface):
|
|||||||
|
|
||||||
keys = Keys.from_sk_str(self.dvm_config.PRIVATE_KEY)
|
keys = Keys.from_sk_str(self.dvm_config.PRIVATE_KEY)
|
||||||
opts = Options().wait_for_send(True).send_timeout(
|
opts = Options().wait_for_send(True).send_timeout(
|
||||||
timedelta(seconds=10)).skip_disconnected_relays(False)
|
timedelta(seconds=5)).skip_disconnected_relays(True)
|
||||||
cli = Client.with_opts(keys, opts)
|
cli = Client.with_opts(keys, opts)
|
||||||
for relay in self.dvm_config.RELAY_LIST:
|
for relay in self.dvm_config.RELAY_LIST:
|
||||||
cli.add_relay(relay)
|
cli.add_relay(relay)
|
||||||
cli.connect()
|
cli.connect()
|
||||||
|
|
||||||
filters = []
|
filters = []
|
||||||
for i in range(i + st):
|
for i in range(i, i + st):
|
||||||
filter1 = Filter().author(PublicKey.from_hex(users[i])).since(notactivesince).limit(1)
|
filter1 = Filter().author(PublicKey.from_hex(users[i])).since(notactivesince).limit(1)
|
||||||
filters.append(filter1)
|
filters.append(filter1)
|
||||||
event_from_authors = cli.get_events_of(filters, timedelta(seconds=10))
|
event_from_authors = cli.get_events_of(filters, timedelta(seconds=10))
|
||||||
@@ -131,7 +131,7 @@ class DiscoverInactiveFollows(DVMTaskInterface):
|
|||||||
args = [followings, ns, begin, step, not_active_since]
|
args = [followings, ns, begin, step, not_active_since]
|
||||||
t = Thread(target=scanList, args=args)
|
t = Thread(target=scanList, args=args)
|
||||||
threads.append(t)
|
threads.append(t)
|
||||||
begin = begin + step
|
begin = begin + step -1
|
||||||
|
|
||||||
# last to step size
|
# last to step size
|
||||||
missing_scans = (len(followings) - begin)
|
missing_scans = (len(followings) - begin)
|
||||||
@@ -149,9 +149,6 @@ class DiscoverInactiveFollows(DVMTaskInterface):
|
|||||||
|
|
||||||
result = {k for (k, v) in ns.dic.items() if v == "False"}
|
result = {k for (k, v) in ns.dic.items() if v == "False"}
|
||||||
|
|
||||||
if len(result) == 0:
|
|
||||||
print("Not found")
|
|
||||||
return "No inactive followers found on relays."
|
|
||||||
print("Inactive accounts found: " + str(len(result)))
|
print("Inactive accounts found: " + str(len(result)))
|
||||||
for k in result:
|
for k in result:
|
||||||
p_tag = Tag.parse(["p", k])
|
p_tag = Tag.parse(["p", k])
|
||||||
|
|||||||
@@ -97,6 +97,8 @@ def post_process_result(anno, original_event):
|
|||||||
def post_process_list_to_events(result):
|
def post_process_list_to_events(result):
|
||||||
result_list = json.loads(result)
|
result_list = json.loads(result)
|
||||||
result_str = ""
|
result_str = ""
|
||||||
|
if len(result_list) == 0:
|
||||||
|
return "No results found"
|
||||||
for tag in result_list:
|
for tag in result_list:
|
||||||
e_tag = Tag.parse(tag)
|
e_tag = Tag.parse(tag)
|
||||||
result_str = result_str + "nostr:" + EventId.from_hex(
|
result_str = result_str + "nostr:" + EventId.from_hex(
|
||||||
@@ -107,6 +109,8 @@ def post_process_list_to_events(result):
|
|||||||
def post_process_list_to_users(result):
|
def post_process_list_to_users(result):
|
||||||
result_list = json.loads(result)
|
result_list = json.loads(result)
|
||||||
result_str = ""
|
result_str = ""
|
||||||
|
if len(result_list) == 0:
|
||||||
|
return "No results found"
|
||||||
for tag in result_list:
|
for tag in result_list:
|
||||||
p_tag = Tag.parse(tag)
|
p_tag = Tag.parse(tag)
|
||||||
result_str = result_str + "nostr:" + PublicKey.from_hex(
|
result_str = result_str + "nostr:" + PublicKey.from_hex(
|
||||||
|
|||||||
Reference in New Issue
Block a user