forked from indymedia/epicyon
				
			Tidying
							parent
							
								
									5a8757d8b0
								
							
						
					
					
						commit
						2941b9df33
					
				|  | @ -1957,7 +1957,6 @@ class PubServer(BaseHTTPRequestHandler): | ||||||
|             actorStr=self.path.replace('/searchhandle','') |             actorStr=self.path.replace('/searchhandle','') | ||||||
|             length = int(self.headers['Content-length']) |             length = int(self.headers['Content-length']) | ||||||
|             searchParams=self.rfile.read(length).decode('utf-8') |             searchParams=self.rfile.read(length).decode('utf-8') | ||||||
|             #print('******************searchParams '+searchParams) |  | ||||||
|             if 'searchtext=' in searchParams: |             if 'searchtext=' in searchParams: | ||||||
|                 searchStr=searchParams.split('searchtext=')[1] |                 searchStr=searchParams.split('searchtext=')[1] | ||||||
|                 if '&' in searchStr: |                 if '&' in searchStr: | ||||||
|  |  | ||||||
							
								
								
									
										18
									
								
								utils.py
								
								
								
								
							
							
						
						
									
										18
									
								
								utils.py
								
								
								
								
							|  | @ -238,3 +238,21 @@ def noOfAccounts(baseDir: str) -> bool: | ||||||
|                 if not account.startswith('inbox'): |                 if not account.startswith('inbox'): | ||||||
|                     accountCtr+=1 |                     accountCtr+=1 | ||||||
|     return accountCtr |     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 | ||||||
|  |  | ||||||
|  | @ -18,6 +18,7 @@ from utils import getNicknameFromActor | ||||||
| from utils import getDomainFromActor | from utils import getDomainFromActor | ||||||
| from utils import locatePost | from utils import locatePost | ||||||
| from utils import noOfAccounts | from utils import noOfAccounts | ||||||
|  | from utils import isPublicPost | ||||||
| from follow import isFollowingActor | from follow import isFollowingActor | ||||||
| from webfinger import webfingerHandle | from webfinger import webfingerHandle | ||||||
| from posts import getPersonBox | from posts import getPersonBox | ||||||
|  | @ -79,31 +80,13 @@ def htmlHashtagSearch(baseDir: str,hashtag: str,pageNumber: int,postsPerPage: in | ||||||
|             continue |             continue | ||||||
|         with open(postFilename, 'r') as fp: |         with open(postFilename, 'r') as fp: | ||||||
|             postJsonObject=commentjson.load(fp) |             postJsonObject=commentjson.load(fp) | ||||||
|             if not postJsonObject.get('type'): |             if not isPublicPost(postJsonObject): | ||||||
|                 index-=1 |                 index-=1 | ||||||
|                 continue |                 continue | ||||||
|             if postJsonObject['type']!='Create': |             hashtagSearchForm+= \ | ||||||
|                 index-=1 |                 individualPostAsHtml(baseDir,session,wfRequest,personCache, \ | ||||||
|                 continue |                                      nickname,domain,port,postJsonObject, \ | ||||||
|             if not postJsonObject.get('object'): |                                      None,True,False,False) | ||||||
|                 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) |  | ||||||
|         index-=1 |         index-=1 | ||||||
| 
 | 
 | ||||||
|     if endIndex>0: |     if endIndex>0: | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue