From 976ee3a89de77bfb3f4ebccd1cd188f88cb9eb93 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 23 Jun 2020 10:46:38 +0100 Subject: [PATCH] Check that follower domains are active before sending to them --- posts.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/posts.py b/posts.py index 4ef32512..b56777f7 100644 --- a/posts.py +++ b/posts.py @@ -27,6 +27,7 @@ from session import postJsonString from session import postImage from webfinger import webfingerHandle from httpsig import createSignedHeader +from utils import siteIsActive from utils import removePostFromCache from utils import getCachedPostFilename from utils import getStatusNumber @@ -1665,7 +1666,11 @@ def sendSignedJson(postJsonObject: {}, session, baseDir: str, if ':' not in toDomain: toDomain = toDomain + ':' + str(toPort) - handleBase = httpPrefix + '://' + toDomain + '/@' + toDomainUrl = httpPrefix + '://' + toDomain + if not siteIsActive(toDomainUrl): + print('Domain is inactive: ' + toDomainUrl) + return 9 + handleBase = toDomainUrl + '/@' if toNickname: handle = handleBase + toNickname else: @@ -2025,6 +2030,14 @@ def sendToFollowers(session, baseDir: str, if debug: print('DEBUG: follower handles for ' + followerDomain) pprint(followerHandles) + + # check that the follower's domain is active + followerDomainUrl = httpPrefix + '://' + followerDomain + if not siteIsActive(followerDomainUrl): + print('Domain is inactive: ' + followerDomainUrl) + continue + print('Domain is active: ' + followerDomainUrl) + withSharedInbox = hasSharedInbox(session, httpPrefix, followerDomain) if debug: if withSharedInbox: