forked from indymedia/epicyon
Viewing replies to posts
parent
e04db12604
commit
511a8767a8
28
daemon.py
28
daemon.py
|
@ -883,8 +883,20 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
'totalItems': 0,
|
||||
'type': 'OrderedCollection'}
|
||||
if 'text/html' in self.headers['Accept']:
|
||||
if not self.server.session:
|
||||
if self.server.debug:
|
||||
print('DEBUG: creating new session')
|
||||
self.server.session= \
|
||||
createSession(self.server.domain,self.server.port,self.server.useTor)
|
||||
self._set_headers('text/html',cookie)
|
||||
self.wfile.write(htmlPostReplies(repliesJson).encode('utf-8'))
|
||||
self.wfile.write(htmlPostReplies(self.server.baseDir, \
|
||||
self.server.session, \
|
||||
self.server.webfingerCache, \
|
||||
self.server.personCache, \
|
||||
nickname, \
|
||||
self.server.domain, \
|
||||
self.server.port, \
|
||||
repliesJson).encode('utf-8'))
|
||||
else:
|
||||
self._set_headers('application/json',None)
|
||||
self.wfile.write(json.dumps(repliesJson).encode('utf-8'))
|
||||
|
@ -954,8 +966,20 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
repliesJson['orderedItems'].append(postJsonObject)
|
||||
# send the replies json
|
||||
if 'text/html' in self.headers['Accept']:
|
||||
if not self.server.session:
|
||||
if self.server.debug:
|
||||
print('DEBUG: creating new session')
|
||||
self.server.session= \
|
||||
createSession(self.server.domain,self.server.port,self.server.useTor)
|
||||
self._set_headers('text/html',cookie)
|
||||
self.wfile.write(htmlPostReplies(repliesJson).encode('utf-8'))
|
||||
self.wfile.write(htmlPostReplies(self.server.baseDir, \
|
||||
self.server.session, \
|
||||
self.server.webfingerCache, \
|
||||
self.server.personCache, \
|
||||
nickname, \
|
||||
self.server.domain, \
|
||||
self.server.port, \
|
||||
repliesJson).encode('utf-8'))
|
||||
else:
|
||||
self._set_headers('application/json',None)
|
||||
self.wfile.write(json.dumps(repliesJson).encode('utf-8'))
|
||||
|
|
|
@ -797,15 +797,31 @@ def htmlIndividualPost(baseDir: str,session,wfRequest: {},personCache: {}, \
|
|||
nickname: str,domain: str,port: int,postJsonObject: {}) -> str:
|
||||
"""Show an individual post as html
|
||||
"""
|
||||
return htmlHeader()+ \
|
||||
postStr= \
|
||||
individualPostAsHtml(baseDir,session,wfRequest,personCache, \
|
||||
nickname,domain,port,postJsonObject,None,True,False)+ \
|
||||
htmlFooter()
|
||||
nickname,domain,port,postJsonObject,None,True,False)
|
||||
if postJsonObject.get('object'):
|
||||
if isinstance(postJsonObject['object'], dict):
|
||||
if postJsonObject['object'].get('replies'):
|
||||
repliesJson=postJsonObject['object']['replies']
|
||||
if repliesJson.get('orderedItems'):
|
||||
for item in repliesJson['orderedItems']:
|
||||
postStr+= \
|
||||
individualPostAsHtml(baseDir,session,wfRequest,personCache, \
|
||||
nickname,domain,port,item,None,True,False)
|
||||
return htmlHeader()+postStr+htmlFooter()
|
||||
|
||||
def htmlPostReplies(postJsonObject: {}) -> str:
|
||||
def htmlPostReplies(baseDir: str,session,wfRequest: {},personCache: {}, \
|
||||
nickname: str,domain: str,port: int,repliesJson: {}) -> str:
|
||||
"""Show the replies to an individual post as html
|
||||
"""
|
||||
return htmlHeader()+"<h1>Replies</h1>"+htmlFooter()
|
||||
repliesStr=''
|
||||
if repliesJson.get('orderedItems'):
|
||||
for item in repliesJson['orderedItems']:
|
||||
repliesStr+=individualPostAsHtml(baseDir,session,wfRequest,personCache, \
|
||||
nickname,domain,port,item,None,True,False)
|
||||
|
||||
return htmlHeader()+repliesStr+htmlFooter()
|
||||
|
||||
def htmlFollowConfirm(baseDir: str,originPathStr: str,followActor: str,followProfileUrl: str) -> str:
|
||||
"""Asks to confirm a follow
|
||||
|
|
Loading…
Reference in New Issue