diff --git a/daemon.py b/daemon.py index eaa2e9e1d..884b00ce5 100644 --- a/daemon.py +++ b/daemon.py @@ -1957,7 +1957,6 @@ class PubServer(BaseHTTPRequestHandler): actorStr=self.path.replace('/searchhandle','') length = int(self.headers['Content-length']) searchParams=self.rfile.read(length).decode('utf-8') - #print('******************searchParams '+searchParams) if 'searchtext=' in searchParams: searchStr=searchParams.split('searchtext=')[1] if '&' in searchStr: diff --git a/utils.py b/utils.py index e8e65dba3..3cea32ebb 100644 --- a/utils.py +++ b/utils.py @@ -238,3 +238,21 @@ def noOfAccounts(baseDir: str) -> bool: if not account.startswith('inbox'): accountCtr+=1 return accountCtr + +def isPublicPost(postJsonObject: {}) -> bool: + """Returns true if the given post is public + """ + if not postJsonObject.get('type'): + return False + if postJsonObject['type']!='Create': + return False + if not postJsonObject.get('object'): + return False + if not isinstance(postJsonObject['object'], dict): + return False + if not postJsonObject['object'].get('to'): + return False + for recipient in postJsonObject['object']['to']: + if recipient.endswith('#Public'): + return True + return False diff --git a/webinterface.py b/webinterface.py index e80c1c7cf..00a8bd0ef 100644 --- a/webinterface.py +++ b/webinterface.py @@ -18,6 +18,7 @@ from utils import getNicknameFromActor from utils import getDomainFromActor from utils import locatePost from utils import noOfAccounts +from utils import isPublicPost from follow import isFollowingActor from webfinger import webfingerHandle from posts import getPersonBox @@ -79,31 +80,13 @@ def htmlHashtagSearch(baseDir: str,hashtag: str,pageNumber: int,postsPerPage: in continue with open(postFilename, 'r') as fp: postJsonObject=commentjson.load(fp) - if not postJsonObject.get('type'): + if not isPublicPost(postJsonObject): index-=1 continue - if postJsonObject['type']!='Create': - index-=1 - continue - if not postJsonObject.get('object'): - index-=1 - continue - if not isinstance(postJsonObject['object'], dict): - index-=1 - continue - if not postJsonObject['object'].get('to'): - index-=1 - continue - isPublic=False - for recipient in postJsonObject['object']['to']: - if recipient.endswith('#Public'): - isPublic=True - break - if isPublic: - hashtagSearchForm+= \ - individualPostAsHtml(baseDir,session,wfRequest,personCache, \ - nickname,domain,port,postJsonObject, \ - None,True,False,False) + hashtagSearchForm+= \ + individualPostAsHtml(baseDir,session,wfRequest,personCache, \ + nickname,domain,port,postJsonObject, \ + None,True,False,False) index-=1 if endIndex>0: