From f5330c76827d1f625304f694391d0b9ffae330ac Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 21 Jan 2021 18:12:15 +0000 Subject: [PATCH] Tidying --- daemon.py | 28 ---------------------------- posts.py | 8 ++++---- 2 files changed, 4 insertions(+), 32 deletions(-) diff --git a/daemon.py b/daemon.py index 7ccfc6c46..3e2486b0a 100644 --- a/daemon.py +++ b/daemon.py @@ -65,7 +65,6 @@ from person import removeAccount from person import canRemovePost from person import personSnooze from person import personUnsnooze -from posts import getPersonKey from posts import isModerator from posts import mutePost from posts import unmutePost @@ -590,33 +589,6 @@ class PubServer(BaseHTTPRequestHandler): self.send_header('ETag', etag) self.end_headers() - def _set_headers_with_sig(self, fileFormat: str, length: int, - baseDir: str, path: str, - domain: str, domainFull: str, port: int, - httpPrefix: str, - callingDomain: str, debug: bool, - jsonStr: str) -> None: - self._set_headers_base(fileFormat, length, None, callingDomain) - nickname = path.split('/users/')[1] - if '/' in nickname: - nickname = nickname.split('/')[0] - privateKeyPem = \ - getPersonKey(nickname, domain, baseDir, 'private', debug) - if len(privateKeyPem) > 0: - boxPath = '/inbox' - signatureHeaderJson = \ - createSignedHeader(privateKeyPem, nickname, - domain, port, - callingDomain, port, - boxPath, - httpPrefix, True, jsonStr) - print('@ detected signatureHeaderJson: ' + str(signatureHeaderJson)) - for headerName, headerItem in signatureHeaderJson.items(): - self.send_header(headerName, headerItem) - self.send_header('User-Agent', 'Epicyon/' + __version__ + - '; +' + httpPrefix + '://' + domainFull + '/') - self.end_headers() - def _set_headers_etag(self, mediaFilename: str, fileFormat: str, data, cookie: str, callingDomain: str) -> None: datalen = len(data) diff --git a/posts.py b/posts.py index 65299a2be..6c22f1ca5 100644 --- a/posts.py +++ b/posts.py @@ -118,8 +118,8 @@ def noOfFollowersOnDomain(baseDir: str, handle: str, return ctr -def getPersonKey(nickname: str, domain: str, baseDir: str, keyType='public', - debug=False): +def _getPersonKey(nickname: str, domain: str, baseDir: str, keyType='public', + debug=False): """Returns the public or private key of a person """ handle = nickname + '@' + domain @@ -1837,7 +1837,7 @@ def sendPost(projectVersion: str, None, None, None, None, None) # get the senders private key - privateKeyPem = getPersonKey(nickname, domain, baseDir, 'private') + privateKeyPem = _getPersonKey(nickname, domain, baseDir, 'private') if len(privateKeyPem) == 0: return 6 @@ -2159,7 +2159,7 @@ def sendSignedJson(postJsonObject: {}, session, baseDir: str, # sharedInbox is optional # get the senders private key - privateKeyPem = getPersonKey(nickname, domain, baseDir, 'private', debug) + privateKeyPem = _getPersonKey(nickname, domain, baseDir, 'private', debug) if len(privateKeyPem) == 0: if debug: print('DEBUG: Private key not found for ' +