mirror of https://gitlab.com/bashrc2/epicyon
Less verbose when not in debug
parent
df0179768f
commit
faadca51b6
|
@ -219,7 +219,7 @@ def sendAnnounceViaServer(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
fromDomain, projectVersion)
|
fromDomain, projectVersion, debug)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: announce webfinger failed for ' + handle)
|
print('DEBUG: announce webfinger failed for ' + handle)
|
||||||
|
|
|
@ -105,7 +105,7 @@ def sendAvailabilityViaServer(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
domain, projectVersion)
|
domain, projectVersion, debug)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: announce webfinger failed for ' + handle)
|
print('DEBUG: announce webfinger failed for ' + handle)
|
||||||
|
|
16
daemon.py
16
daemon.py
|
@ -1379,7 +1379,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if GETtimings.get(prevGetId):
|
if GETtimings.get(prevGetId):
|
||||||
timeDiff = int(timeDiff - int(GETtimings[prevGetId]))
|
timeDiff = int(timeDiff - int(GETtimings[prevGetId]))
|
||||||
GETtimings[currGetId] = str(timeDiff)
|
GETtimings[currGetId] = str(timeDiff)
|
||||||
if logEvent:
|
if logEvent and self.server.debug:
|
||||||
print('GET TIMING ' + currGetId + ' = ' + str(timeDiff))
|
print('GET TIMING ' + currGetId + ' = ' + str(timeDiff))
|
||||||
|
|
||||||
def _benchmarkPOSTtimings(self, POSTstartTime, POSTtimings: [],
|
def _benchmarkPOSTtimings(self, POSTstartTime, POSTtimings: [],
|
||||||
|
@ -1397,7 +1397,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if logEvent:
|
if logEvent:
|
||||||
ctr = 1
|
ctr = 1
|
||||||
for timeDiff in POSTtimings:
|
for timeDiff in POSTtimings:
|
||||||
print('POST TIMING|' + str(ctr) + '|' + timeDiff)
|
if self.server.debug:
|
||||||
|
print('POST TIMING|' + str(ctr) + '|' + timeDiff)
|
||||||
ctr += 1
|
ctr += 1
|
||||||
|
|
||||||
def _pathContainsBlogLink(self, baseDir: str,
|
def _pathContainsBlogLink(self, baseDir: str,
|
||||||
|
@ -7351,6 +7352,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.peertubeInstances,
|
self.server.peertubeInstances,
|
||||||
self.server.allowLocalNetworkAccess,
|
self.server.allowLocalNetworkAccess,
|
||||||
self.server.textModeBanner,
|
self.server.textModeBanner,
|
||||||
|
self.server.debug,
|
||||||
actorJson['roles'],
|
actorJson['roles'],
|
||||||
None, None)
|
None, None)
|
||||||
msg = msg.encode('utf-8')
|
msg = msg.encode('utf-8')
|
||||||
|
@ -7439,6 +7441,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.peertubeInstances,
|
self.server.peertubeInstances,
|
||||||
allowLocalNetworkAccess,
|
allowLocalNetworkAccess,
|
||||||
self.server.textModeBanner,
|
self.server.textModeBanner,
|
||||||
|
self.server.debug,
|
||||||
actorJson['skills'],
|
actorJson['skills'],
|
||||||
None, None)
|
None, None)
|
||||||
msg = msg.encode('utf-8')
|
msg = msg.encode('utf-8')
|
||||||
|
@ -9243,6 +9246,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.peertubeInstances,
|
self.server.peertubeInstances,
|
||||||
self.server.allowLocalNetworkAccess,
|
self.server.allowLocalNetworkAccess,
|
||||||
self.server.textModeBanner,
|
self.server.textModeBanner,
|
||||||
|
self.server.debug,
|
||||||
shares,
|
shares,
|
||||||
pageNumber, sharesPerPage)
|
pageNumber, sharesPerPage)
|
||||||
msg = msg.encode('utf-8')
|
msg = msg.encode('utf-8')
|
||||||
|
@ -9341,6 +9345,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.peertubeInstances,
|
self.server.peertubeInstances,
|
||||||
self.server.allowLocalNetworkAccess,
|
self.server.allowLocalNetworkAccess,
|
||||||
self.server.textModeBanner,
|
self.server.textModeBanner,
|
||||||
|
self.server.debug,
|
||||||
following,
|
following,
|
||||||
pageNumber,
|
pageNumber,
|
||||||
followsPerPage).encode('utf-8')
|
followsPerPage).encode('utf-8')
|
||||||
|
@ -9439,6 +9444,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.peertubeInstances,
|
self.server.peertubeInstances,
|
||||||
self.server.allowLocalNetworkAccess,
|
self.server.allowLocalNetworkAccess,
|
||||||
self.server.textModeBanner,
|
self.server.textModeBanner,
|
||||||
|
self.server.debug,
|
||||||
followers,
|
followers,
|
||||||
pageNumber,
|
pageNumber,
|
||||||
followsPerPage).encode('utf-8')
|
followsPerPage).encode('utf-8')
|
||||||
|
@ -9560,6 +9566,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.peertubeInstances,
|
self.server.peertubeInstances,
|
||||||
self.server.allowLocalNetworkAccess,
|
self.server.allowLocalNetworkAccess,
|
||||||
self.server.textModeBanner,
|
self.server.textModeBanner,
|
||||||
|
self.server.debug,
|
||||||
None, None).encode('utf-8')
|
None, None).encode('utf-8')
|
||||||
msglen = len(msg)
|
msglen = len(msg)
|
||||||
self._set_headers('text/html', msglen,
|
self._set_headers('text/html', msglen,
|
||||||
|
@ -13637,7 +13644,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
# check authorization
|
# check authorization
|
||||||
authorized = self._isAuthorized()
|
authorized = self._isAuthorized()
|
||||||
if not authorized:
|
if not authorized and self.server.debug:
|
||||||
print('POST Not authorized')
|
print('POST Not authorized')
|
||||||
print(str(self.headers))
|
print(str(self.headers))
|
||||||
|
|
||||||
|
@ -14236,7 +14243,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
if self.path == '/sharedInbox' or self.path == '/inbox':
|
if self.path == '/sharedInbox' or self.path == '/inbox':
|
||||||
print('DEBUG: POST to shared inbox')
|
if self.server.debug:
|
||||||
|
print('DEBUG: POST to shared inbox')
|
||||||
queueStatus = \
|
queueStatus = \
|
||||||
self._updateInboxQueue('inbox', messageJson, messageBytes)
|
self._updateInboxQueue('inbox', messageJson, messageBytes)
|
||||||
if queueStatus >= 0 and queueStatus <= 3:
|
if queueStatus >= 0 and queueStatus <= 3:
|
||||||
|
|
|
@ -55,7 +55,7 @@ def sendDeleteViaServer(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = \
|
wfRequest = \
|
||||||
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
||||||
fromDomain, projectVersion)
|
fromDomain, projectVersion, debug)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: announce webfinger failed for ' + handle)
|
print('DEBUG: announce webfinger failed for ' + handle)
|
||||||
|
|
|
@ -1477,7 +1477,7 @@ if args.followers:
|
||||||
handle = nickname + '@' + domain
|
handle = nickname + '@' + domain
|
||||||
wfRequest = webfingerHandle(session, handle,
|
wfRequest = webfingerHandle(session, handle,
|
||||||
httpPrefix, cachedWebfingers,
|
httpPrefix, cachedWebfingers,
|
||||||
None, __version__)
|
None, __version__, debug)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
print('Unable to webfinger ' + handle)
|
print('Unable to webfinger ' + handle)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
|
@ -989,7 +989,7 @@ def sendFollowRequestViaServer(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = \
|
wfRequest = \
|
||||||
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
||||||
fromDomain, projectVersion)
|
fromDomain, projectVersion, debug)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: announce webfinger failed for ' + handle)
|
print('DEBUG: announce webfinger failed for ' + handle)
|
||||||
|
@ -1078,7 +1078,7 @@ def sendUnfollowRequestViaServer(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = \
|
wfRequest = \
|
||||||
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
||||||
fromDomain, projectVersion)
|
fromDomain, projectVersion, debug)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: announce webfinger failed for ' + handle)
|
print('DEBUG: announce webfinger failed for ' + handle)
|
||||||
|
|
13
inbox.py
13
inbox.py
|
@ -2702,7 +2702,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
print('Loading queue item ' + queueFilename)
|
if debug:
|
||||||
|
print('Loading queue item ' + queueFilename)
|
||||||
|
|
||||||
# Load the queue json
|
# Load the queue json
|
||||||
queueJson = loadJson(queueFilename, 1)
|
queueJson = loadJson(queueFilename, 1)
|
||||||
|
@ -2829,7 +2830,7 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
if accountMaxPostsPerDay > 0 or domainMaxPostsPerDay > 0:
|
if accountMaxPostsPerDay > 0 or domainMaxPostsPerDay > 0:
|
||||||
pprint(quotasDaily)
|
pprint(quotasDaily)
|
||||||
|
|
||||||
if queueJson.get('actor'):
|
if debug and queueJson.get('actor'):
|
||||||
print('Obtaining public key for actor ' + queueJson['actor'])
|
print('Obtaining public key for actor ' + queueJson['actor'])
|
||||||
|
|
||||||
# Try a few times to obtain the public key
|
# Try a few times to obtain the public key
|
||||||
|
@ -3053,8 +3054,9 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
httpPrefix, domain, port, debug)
|
httpPrefix, domain, port, debug)
|
||||||
if len(recipientsDict.items()) == 0 and \
|
if len(recipientsDict.items()) == 0 and \
|
||||||
len(recipientsDictFollowers.items()) == 0:
|
len(recipientsDictFollowers.items()) == 0:
|
||||||
print('Queue: no recipients were resolved ' +
|
if debug:
|
||||||
'for post arriving in inbox')
|
print('Queue: no recipients were resolved ' +
|
||||||
|
'for post arriving in inbox')
|
||||||
if os.path.isfile(queueFilename):
|
if os.path.isfile(queueFilename):
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
|
@ -3122,8 +3124,7 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
themeName)
|
themeName)
|
||||||
if debug:
|
if debug:
|
||||||
pprint(queueJson['post'])
|
pprint(queueJson['post'])
|
||||||
|
print('Queue: Queue post accepted')
|
||||||
print('Queue: Queue post accepted')
|
|
||||||
if os.path.isfile(queueFilename):
|
if os.path.isfile(queueFilename):
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
|
|
4
like.py
4
like.py
|
@ -167,7 +167,7 @@ def sendLikeViaServer(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
fromDomain, projectVersion)
|
fromDomain, projectVersion, debug)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: announce webfinger failed for ' + handle)
|
print('DEBUG: announce webfinger failed for ' + handle)
|
||||||
|
@ -248,7 +248,7 @@ def sendUndoLikeViaServer(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
fromDomain, projectVersion)
|
fromDomain, projectVersion, debug)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: announce webfinger failed for ' + handle)
|
print('DEBUG: announce webfinger failed for ' + handle)
|
||||||
|
|
|
@ -56,7 +56,7 @@ def _updateMovedHandle(baseDir: str, nickname: str, domain: str,
|
||||||
handle = handle[1:]
|
handle = handle[1:]
|
||||||
wfRequest = webfingerHandle(session, handle,
|
wfRequest = webfingerHandle(session, handle,
|
||||||
httpPrefix, cachedWebfingers,
|
httpPrefix, cachedWebfingers,
|
||||||
None, __version__)
|
None, __version__, debug)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
print('updateMovedHandle unable to webfinger ' + handle)
|
print('updateMovedHandle unable to webfinger ' + handle)
|
||||||
return ctr
|
return ctr
|
||||||
|
|
|
@ -1102,7 +1102,8 @@ def setPersonNotes(baseDir: str, nickname: str, domain: str,
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def getActorJson(handle: str, http: bool, gnunet: bool, quiet=False) -> {}:
|
def getActorJson(handle: str, http: bool, gnunet: bool,
|
||||||
|
debug: bool, quiet=False) -> {}:
|
||||||
"""Returns the actor json
|
"""Returns the actor json
|
||||||
"""
|
"""
|
||||||
originalActor = handle
|
originalActor = handle
|
||||||
|
@ -1175,7 +1176,7 @@ def getActorJson(handle: str, http: bool, gnunet: bool, quiet=False) -> {}:
|
||||||
handle = nickname + '@' + domain
|
handle = nickname + '@' + domain
|
||||||
wfRequest = webfingerHandle(session, handle,
|
wfRequest = webfingerHandle(session, handle,
|
||||||
httpPrefix, cachedWebfingers,
|
httpPrefix, cachedWebfingers,
|
||||||
None, __version__)
|
None, __version__, debug)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print('Unable to webfinger ' + handle)
|
print('Unable to webfinger ' + handle)
|
||||||
|
|
27
posts.py
27
posts.py
|
@ -1935,7 +1935,7 @@ def sendPost(projectVersion: str,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
domain, projectVersion)
|
domain, projectVersion, debug)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
return 1
|
return 1
|
||||||
if not isinstance(wfRequest, dict):
|
if not isinstance(wfRequest, dict):
|
||||||
|
@ -2052,7 +2052,7 @@ def sendPostViaServer(projectVersion: str,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = \
|
wfRequest = \
|
||||||
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
||||||
fromDomain, projectVersion)
|
fromDomain, projectVersion, debug)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: webfinger failed for ' + handle)
|
print('DEBUG: webfinger failed for ' + handle)
|
||||||
|
@ -2249,7 +2249,7 @@ def sendSignedJson(postJsonObject: {}, session, baseDir: str,
|
||||||
|
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
wfRequest = webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
||||||
domain, projectVersion)
|
domain, projectVersion, debug)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: webfinger for ' + handle + ' failed')
|
print('DEBUG: webfinger for ' + handle + ' failed')
|
||||||
|
@ -2538,7 +2538,8 @@ def sendToNamedAddresses(session, baseDir: str,
|
||||||
personCache, debug, projectVersion)
|
personCache, debug, projectVersion)
|
||||||
|
|
||||||
|
|
||||||
def _hasSharedInbox(session, httpPrefix: str, domain: str) -> bool:
|
def _hasSharedInbox(session, httpPrefix: str, domain: str,
|
||||||
|
debug: bool) -> bool:
|
||||||
"""Returns true if the given domain has a shared inbox
|
"""Returns true if the given domain has a shared inbox
|
||||||
This tries the new and the old way of webfingering the shared inbox
|
This tries the new and the old way of webfingering the shared inbox
|
||||||
"""
|
"""
|
||||||
|
@ -2547,9 +2548,8 @@ def _hasSharedInbox(session, httpPrefix: str, domain: str) -> bool:
|
||||||
'inbox@' + domain
|
'inbox@' + domain
|
||||||
]
|
]
|
||||||
for handle in tryHandles:
|
for handle in tryHandles:
|
||||||
wfRequest = webfingerHandle(session, handle,
|
wfRequest = webfingerHandle(session, handle, httpPrefix, {},
|
||||||
httpPrefix, {},
|
None, __version__, debug)
|
||||||
None, __version__)
|
|
||||||
if wfRequest:
|
if wfRequest:
|
||||||
if isinstance(wfRequest, dict):
|
if isinstance(wfRequest, dict):
|
||||||
if not wfRequest.get('errors'):
|
if not wfRequest.get('errors'):
|
||||||
|
@ -2634,7 +2634,8 @@ def sendToFollowers(session, baseDir: str,
|
||||||
print('Sending post to followers domain is active: ' +
|
print('Sending post to followers domain is active: ' +
|
||||||
followerDomainUrl)
|
followerDomainUrl)
|
||||||
|
|
||||||
withSharedInbox = _hasSharedInbox(session, httpPrefix, followerDomain)
|
withSharedInbox = _hasSharedInbox(session, httpPrefix,
|
||||||
|
followerDomain, debug)
|
||||||
if debug:
|
if debug:
|
||||||
if withSharedInbox:
|
if withSharedInbox:
|
||||||
print(followerDomain + ' has shared inbox')
|
print(followerDomain + ' has shared inbox')
|
||||||
|
@ -3463,7 +3464,7 @@ def getPublicPostsOfPerson(baseDir: str, nickname: str, domain: str,
|
||||||
handle = httpPrefix + "://" + domainFull + "/@" + nickname
|
handle = httpPrefix + "://" + domainFull + "/@" + nickname
|
||||||
wfRequest = \
|
wfRequest = \
|
||||||
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
||||||
domain, projectVersion)
|
domain, projectVersion, debug)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
if not isinstance(wfRequest, dict):
|
if not isinstance(wfRequest, dict):
|
||||||
|
@ -3505,7 +3506,7 @@ def getPublicPostDomains(session, baseDir: str, nickname: str, domain: str,
|
||||||
handle = httpPrefix + "://" + domainFull + "/@" + nickname
|
handle = httpPrefix + "://" + domainFull + "/@" + nickname
|
||||||
wfRequest = \
|
wfRequest = \
|
||||||
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
||||||
domain, projectVersion)
|
domain, projectVersion, debug)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
return domainList
|
return domainList
|
||||||
if not isinstance(wfRequest, dict):
|
if not isinstance(wfRequest, dict):
|
||||||
|
@ -3585,7 +3586,7 @@ def getPublicPostInfo(session, baseDir: str, nickname: str, domain: str,
|
||||||
handle = httpPrefix + "://" + domainFull + "/@" + nickname
|
handle = httpPrefix + "://" + domainFull + "/@" + nickname
|
||||||
wfRequest = \
|
wfRequest = \
|
||||||
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
||||||
domain, projectVersion)
|
domain, projectVersion, debug)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
return {}
|
return {}
|
||||||
if not isinstance(wfRequest, dict):
|
if not isinstance(wfRequest, dict):
|
||||||
|
@ -4148,7 +4149,7 @@ def sendBlockViaServer(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
fromDomain, projectVersion)
|
fromDomain, projectVersion, debug)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: announce webfinger failed for ' + handle)
|
print('DEBUG: announce webfinger failed for ' + handle)
|
||||||
|
@ -4232,7 +4233,7 @@ def sendUndoBlockViaServer(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
fromDomain, projectVersion)
|
fromDomain, projectVersion, debug)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: announce webfinger failed for ' + handle)
|
print('DEBUG: announce webfinger failed for ' + handle)
|
||||||
|
|
2
roles.py
2
roles.py
|
@ -310,7 +310,7 @@ def sendRoleViaServer(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
delegatorDomain, projectVersion)
|
delegatorDomain, projectVersion, debug)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: announce webfinger failed for ' + handle)
|
print('DEBUG: announce webfinger failed for ' + handle)
|
||||||
|
|
|
@ -358,7 +358,7 @@ def sendShareViaServer(baseDir, session,
|
||||||
wfRequest = \
|
wfRequest = \
|
||||||
webfingerHandle(session, handle, httpPrefix,
|
webfingerHandle(session, handle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
fromDomain, projectVersion)
|
fromDomain, projectVersion, debug)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: announce webfinger failed for ' + handle)
|
print('DEBUG: announce webfinger failed for ' + handle)
|
||||||
|
@ -457,7 +457,7 @@ def sendUndoShareViaServer(baseDir: str, session,
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest = \
|
wfRequest = \
|
||||||
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
||||||
fromDomain, projectVersion)
|
fromDomain, projectVersion, debug)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: announce webfinger failed for ' + handle)
|
print('DEBUG: announce webfinger failed for ' + handle)
|
||||||
|
|
|
@ -123,7 +123,7 @@ def sendSkillViaServer(baseDir: str, session, nickname: str, password: str,
|
||||||
wfRequest = \
|
wfRequest = \
|
||||||
webfingerHandle(session, handle, httpPrefix,
|
webfingerHandle(session, handle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
domain, projectVersion)
|
domain, projectVersion, debug)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: announce webfinger failed for ' + handle)
|
print('DEBUG: announce webfinger failed for ' + handle)
|
||||||
|
|
|
@ -52,7 +52,7 @@ def instancesGraph(baseDir: str, handles: str,
|
||||||
wfRequest = \
|
wfRequest = \
|
||||||
webfingerHandle(session, handle, httpPrefix,
|
webfingerHandle(session, handle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
domain, projectVersion)
|
domain, projectVersion, debug)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
return dotGraphStr + '}\n'
|
return dotGraphStr + '}\n'
|
||||||
if not isinstance(wfRequest, dict):
|
if not isinstance(wfRequest, dict):
|
||||||
|
|
|
@ -1223,7 +1223,7 @@ def individualPostAsHtml(allowDownloads: bool,
|
||||||
postActorWf = \
|
postActorWf = \
|
||||||
webfingerHandle(session, postActorHandle, httpPrefix,
|
webfingerHandle(session, postActorHandle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
domain, __version__)
|
domain, __version__, False)
|
||||||
|
|
||||||
avatarUrl2 = None
|
avatarUrl2 = None
|
||||||
displayName = None
|
displayName = None
|
||||||
|
|
|
@ -115,7 +115,7 @@ def htmlProfileAfterSearch(cssCache: {},
|
||||||
webfingerHandle(session,
|
webfingerHandle(session,
|
||||||
searchNickname + '@' + searchDomainFull,
|
searchNickname + '@' + searchDomainFull,
|
||||||
httpPrefix, cachedWebfingers,
|
httpPrefix, cachedWebfingers,
|
||||||
domain, projectVersion)
|
domain, projectVersion, debug)
|
||||||
if not wf:
|
if not wf:
|
||||||
print('DEBUG: Unable to webfinger ' +
|
print('DEBUG: Unable to webfinger ' +
|
||||||
searchNickname + '@' + searchDomainFull)
|
searchNickname + '@' + searchDomainFull)
|
||||||
|
@ -481,6 +481,7 @@ def htmlProfile(rssIconAtTop: bool,
|
||||||
peertubeInstances: [],
|
peertubeInstances: [],
|
||||||
allowLocalNetworkAccess: bool,
|
allowLocalNetworkAccess: bool,
|
||||||
textModeBanner: str,
|
textModeBanner: str,
|
||||||
|
debug: bool,
|
||||||
extraJson=None, pageNumber=None,
|
extraJson=None, pageNumber=None,
|
||||||
maxItemsPerPage=None) -> str:
|
maxItemsPerPage=None) -> str:
|
||||||
"""Show the profile page as html
|
"""Show the profile page as html
|
||||||
|
@ -816,7 +817,7 @@ def htmlProfile(rssIconAtTop: bool,
|
||||||
cachedWebfingers, personCache, extraJson,
|
cachedWebfingers, personCache, extraJson,
|
||||||
projectVersion, ["unfollow"], selected,
|
projectVersion, ["unfollow"], selected,
|
||||||
usersPath, pageNumber, maxItemsPerPage,
|
usersPath, pageNumber, maxItemsPerPage,
|
||||||
dormantMonths)
|
dormantMonths, debug)
|
||||||
elif selected == 'followers':
|
elif selected == 'followers':
|
||||||
profileStr += \
|
profileStr += \
|
||||||
_htmlProfileFollowing(translate, baseDir, httpPrefix,
|
_htmlProfileFollowing(translate, baseDir, httpPrefix,
|
||||||
|
@ -825,7 +826,7 @@ def htmlProfile(rssIconAtTop: bool,
|
||||||
cachedWebfingers, personCache, extraJson,
|
cachedWebfingers, personCache, extraJson,
|
||||||
projectVersion, ["block"],
|
projectVersion, ["block"],
|
||||||
selected, usersPath, pageNumber,
|
selected, usersPath, pageNumber,
|
||||||
maxItemsPerPage, dormantMonths)
|
maxItemsPerPage, dormantMonths, debug)
|
||||||
elif selected == 'roles':
|
elif selected == 'roles':
|
||||||
profileStr += \
|
profileStr += \
|
||||||
_htmlProfileRoles(translate, nickname, domainFull,
|
_htmlProfileRoles(translate, nickname, domainFull,
|
||||||
|
@ -920,7 +921,7 @@ def _htmlProfileFollowing(translate: {}, baseDir: str, httpPrefix: str,
|
||||||
feedName: str, actor: str,
|
feedName: str, actor: str,
|
||||||
pageNumber: int,
|
pageNumber: int,
|
||||||
maxItemsPerPage: int,
|
maxItemsPerPage: int,
|
||||||
dormantMonths: int) -> str:
|
dormantMonths: int, debug: bool) -> str:
|
||||||
"""Shows following on the profile screen
|
"""Shows following on the profile screen
|
||||||
"""
|
"""
|
||||||
profileStr = ''
|
profileStr = ''
|
||||||
|
@ -952,7 +953,7 @@ def _htmlProfileFollowing(translate: {}, baseDir: str, httpPrefix: str,
|
||||||
domain, followingActor,
|
domain, followingActor,
|
||||||
authorized, nickname,
|
authorized, nickname,
|
||||||
httpPrefix, projectVersion, dormant,
|
httpPrefix, projectVersion, dormant,
|
||||||
buttons)
|
debug, buttons)
|
||||||
|
|
||||||
if authorized and maxItemsPerPage and pageNumber:
|
if authorized and maxItemsPerPage and pageNumber:
|
||||||
if len(followingJson['orderedItems']) >= maxItemsPerPage:
|
if len(followingJson['orderedItems']) >= maxItemsPerPage:
|
||||||
|
@ -1801,6 +1802,7 @@ def _individualFollowAsHtml(translate: {},
|
||||||
httpPrefix: str,
|
httpPrefix: str,
|
||||||
projectVersion: str,
|
projectVersion: str,
|
||||||
dormant: bool,
|
dormant: bool,
|
||||||
|
debug: bool,
|
||||||
buttons=[]) -> str:
|
buttons=[]) -> str:
|
||||||
"""An individual follow entry on the profile screen
|
"""An individual follow entry on the profile screen
|
||||||
"""
|
"""
|
||||||
|
@ -1817,7 +1819,7 @@ def _individualFollowAsHtml(translate: {},
|
||||||
followUrlWf = \
|
followUrlWf = \
|
||||||
webfingerHandle(session, followUrlHandle, httpPrefix,
|
webfingerHandle(session, followUrlHandle, httpPrefix,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
domain, __version__)
|
domain, __version__, debug)
|
||||||
|
|
||||||
(inboxUrl, pubKeyId, pubKey,
|
(inboxUrl, pubKeyId, pubKey,
|
||||||
fromPersonId, sharedInbox,
|
fromPersonId, sharedInbox,
|
||||||
|
|
20
webfinger.py
20
webfinger.py
|
@ -40,11 +40,13 @@ def _parseHandle(handle: str) -> (str, str):
|
||||||
|
|
||||||
def webfingerHandle(session, handle: str, httpPrefix: str,
|
def webfingerHandle(session, handle: str, httpPrefix: str,
|
||||||
cachedWebfingers: {},
|
cachedWebfingers: {},
|
||||||
fromDomain: str, projectVersion: str) -> {}:
|
fromDomain: str, projectVersion: str,
|
||||||
|
debug: bool) -> {}:
|
||||||
"""Gets webfinger result for the given ActivityPub handle
|
"""Gets webfinger result for the given ActivityPub handle
|
||||||
"""
|
"""
|
||||||
if not session:
|
if not session:
|
||||||
print('WARN: No session specified for webfingerHandle')
|
if debug:
|
||||||
|
print('WARN: No session specified for webfingerHandle')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
nickname, domain = _parseHandle(handle)
|
nickname, domain = _parseHandle(handle)
|
||||||
|
@ -60,7 +62,8 @@ def webfingerHandle(session, handle: str, httpPrefix: str,
|
||||||
wf = getWebfingerFromCache(nickname + '@' + wfDomain,
|
wf = getWebfingerFromCache(nickname + '@' + wfDomain,
|
||||||
cachedWebfingers)
|
cachedWebfingers)
|
||||||
if wf:
|
if wf:
|
||||||
print('Webfinger from cache: ' + str(wf))
|
if debug:
|
||||||
|
print('Webfinger from cache: ' + str(wf))
|
||||||
return wf
|
return wf
|
||||||
url = '{}://{}/.well-known/webfinger'.format(httpPrefix, domain)
|
url = '{}://{}/.well-known/webfinger'.format(httpPrefix, domain)
|
||||||
par = {
|
par = {
|
||||||
|
@ -81,11 +84,12 @@ def webfingerHandle(session, handle: str, httpPrefix: str,
|
||||||
storeWebfingerInCache(nickname + '@' + wfDomain,
|
storeWebfingerInCache(nickname + '@' + wfDomain,
|
||||||
result, cachedWebfingers)
|
result, cachedWebfingers)
|
||||||
else:
|
else:
|
||||||
print("WARN: Unable to webfinger " + url + ' ' +
|
if debug:
|
||||||
'nickname: ' + str(nickname) + ' ' +
|
print("WARN: Unable to webfinger " + url + ' ' +
|
||||||
'domain: ' + str(wfDomain) + ' ' +
|
'nickname: ' + str(nickname) + ' ' +
|
||||||
'headers: ' + str(hdr) + ' ' +
|
'domain: ' + str(wfDomain) + ' ' +
|
||||||
'params: ' + str(par))
|
'headers: ' + str(hdr) + ' ' +
|
||||||
|
'params: ' + str(par))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue