main
Bob Mottram 2020-09-01 11:28:27 +01:00
parent 20f33a580f
commit 0c6aeb67e3
1 changed files with 15 additions and 8 deletions

View File

@ -4895,12 +4895,15 @@ class PubServer(BaseHTTPRequestHandler):
""" """
if not ('/statuses/' in path and '/users/' in path): if not ('/statuses/' in path and '/users/' in path):
return False return False
namedStatus = path.split('/users/')[1] namedStatus = path.split('/users/')[1]
if '/' not in namedStatus: if '/' not in namedStatus:
return False return False
postSections = namedStatus.split('/') postSections = namedStatus.split('/')
if len(postSections) < 4: if len(postSections) < 4:
return False return False
if not postSections[3].startswith('replies'): if not postSections[3].startswith('replies'):
return False return False
nickname = postSections[0] nickname = postSections[0]
@ -4921,15 +4924,19 @@ class PubServer(BaseHTTPRequestHandler):
# so show empty collection # so show empty collection
contextStr = \ contextStr = \
'https://www.w3.org/ns/activitystreams' 'https://www.w3.org/ns/activitystreams'
firstStr = \ firstStr = \
httpPrefix + '://' + domainFull + '/users/' + nickname + \ httpPrefix + '://' + domainFull + '/users/' + nickname + \
'/statuses/' + statusNumber + '/replies?page=true' '/statuses/' + statusNumber + '/replies?page=true'
idStr = \ idStr = \
httpPrefix + '://' + domainFull + '/users/' + nickname + \ httpPrefix + '://' + domainFull + '/users/' + nickname + \
'/statuses/' + statusNumber + '/replies' '/statuses/' + statusNumber + '/replies'
lastStr = \ lastStr = \
httpPrefix + '://' + domainFull + '/users/' + nickname + \ httpPrefix + '://' + domainFull + '/users/' + nickname + \
'/statuses/' + statusNumber + '/replies?page=true' '/statuses/' + statusNumber + '/replies?page=true'
repliesJson = { repliesJson = {
'@context': contextStr, '@context': contextStr,
'first': firstStr, 'first': firstStr,
@ -4938,6 +4945,7 @@ class PubServer(BaseHTTPRequestHandler):
'totalItems': 0, 'totalItems': 0,
'type': 'OrderedCollection' 'type': 'OrderedCollection'
} }
if self._requestHTTP(): if self._requestHTTP():
if not self.server.session: if not self.server.session:
print('DEBUG: creating new session during get replies') print('DEBUG: creating new session during get replies')
@ -4991,13 +4999,16 @@ class PubServer(BaseHTTPRequestHandler):
# replies exist. Itterate through the # replies exist. Itterate through the
# text file containing message ids # text file containing message ids
contextStr = 'https://www.w3.org/ns/activitystreams' contextStr = 'https://www.w3.org/ns/activitystreams'
idStr = \ idStr = \
httpPrefix + '://' + domainFull + \ httpPrefix + '://' + domainFull + \
'/users/' + nickname + '/statuses/' + \ '/users/' + nickname + '/statuses/' + \
statusNumber + '?page=true' statusNumber + '?page=true'
partOfStr = \ partOfStr = \
httpPrefix + '://' + domainFull + \ httpPrefix + '://' + domainFull + \
'/users/' + nickname + '/statuses/' + statusNumber '/users/' + nickname + '/statuses/' + statusNumber
repliesJson = { repliesJson = {
'@context': contextStr, '@context': contextStr,
'id': idStr, 'id': idStr,
@ -5008,12 +5019,9 @@ class PubServer(BaseHTTPRequestHandler):
} }
# populate the items list with replies # populate the items list with replies
populateRepliesJson(baseDir, populateRepliesJson(baseDir, nickname, domain,
nickname,
domain,
postRepliesFilename, postRepliesFilename,
authorized, authorized, repliesJson)
repliesJson)
# send the replies json # send the replies json
if self._requestHTTP(): if self._requestHTTP():
@ -5061,8 +5069,7 @@ class PubServer(BaseHTTPRequestHandler):
'post replies done') 'post replies done')
else: else:
if self._fetchAuthenticated(): if self._fetchAuthenticated():
msg = \ msg = json.dumps(repliesJson,
json.dumps(repliesJson,
ensure_ascii=False) ensure_ascii=False)
msg = msg.encode('utf-8') msg = msg.encode('utf-8')
protocolStr = 'application/json' protocolStr = 'application/json'