Only show public posts on the profile

master
Bob Mottram 2019-09-02 12:59:15 +01:00
parent 3d6a823da8
commit 2c30f76ce8
1 changed files with 30 additions and 10 deletions

View File

@ -276,7 +276,7 @@ def htmlHashtagSearch(baseDir: str,hashtag: str,pageNumber: int,postsPerPage: in
nickname,domain,port,postJsonObject, \ nickname,domain,port,postJsonObject, \
None,True,False, \ None,True,False, \
httpPrefix,projectVersion, \ httpPrefix,projectVersion, \
False,False,False) False,False,False,False)
index-=1 index-=1
if endIndex>0: if endIndex>0:
@ -858,6 +858,7 @@ def htmlProfilePosts(baseDir: str,httpPrefix: str, \
session,wfRequest: {},personCache: {}, \ session,wfRequest: {},personCache: {}, \
projectVersion: str) -> str: projectVersion: str) -> str:
"""Shows posts on the profile screen """Shows posts on the profile screen
These should only be public posts
""" """
profileStr='' profileStr=''
outboxFeed= \ outboxFeed= \
@ -874,7 +875,7 @@ def htmlProfilePosts(baseDir: str,httpPrefix: str, \
individualPostAsHtml(baseDir,session,wfRequest,personCache, \ individualPostAsHtml(baseDir,session,wfRequest,personCache, \
nickname,domain,port,item,None,True,False, \ nickname,domain,port,item,None,True,False, \
httpPrefix,projectVersion, \ httpPrefix,projectVersion, \
False,False,False) False,False,False,True)
return profileStr return profileStr
def htmlProfileFollowing(baseDir: str,httpPrefix: str, \ def htmlProfileFollowing(baseDir: str,httpPrefix: str, \
@ -1325,7 +1326,8 @@ def individualPostAsHtml(baseDir: str, \
httpPrefix: str, projectVersion: str, \ httpPrefix: str, projectVersion: str, \
showRepeats=True, \ showRepeats=True, \
showIcons=False, \ showIcons=False, \
manuallyApprovesFollowers=False) -> str: manuallyApprovesFollowers=False, \
showPublicOnly=False) -> str:
""" Shows a single post as html """ Shows a single post as html
""" """
# If this is the inbox timeline then don't show the repeat icon on any DMs # If this is the inbox timeline then don't show the repeat icon on any DMs
@ -1386,6 +1388,24 @@ def individualPostAsHtml(baseDir: str, \
return '' return ''
if not isinstance(postJsonObject['object'], dict): if not isinstance(postJsonObject['object'], dict):
return '' return ''
# if this post should be public then check its recipients
if showPublicOnly:
if postJsonObject['object'].get('to'):
containsPublic=False
for toAddress in postJsonObject['object']['to']:
if toAddress.endswith('#Public'):
containsPublic=True
break
if not containsPublic:
if postJsonObject['object'].get('cc'):
for toAddress in postJsonObject['object']['cc']:
if toAddress.endswith('#Public'):
containsPublic=True
break
if not containsPublic:
return ''
isModerationPost=False isModerationPost=False
if postJsonObject['object'].get('moderationStatus'): if postJsonObject['object'].get('moderationStatus'):
isModerationPost=True isModerationPost=True
@ -1757,7 +1777,7 @@ def htmlTimeline(pageNumber: int,itemsPerPage: int,session,baseDir: str, \
httpPrefix,projectVersion, \ httpPrefix,projectVersion, \
boxName!='dm', \ boxName!='dm', \
showIndividualPostIcons, \ showIndividualPostIcons, \
manuallyApproveFollowers) manuallyApproveFollowers,False)
# page down arrow # page down arrow
if itemCtr>=itemsPerPage: if itemCtr>=itemsPerPage:
@ -1823,7 +1843,7 @@ def htmlIndividualPost(baseDir: str,session,wfRequest: {},personCache: {}, \
postStr+= \ postStr+= \
individualPostAsHtml(baseDir,session,wfRequest,personCache, \ individualPostAsHtml(baseDir,session,wfRequest,personCache, \
nickname,domain,port,postJsonObject,None,True,False, \ nickname,domain,port,postJsonObject,None,True,False, \
httpPrefix,projectVersion,False,False,False) httpPrefix,projectVersion,False,False,False,False)
messageId=postJsonObject['id'].replace('/activity','') messageId=postJsonObject['id'].replace('/activity','')
# show the previous posts # show the previous posts
@ -1838,7 +1858,7 @@ def htmlIndividualPost(baseDir: str,session,wfRequest: {},personCache: {}, \
nickname,domain,port,postJsonObject, \ nickname,domain,port,postJsonObject, \
None,True,False, \ None,True,False, \
httpPrefix,projectVersion, \ httpPrefix,projectVersion, \
False,False,False)+postStr False,False,False,False)+postStr
# show the following posts # show the following posts
postFilename=locatePost(baseDir,nickname,domain,messageId) postFilename=locatePost(baseDir,nickname,domain,messageId)
@ -1854,7 +1874,7 @@ def htmlIndividualPost(baseDir: str,session,wfRequest: {},personCache: {}, \
postStr+= \ postStr+= \
individualPostAsHtml(baseDir,session,wfRequest,personCache, \ individualPostAsHtml(baseDir,session,wfRequest,personCache, \
nickname,domain,port,item,None,True,False, \ nickname,domain,port,item,None,True,False, \
httpPrefix,projectVersion,False,False,False) httpPrefix,projectVersion,False,False,False,False)
return htmlHeader()+postStr+htmlFooter() return htmlHeader()+postStr+htmlFooter()
def htmlPostReplies(baseDir: str,session,wfRequest: {},personCache: {}, \ def htmlPostReplies(baseDir: str,session,wfRequest: {},personCache: {}, \
@ -1867,7 +1887,7 @@ def htmlPostReplies(baseDir: str,session,wfRequest: {},personCache: {}, \
for item in repliesJson['orderedItems']: for item in repliesJson['orderedItems']:
repliesStr+=individualPostAsHtml(baseDir,session,wfRequest,personCache, \ repliesStr+=individualPostAsHtml(baseDir,session,wfRequest,personCache, \
nickname,domain,port,item,None,True,False, \ nickname,domain,port,item,None,True,False, \
httpPrefix,projectVersion,False,False,False) httpPrefix,projectVersion,False,False,False,False)
return htmlHeader()+repliesStr+htmlFooter() return htmlHeader()+repliesStr+htmlFooter()
@ -1947,7 +1967,7 @@ def htmlDeletePost(session,baseDir: str,messageId: str, \
deletePostStr+= \ deletePostStr+= \
individualPostAsHtml(baseDir,session,wfRequest,personCache, \ individualPostAsHtml(baseDir,session,wfRequest,personCache, \
nickname,domain,port,postJsonObject,None,True,False, \ nickname,domain,port,postJsonObject,None,True,False, \
httpPrefix,projectVersion,False,False,False) httpPrefix,projectVersion,False,False,False,False)
deletePostStr+='<center>' deletePostStr+='<center>'
deletePostStr+=' <p class="followText">Delete this post?</p>' deletePostStr+=' <p class="followText">Delete this post?</p>'
deletePostStr+= \ deletePostStr+= \
@ -2325,7 +2345,7 @@ def htmlProfileAfterSearch(baseDir: str,path: str,httpPrefix: str, \
nickname,domain,port, \ nickname,domain,port, \
item,avatarUrl,False,False, \ item,avatarUrl,False,False, \
httpPrefix,projectVersion, \ httpPrefix,projectVersion, \
False,False,False) False,False,False,False)
i+=1 i+=1
if i>=20: if i>=20:
break break