don't send to banned instances

This commit is contained in:
rimu 2024-08-19 10:24:49 +12:00
parent fea7de022f
commit 8fbf59e189
2 changed files with 2 additions and 3 deletions

View file

@ -1,5 +1,4 @@
from datetime import datetime, timedelta from datetime import datetime, timedelta
from threading import Thread
from time import sleep from time import sleep
from random import randint from random import randint
from typing import List from typing import List
@ -717,7 +716,7 @@ def send_to_remote_instance_task(instance_id: int, community_id: int, payload):
community = Community.query.get(community_id) community = Community.query.get(community_id)
if community: if community:
instance = Instance.query.get(instance_id) instance = Instance.query.get(instance_id)
if instance.inbox and instance.online(): if instance.inbox and instance.online() and not instance_banned(instance.domain):
if post_request(instance.inbox, payload, community.private_key, community.ap_profile_id + '#main-key'): if post_request(instance.inbox, payload, community.private_key, community.ap_profile_id + '#main-key'):
instance.last_successful_send = utcnow() instance.last_successful_send = utcnow()
instance.failures = 0 instance.failures = 0

View file

@ -571,7 +571,7 @@ def user_ip_banned() -> bool:
return current_ip_address in banned_ip_addresses() return current_ip_address in banned_ip_addresses()
@cache.memoize(timeout=30) @cache.memoize(timeout=60)
def instance_banned(domain: str) -> bool: # see also activitypub.util.instance_blocked() def instance_banned(domain: str) -> bool: # see also activitypub.util.instance_blocked()
if domain is None or domain == '': if domain is None or domain == '':
return False return False