Randomize the sequence of instances a post is sent out to

merge-requests/30/head
Bob Mottram 2022-04-23 11:05:51 +01:00
parent 7ccbd54b01
commit cb1cd531eb
1 changed files with 10 additions and 1 deletions

View File

@ -3307,12 +3307,21 @@ def send_to_followers(server, session, session_onion, session_i2p,
elif domain.endswith('.i2p'): elif domain.endswith('.i2p'):
curr_proxy_type = 'i2p' curr_proxy_type = 'i2p'
# for each instance
sending_start_time = datetime.datetime.utcnow() sending_start_time = datetime.datetime.utcnow()
print('Sending post to followers begins ' + print('Sending post to followers begins ' +
sending_start_time.strftime("%Y-%m-%dT%H:%M:%SZ")) sending_start_time.strftime("%Y-%m-%dT%H:%M:%SZ"))
sending_ctr = 0 sending_ctr = 0
# randomize the order of sending to instances
randomized_instances = []
for follower_domain, follower_handles in grouped.items(): for follower_domain, follower_handles in grouped.items():
randomized_instances.append([follower_domain, follower_handles])
random.shuffle(randomized_instances)
# send out to each instance
for group_send in randomized_instances:
follower_domain = group_send[0]
follower_handles = group_send[1]
print('Sending post to followers progress ' + print('Sending post to followers progress ' +
str(int(sending_ctr * 100 / len(grouped.items()))) + '% ' + str(int(sending_ctr * 100 / len(grouped.items()))) + '% ' +
follower_domain) follower_domain)