Browse Source

Remove trailing whitespace

Bob Mottram 7 months ago
parent
commit
23bb250deb
39 changed files with 654 additions and 657 deletions
  1. 5 5
      acceptreject.py
  2. 7 7
      announce.py
  3. 1 1
      auth.py
  4. 4 4
      availability.py
  5. 2 2
      blocking.py
  6. 6 6
      blog.py
  7. 31 31
      blurhash.py
  8. 15 15
      bookmarks.py
  9. 2 2
      cache.py
  10. 6 6
      capabilities.py
  11. 8 8
      content.py
  12. 133 133
      daemon.py
  13. 6 6
      delete.py
  14. 1 1
      donate.py
  15. 56 56
      epicyon.py
  16. 0 1
      filters.py
  17. 22 22
      follow.py
  18. 7 7
      happening.py
  19. 2 2
      httpsig.py
  20. 46 46
      inbox.py
  21. 13 13
      like.py
  22. 8 8
      manualapprove.py
  23. 6 6
      media.py
  24. 2 2
      metadata.py
  25. 1 1
      outbox.py
  26. 16 16
      person.py
  27. 61 61
      posts.py
  28. 1 1
      question.py
  29. 10 10
      roles.py
  30. 1 1
      schedule.py
  31. 3 3
      session.py
  32. 10 10
      shares.py
  33. 4 4
      skills.py
  34. 31 31
      tests.py
  35. 3 4
      theme.py
  36. 17 17
      threads.py
  37. 6 6
      utils.py
  38. 4 4
      webfinger.py
  39. 97 98
      webinterface.py

+ 5 - 5
acceptreject.py

@@ -85,7 +85,7 @@ def acceptFollow(baseDir: str,domain : str,messageJson: {}, \
     if not messageJson.get('object'):
         return
     if not messageJson['object'].get('type'):
-        return 
+        return
     if not messageJson['object']['type']=='Follow':
         return
     if debug:
@@ -96,7 +96,7 @@ def acceptFollow(baseDir: str,domain : str,messageJson: {}, \
     # no, this isn't a mistake
     if not messageJson['object'].get('object'):
         print('DEBUG: no object within Follow activity')
-        return 
+        return
     if not messageJson.get('to'):
         if debug:
             print('DEBUG: No "to" parameter in follow Accept')
@@ -115,7 +115,7 @@ def acceptFollow(baseDir: str,domain : str,messageJson: {}, \
         return
     if not nickname:
         if debug:
-            print('DEBUG: nickname not found in '+thisActor)        
+            print('DEBUG: nickname not found in '+thisActor)
         return
     if acceptedPort:
         if '/'+acceptedDomain+':'+str(acceptedPort)+'/users/'+nickname not in thisActor:
@@ -132,7 +132,7 @@ def acceptFollow(baseDir: str,domain : str,messageJson: {}, \
                 print('Expected: /'+acceptedDomain+'/users/'+nickname)
                 print('Actual:   '+thisActor)
                 print('DEBUG: unrecognized actor '+thisActor)
-            return    
+            return
     followedActor=messageJson['object']['object']
     followedDomain,port=getDomainFromActor(followedActor)
     if not followedDomain:
@@ -166,7 +166,7 @@ def acceptFollow(baseDir: str,domain : str,messageJson: {}, \
                       nickname+'@'+acceptedDomainFull+ \
                       ' from '+followedNickname+'@'+followedDomainFull+ \
                       ' but they have been unfollowed')
-            return            
+            return
 
     if followPerson(baseDir, \
                     nickname,acceptedDomainFull, \

+ 7 - 7
announce.py

@@ -78,7 +78,7 @@ def undoAnnounceCollectionEntry(recentPostsCache: {}, \
                                 baseDir: str,postFilename: str, \
                                 actor: str,domain: str,debug: bool) -> None:
     """Undoes an announce for a particular actor by removing it from
-    the "shares" collection within a post. Note that the "shares" 
+    the "shares" collection within a post. Note that the "shares"
     collection has no relation to shared items in shares.py. It's
     shares of posts, not shares of physical objects.
     """
@@ -169,7 +169,7 @@ def updateAnnounceCollection(recentPostsCache: {}, \
                 "totalItems": 1,
                 'items': [{
                     'type': 'Announce',
-                    'actor': actor                    
+                    'actor': actor
                 }]
             }
             postJsonObject['object']['shares']=announcementsJson
@@ -274,7 +274,7 @@ def createAnnounce(session,baseDir: str,federationList: [], \
                        httpPrefix,True,clientToServer,federationList, \
                        sendThreads,postLog,cachedWebfingers,personCache, \
                        debug,projectVersion)
-            
+
     return newAnnounce
 
 def announcePublic(session,baseDir: str,federationList: [], \
@@ -386,7 +386,7 @@ def undoAnnounce(session,baseDir: str,federationList: [], \
                        'https://www.w3.org/ns/activitystreams#Public', \
                        httpPrefix,True,clientToServer,federationList, \
                        sendThreads,postLog,cachedWebfingers,personCache,debug)
-            
+
     return newUndoAnnounce
 
 def undoAnnouncePublic(session,baseDir: str,federationList: [], \
@@ -495,7 +495,7 @@ def sendAnnounceViaServer(baseDir: str,session, \
     inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,displayName= \
         getPersonBox(baseDir,session,wfRequest,personCache, \
                      projectVersion,httpPrefix,fromNickname,fromDomain,postToBox)
-                     
+
     if not inboxUrl:
         if debug:
             print('DEBUG: No '+postToBox+' was found for '+handle)
@@ -504,9 +504,9 @@ def sendAnnounceViaServer(baseDir: str,session, \
         if debug:
             print('DEBUG: No actor was found for '+handle)
         return 4
-    
+
     authHeader=createBasicAuthHeader(fromNickname,password)
-     
+
     headers={
         'host': fromDomain, \
         'Content-type': 'application/json', \

+ 1 - 1
auth.py

@@ -22,7 +22,7 @@ def hashPassword(password: str) -> str:
                                 salt, 100000)
     pwdhash=binascii.hexlify(pwdhash)
     return (salt+pwdhash).decode('ascii')
- 
+
 def verifyPassword(storedPassword: str,providedPassword: str) -> bool:
     """Verify a stored password against one provided by user
     """

+ 4 - 4
availability.py

@@ -88,7 +88,7 @@ def sendAvailabilityViaServer(baseDir: str,session, \
         if port!=80 and port!=443:
             if ':' not in domain:
                 domainFull=domain+':'+str(port)
-        
+
     toUrl=httpPrefix+'://'+domainFull+'/users/'+nickname
     ccUrl=httpPrefix+'://'+domainFull+'/users/'+nickname+'/followers'
 
@@ -117,7 +117,7 @@ def sendAvailabilityViaServer(baseDir: str,session, \
     inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,displayName= \
         getPersonBox(baseDir,session,wfRequest,personCache, \
                      projectVersion,httpPrefix,nickname,domain,postToBox)
-                     
+
     if not inboxUrl:
         if debug:
             print('DEBUG: No '+postToBox+' was found for '+handle)
@@ -126,9 +126,9 @@ def sendAvailabilityViaServer(baseDir: str,session, \
         if debug:
             print('DEBUG: No actor was found for '+handle)
         return 4
-    
+
     authHeader=createBasicAuthHeader(Nickname,password)
-     
+
     headers={
         'host': domain, \
         'Content-type': 'application/json', \

+ 2 - 2
blocking.py

@@ -14,7 +14,7 @@ def addGlobalBlock(baseDir: str, \
     """Global block which applies to all accounts
     """
     blockingFilename=baseDir+'/accounts/blocking.txt'
-    if not blockNickname.startswith('#'):        
+    if not blockNickname.startswith('#'):
         blockHandle=blockNickname+'@'+blockDomain
         if os.path.isfile(blockingFilename):
             if blockHandle in open(blockingFilename).read():
@@ -54,7 +54,7 @@ def removeGlobalBlock(baseDir: str, \
     """Unblock the given global block
     """
     unblockingFilename=baseDir+'/accounts/blocking.txt'
-    if not unblockNickname.startswith('#'):        
+    if not unblockNickname.startswith('#'):
         unblockHandle=unblockNickname+'@'+unblockDomain
         if os.path.isfile(unblockingFilename):
             if unblockHandle in open(unblockingFilename).read():

+ 6 - 6
blog.py

@@ -171,7 +171,7 @@ def htmlBlogPostContent(authorized: bool, \
         # posts from the domain are expected to have an attributedTo field
         if restrictToDomain:
             return ''
-        
+
     if postJsonObject['object'].get('published'):
         if 'T' in postJsonObject['object']['published']:
             blogStr+='<h3>'+postJsonObject['object']['published'].split('T')[0]
@@ -312,7 +312,7 @@ def htmlBlogPage(authorized: bool, session, \
     """
     if ' ' in nickname or '@' in nickname or '\n' in nickname:
         return None
-    blogStr=''    
+    blogStr=''
 
     cssFilename=baseDir+'/epicyon-profile.css'
     if os.path.isfile(baseDir+'/epicyon.css'):
@@ -424,7 +424,7 @@ def htmlBlogPageRSS(authorized: bool, session, \
     if not timelineJson:
         return blogRSS+rssFooter()
 
-    if pageNumber!=None:        
+    if pageNumber!=None:
         for item in timelineJson['orderedItems']:
             if item['type']!='Create':
                 continue
@@ -556,11 +556,11 @@ def htmlEditBlog(mediaInstance: bool,translate: {}, \
 
     if os.path.isfile(baseDir+'/accounts/newpost.txt'):
         with open(baseDir+'/accounts/newpost.txt', 'r') as file:
-            editBlogText='<p class="new-post-text">'+file.read()+'</p>'    
+            editBlogText='<p class="new-post-text">'+file.read()+'</p>'
 
     cssFilename=baseDir+'/epicyon-profile.css'
     if os.path.isfile(baseDir+'/epicyon.css'):
-        cssFilename=baseDir+'/epicyon.css'        
+        cssFilename=baseDir+'/epicyon.css'
     with open(cssFilename, 'r') as cssFile:
         editBlogCSS=cssFile.read()
         if httpPrefix!='https':
@@ -606,7 +606,7 @@ def htmlEditBlog(mediaInstance: bool,translate: {}, \
     editBlogForm=htmlHeader(cssFilename,editBlogCSS)
 
     mentionsStr=''
-        
+
     editBlogForm+= \
         '<form enctype="multipart/form-data" method="POST" accept-charset="UTF-8" action="'+ \
         pathBase+'?'+endpoint+'?page='+str(pageNumber)+'">'

+ 31 - 31
blurhash.py

@@ -10,7 +10,7 @@ furnished to do so, subject to the following conditions:
 
 * The above copyright notice and this permission notice shall be included in all
 copies or substantial portions of the Software.
-* You and any organization you work for may not promote white supremacy, hate 
+* You and any organization you work for may not promote white supremacy, hate
 speech and homo- or transphobia - this license is void if you do.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
@@ -23,7 +23,7 @@ SOFTWARE.
 
 https://github.com/halcy/blurhash-python
 
-Pure python blurhash decoder with no additional dependencies, for 
+Pure python blurhash decoder with no additional dependencies, for
 both de- and encoding.
 
 Very close port of the original Swift implementation by Dag Ågren.
@@ -47,13 +47,13 @@ def base83_decode(base83_str):
 def base83_encode(value, length):
     """
     Decodes an integer to a base83 string, as used in blurhash.
-    
+
     Length is how long the resulting string should be. Will complain
     if the specified length is too short.
     """
     if int(value) // (83 ** (length)) != 0:
         raise ValueError("Specified length is too short to encode given value.")
-        
+
     result=""
     for i in range(1,length+1):
         digit=int(value) // (83 ** (length - i)) % 83
@@ -90,44 +90,44 @@ def blurhash_components(blurhash):
     """
     if len(blurhash) < 6:
         raise ValueError("BlurHash must be at least 6 characters long.")
-    
+
     # Decode metadata
     size_info=base83_decode(blurhash[0])
     size_y=int(size_info / 9)+1
     size_x=(size_info % 9)+1
-    
+
     return size_x, size_y
 
 def blurhash_decode(blurhash,width,height,punch=1.0,linear=False):
     """
     Decodes the given blurhash to an image of the specified size.
-    
+
     Returns the resulting image a list of lists of 3-value sRGB 8 bit integer
-    lists. Set linear to True if you would prefer to get linear floating point 
+    lists. Set linear to True if you would prefer to get linear floating point
     RGB back.
-    
+
     The punch parameter can be used to de- or increase the contrast of the
     resulting image.
-    
+
     As per the original implementation it is suggested to only decode
     to a relatively small size and then scale the result up, as it
     basically looks the same anyways.
     """
     if len(blurhash) < 6:
         raise ValueError("BlurHash must be at least 6 characters long.")
-    
+
     # Decode metadata
     size_info=base83_decode(blurhash[0])
     size_y=int(size_info / 9)+1
     size_x=(size_info % 9)+1
-    
+
     quant_max_value=base83_decode(blurhash[1])
     real_max_value=(float(quant_max_value+1)/166.0)*punch
-    
+
     # Make sure we at least have the right number of characters
     if len(blurhash) != 4+2*size_x*size_y:
         raise ValueError("Invalid BlurHash length.")
-        
+
     # Decode DC component
     dc_value=base83_decode(blurhash[2:6])
     colours=[(
@@ -135,7 +135,7 @@ def blurhash_decode(blurhash,width,height,punch=1.0,linear=False):
         srgb_to_linear((dc_value >> 8) & 255),
         srgb_to_linear(dc_value & 255)
     )]
-    
+
     # Decode AC components
     for component in range(1, size_x * size_y):
         ac_value=base83_decode(blurhash[4+component*2:4+(component+1)*2])
@@ -144,8 +144,8 @@ def blurhash_decode(blurhash,width,height,punch=1.0,linear=False):
             sign_pow((float(int(ac_value / 19) % 19) - 9.0) / 9.0, 2.0) * real_max_value,
             sign_pow((float(ac_value % 19) - 9.0) / 9.0, 2.0) * real_max_value
         ))
-    
-    # Return image RGB values, as a list of lists of lists, 
+
+    # Return image RGB values, as a list of lists of lists,
     # consumable by something like numpy or PIL.
     pixels=[]
     for y in range(height):
@@ -172,24 +172,24 @@ def blurhash_decode(blurhash,width,height,punch=1.0,linear=False):
                 pixel_row.append(pixel)
         pixels.append(pixel_row)
     return pixels
-    
+
 def blurhash_encode(image,components_x=4,components_y=4,linear=False):
     """
     Calculates the blurhash for an image using the given x and y component counts.
-    
+
     Image should be a 3-dimensional array, with the first dimension being y, the second
-    being x, and the third being the three rgb components that are assumed to be 0-255 
+    being x, and the third being the three rgb components that are assumed to be 0-255
     srgb integers (incidentally, this is the format you will get from a PIL RGB image).
-    
+
     You can also pass in already linear data - to do this, set linear to True. This is
     useful if you want to encode a version of your image resized to a smaller size (which
     you should ideally do in linear colour).
     """
-    if components_x < 1 or components_x > 9 or components_y < 1 or components_y > 9: 
+    if components_x < 1 or components_x > 9 or components_y < 1 or components_y > 9:
         raise ValueError("x and y component counts must be between 1 and 9 inclusive.")
     height=float(len(image))
     width=float(len(image[0]))
-    
+
     # Convert to linear if neeeded
     image_linear=[]
     if linear==False:
@@ -204,7 +204,7 @@ def blurhash_encode(image,components_x=4,components_y=4,linear=False):
             image_linear.append(image_linear_line)
     else:
         image_linear=image
-        
+
     # Calculate components
     components=[]
     max_ac_component=0.0
@@ -220,28 +220,28 @@ def blurhash_encode(image,components_x=4,components_y=4,linear=False):
                     component[0] += basis * image_linear[y][x][0]
                     component[1] += basis * image_linear[y][x][1]
                     component[2] += basis * image_linear[y][x][2]
-                    
+
             component[0] /= (width * height)
             component[1] /= (width * height)
             component[2] /= (width * height)
             components.append(component)
-            
+
             if not (i==0 and j==0):
                 max_ac_component= \
                     max(max_ac_component,abs(component[0]), \
                         abs(component[1]),abs(component[2]))
-                
+
     # Encode components
     dc_value= \
         (linear_to_srgb(components[0][0]) << 16)+ \
         (linear_to_srgb(components[0][1]) << 8)+ \
         linear_to_srgb(components[0][2])
-    
+
     quant_max_ac_component= \
         int(max(0, min(82, math.floor(max_ac_component * 166 - 0.5))))
     ac_component_norm_factor= \
         float(quant_max_ac_component+1) / 166.0
-    
+
     ac_values=[]
     for r, g, b in components[1:]:
         ac_values.append(
@@ -249,7 +249,7 @@ def blurhash_encode(image,components_x=4,components_y=4,linear=False):
             int(max(0.0,min(18.0, math.floor(sign_pow(g / ac_component_norm_factor, 0.5) * 9.0 + 9.5)))) * 19 + \
             int(max(0.0,min(18.0, math.floor(sign_pow(b / ac_component_norm_factor, 0.5) * 9.0 + 9.5))))
         )
-        
+
     # Build final blurhash
     blurhash=""
     blurhash += base83_encode((components_x - 1) + (components_y - 1) * 9, 1)
@@ -257,5 +257,5 @@ def blurhash_encode(image,components_x=4,components_y=4,linear=False):
     blurhash += base83_encode(dc_value, 4)
     for ac_value in ac_values:
         blurhash += base83_encode(ac_value, 2)
-    
+
     return blurhash

+ 15 - 15
bookmarks.py

@@ -167,7 +167,7 @@ def updateBookmarksCollection(recentPostsCache: {}, \
                 'items': [{
                     'type': 'Bookmark',
                     'actor': actor
-                }]                
+                }]
             }
             postJsonObject['object']['bookmarks']=bookmarksJson
         else:
@@ -271,11 +271,11 @@ def bookmark(recentPostsCache: {}, \
             print('DEBUG: bookmark domain: '+domain)
             print('DEBUG: bookmark objectUrl: '+objectUrl)
             return None
-        
+
         updateBookmarksCollection(recentPostsCache, \
                                   baseDir,postFilename,objectUrl, \
                                   newBookmarkJson['actor'],domain,debug)
-        
+
         sendSignedJson(newBookmarkJson,session,baseDir, \
                        nickname,domain,port, \
                        bookmarkedPostNickname,bookmarkedPostDomain,bookmarkedPostPort, \
@@ -385,7 +385,7 @@ def undoBookmark(recentPostsCache: {}, \
         undoBookmarksCollectionEntry(recentPostsCache, \
                                      baseDir,postFilename,objectUrl, \
                                      newBookmarkJson['actor'],domain,debug)
-        
+
         sendSignedJson(newUndoBookmarkJson,session,baseDir, \
                        nickname,domain,port, \
                        bookmarkedPostNickname,bookmarkedPostDomain,bookmarkedPostPort, \
@@ -425,7 +425,7 @@ def undoBookmarkPost(session,baseDir: str,federationList: [], \
                 ccUrl= \
                     httpPrefix+'://'+bookmarkedomain+':'+ \
                     str(bookmarkPort)+'/users/'+bookmarkNickname
-                
+
     return undoBookmark(session,baseDir,federationList,nickname,domain,port, \
                         ccList,httpPrefix,objectUrl,clientToServer, \
                         sendThreads,postLog,personCache,cachedWebfingers,debug)
@@ -453,7 +453,7 @@ def sendBookmarkViaServer(baseDir: str,session, \
 
     if '/statuses/' in bookmarkUrl:
         toUrl=[bookmarkUrl.split('/statuses/')[0]]
-        
+
     newBookmarkJson={
         "@context": "https://www.w3.org/ns/activitystreams",
         'type': 'Bookmark',
@@ -478,7 +478,7 @@ def sendBookmarkViaServer(baseDir: str,session, \
         getPersonBox(baseDir,session,wfRequest,personCache, \
                      projectVersion,httpPrefix,fromNickname, \
                      fromDomain,postToBox)
-    
+
     if not inboxUrl:
         if debug:
             print('DEBUG: No '+postToBox+' was found for '+handle)
@@ -487,9 +487,9 @@ def sendBookmarkViaServer(baseDir: str,session, \
         if debug:
             print('DEBUG: No actor was found for '+handle)
         return 4
-    
+
     authHeader=createBasicAuthHeader(fromNickname,password)
-    
+
     headers={
         'host': fromDomain, \
         'Content-type': 'application/json', \
@@ -559,7 +559,7 @@ def sendUndoBookmarkViaServer(baseDir: str,session, \
         getPersonBox(baseDir,session,wfRequest,personCache, \
                      projectVersion,httpPrefix,fromNickname, \
                      fromDomain,postToBox)
-    
+
     if not inboxUrl:
         if debug:
             print('DEBUG: No '+postToBox+' was found for '+handle)
@@ -568,9 +568,9 @@ def sendUndoBookmarkViaServer(baseDir: str,session, \
         if debug:
             print('DEBUG: No actor was found for '+handle)
         return 4
-    
+
     authHeader=createBasicAuthHeader(fromNickname,password)
-    
+
     headers={
         'host': fromDomain, \
         'Content-type': 'application/json', \
@@ -618,7 +618,7 @@ def outboxBookmark(recentPostsCache: {}, \
             return
         if messageJson['to'][0]!=messageJson['actor']:
             print('WARN: Bookmark should be addressed to the same actor')
-            return            
+            return
     if debug:
         print('DEBUG: c2s bookmark request arrived in outbox')
 
@@ -652,7 +652,7 @@ def outboxUndoBookmark(recentPostsCache: {}, \
     if not isinstance(messageJson['object'], dict):
         if debug:
             print('DEBUG: undo bookmark object is not dict')
-        return    
+        return
     if not messageJson['object'].get('type'):
         if debug:
             print('DEBUG: undo bookmark - no type')
@@ -677,7 +677,7 @@ def outboxUndoBookmark(recentPostsCache: {}, \
             return
         if messageJson['to'][0]!=messageJson['actor']:
             print('WARN: Bookmark should be addressed to the same actor')
-            return            
+            return
     if debug:
         print('DEBUG: c2s undo bookmark request arrived in outbox')
 

+ 2 - 2
cache.py

@@ -11,7 +11,7 @@ import time
 import datetime
 from utils import loadJson
 from utils import saveJson
-        
+
 def storePersonInCache(baseDir: str,personUrl: str,personJson: {},personCache: {}) -> None:
     """Store an actor in the cache
     """
@@ -41,7 +41,7 @@ def getPersonFromCache(baseDir: str,personUrl: str,personCache: {}) -> {}:
             if personJson:
                 storePersonInCache(baseDir,personUrl,personJson,personCache)
                 loadedFromFile=True
-        
+
     if personCache.get(personUrl):
         if not loadedFromFile:
             # update the timestamp for the last time the actor was retrieved

+ 6 - 6
capabilities.py

@@ -82,7 +82,7 @@ def CapablePost(postJson: {}, capabilityList: [], debug :bool) -> bool:
                         if 'inbox:cw' in capabilityList:
                             if debug:
                                 print('DEBUG: inbox post rejected because inbox:cw, summary missing')
-                            return False                        
+                            return False
     if 'inbox:write' in capabilityList:
         return True
     return True
@@ -102,7 +102,7 @@ def capabilitiesRequest(baseDir: str,httpPrefix: str,domain: str, \
         "actor": requestedActor
     }
     return ocapRequest
- 
+
 def capabilitiesAccept(baseDir: str,httpPrefix: str, \
                        nickname: str,domain: str, port: int, \
                        acceptedActor: str, saveToFile: bool, \
@@ -119,7 +119,7 @@ def capabilitiesAccept(baseDir: str,httpPrefix: str, \
         if port!=80 and port !=443:
             if ':' not in domain:
                 fullDomain=domain+':'+str(port)
-    
+
     # make directories to store capabilities
     ocapFilename=getOcapFilename(baseDir,nickname,fullDomain,acceptedActor,'accept')
     if not ocapFilename:
@@ -129,14 +129,14 @@ def capabilitiesAccept(baseDir: str,httpPrefix: str, \
     # if the capability already exists then load it from file
     if os.path.isfile(ocapFilename):
         ocapAccept=loadJson(ocapFilename)
-    # otherwise create a new capability    
+    # otherwise create a new capability
     if not ocapAccept:
         acceptedActorNickname=getNicknameFromActor(acceptedActor)
         if not acceptedActorNickname:
             print('WARN: unable to find nickname in '+acceptedActor)
             return None
         acceptedActorDomain,acceptedActorPort=getDomainFromActor(acceptedActor)
-        if acceptedActorPort:            
+        if acceptedActorPort:
             ocapId=acceptedActorNickname+'@'+acceptedActorDomain+':'+str(acceptedActorPort)+'#'+createPassword(32)
         else:
             ocapId=acceptedActorNickname+'@'+acceptedActorDomain+'#'+createPassword(32)
@@ -185,7 +185,7 @@ def capabilitiesUpdate(baseDir: str,httpPrefix: str, \
         if port!=80 and port !=443:
             if ':' not in domain:
                 fullDomain=domain+':'+str(port)
-    
+
     # Get the filename of the capability
     ocapFilename=getOcapFilename(baseDir,nickname,fullDomain,updateActor,'accept')
     if not ocapFilename:

+ 8 - 8
content.py

@@ -92,7 +92,7 @@ def replaceEmojiFromTags(content: str,tag: [],messageType: str) -> str:
 
         htmlClass='emoji'
         if messageType=='post header':
-            htmlClass='emojiheader'            
+            htmlClass='emojiheader'
         if messageType=='profile':
             htmlClass='emojiprofile'
         emojiHtml="<img src=\""+tagItem['icon']['url']+"\" alt=\""+tagItem['name'].replace(':','')+"\" align=\"middle\" class=\""+htmlClass+"\"/>"
@@ -298,7 +298,7 @@ def addMention(wordStr: str,httpPrefix: str,following: str,replaceMentions: {},r
             return True
     # @nick@domain
     if not (possibleDomain=='localhost' or '.' in possibleDomain):
-        return False        
+        return False
     recipientActor=httpPrefix+"://"+possibleDomain+"/users/"+possibleNickname
     if recipientActor not in recipients:
         recipients.append(recipientActor)
@@ -389,7 +389,7 @@ def addHtmlTags(baseDir: str,httpPrefix: str, \
     content=content.replace('\n',' --linebreak-- ')
     content=addMusicTag(content,'nowplaying')
     words=content.replace(',',' ').replace(';',' ').split(' ')
-    
+
     # remove . for words which are not mentions
     wordCtr=0
     newWords=[]
@@ -461,7 +461,7 @@ def addHtmlTags(baseDir: str,httpPrefix: str, \
         content=removeLongWords(content,maxWordLength,longWordsList)
     content=content.replace(' --linebreak-- ','</p><p>')
     return '<p>'+content+'</p>'
-                
+
 def getMentionsFromHtml(htmlText: str,matchStr="<span class=\"h-card\"><a href=\"") -> []:
     """Extracts mentioned actors from the given html content string
     """
@@ -521,7 +521,7 @@ def saveMediaInFormPOST(mediaBytes,debug: bool, \
     mediaLocation=-1
     searchStr=''
     filename=None
-    
+
     # directly search the binary array for the beginning
     # of an image
     extensionList= {
@@ -579,7 +579,7 @@ def saveMediaInFormPOST(mediaBytes,debug: bool, \
 def extractTextFieldsInPOST(postBytes,boundary,debug: bool) -> {}:
     """Returns a dictionary containing the text fields of a http form POST
     The boundary argument comes from the http header
-    """    
+    """
     msg=email.parser.BytesParser().parsebytes(postBytes)
     if debug:
         print('DEBUG: POST arriving '+msg.get_payload(decode=True).decode('utf-8'))
@@ -590,7 +590,7 @@ def extractTextFieldsInPOST(postBytes,boundary,debug: bool) -> {}:
         if f=='--':
             continue
         if ' name="' not in f:
-            continue                    
+            continue
         postStr=f.split(' name="',1)[1]
         if '"' not in postStr:
             continue
@@ -600,7 +600,7 @@ def extractTextFieldsInPOST(postBytes,boundary,debug: bool) -> {}:
             continue
         if '\r\n' not in postValueStr:
             continue
-        postLines=postValueStr.split('\r\n')                                    
+        postLines=postValueStr.split('\r\n')
         postValue=''
         if len(postLines)>2:
             for line in range(2,len(postLines)-1):

File diff suppressed because it is too large
+ 133 - 133
daemon.py


+ 6 - 6
delete.py

@@ -80,7 +80,7 @@ def createDelete(session,baseDir: str,federationList: [], \
                        'https://www.w3.org/ns/activitystreams#Public', \
                        httpPrefix,True,clientToServer,federationList, \
                        sendThreads,postLog,cachedWebfingers,personCache,debug)
-        
+
     return newDelete
 
 def sendDeleteViaServer(baseDir: str,session, \
@@ -131,7 +131,7 @@ def sendDeleteViaServer(baseDir: str,session, \
         getPersonBox(baseDir,session,wfRequest,personCache, \
                      projectVersion,httpPrefix,fromNickname, \
                      fromDomain,postToBox)
-                     
+
     if not inboxUrl:
         if debug:
             print('DEBUG: No '+postToBox+' was found for '+handle)
@@ -140,9 +140,9 @@ def sendDeleteViaServer(baseDir: str,session, \
         if debug:
             print('DEBUG: No actor was found for '+handle)
         return 4
-    
+
     authHeader=createBasicAuthHeader(fromNickname,password)
-     
+
     headers={
         'host': fromDomain, \
         'Content-type': 'application/json', \
@@ -257,14 +257,14 @@ def outboxDelete(baseDir: str,httpPrefix: str, \
     if deleteNickname!=nickname:
         if debug:
             print("DEBUG: you can't delete a post which wasn't created by you (nickname does not match)")
-        return        
+        return
     deleteDomain,deletePort=getDomainFromActor(messageId)
     if ':' in domain:
         domain=domain.split(':')[0]
     if deleteDomain!=domain:
         if debug:
             print("DEBUG: you can't delete a post which wasn't created by you (domain does not match)")
-        return        
+        return
     removeModerationPostFromIndex(baseDir,messageId,debug)
     postFilename=locatePost(baseDir,deleteNickname,deleteDomain,messageId)
     if not postFilename:

+ 1 - 1
donate.py

@@ -12,7 +12,7 @@ def getDonationTypes() -> str:
     return ('patreon','paypal','gofundme','liberapay', \
             'kickstarter','indiegogo','crowdsupply', \
             'subscribestar')
-    
+
 def getDonationUrl(actorJson: {}) -> str:
     """Returns a link used for donations
     """

+ 56 - 56
epicyon.py

@@ -354,7 +354,7 @@ if args.posts:
 if args.postsraw:
     if '@' not in args.postsraw:
         print('Syntax: --postsraw nickname@domain')
-        sys.exit()        
+        sys.exit()
     if not args.http:
         args.port=443
     nickname=args.postsraw.split('@')[0]
@@ -398,7 +398,7 @@ if not args.blogsinstance:
     blogsInstance=getConfigParam(baseDir,'blogsInstance')
     if blogsInstance!=None:
         args.blogsinstance=blogsInstance
-    
+
 # set the instance title in config.json
 title=getConfigParam(baseDir,'instanceTitle')
 if not title:
@@ -450,13 +450,13 @@ if not getConfigParam(baseDir,'registration'):
     setConfigParam(baseDir,'maxRegistrations',str(maxRegistrations))
     setConfigParam(baseDir,'registrationsRemaining',str(maxRegistrations))
 
-if args.resetregistrations:    
+if args.resetregistrations:
     setConfigParam(baseDir,'registrationsRemaining',str(maxRegistrations))
     print('Number of new registrations reset to '+str(maxRegistrations))
-    
+
 # whether new registrations are open or closed
 if args.registration:
-    if args.registration.lower()=='open':        
+    if args.registration.lower()=='open':
         registration=getConfigParam(baseDir,'registration')
         if not registration:
             setConfigParam(baseDir,'registrationsRemaining',str(maxRegistrations))
@@ -468,7 +468,7 @@ if args.registration:
     else:
         setConfigParam(baseDir,'registration','closed')
         print('New registrations closed')
-    
+
 # unique ID for the instance
 instanceId=getConfigParam(baseDir,'instanceId')
 if not instanceId:
@@ -535,7 +535,7 @@ if args.approve:
     if '@' not in args.approve:
         print('syntax: --approve nick@domain')
         sys.exit()
-    session=createSession(useTor)        
+    session=createSession(useTor)
     sendThreads=[]
     postLog=[]
     cachedWebfingers={}
@@ -559,7 +559,7 @@ if args.deny:
     if '@' not in args.deny:
         print('syntax: --deny nick@domain')
         sys.exit()
-    session=createSession(useTor)        
+    session=createSession(useTor)
     sendThreads=[]
     postLog=[]
     cachedWebfingers={}
@@ -590,21 +590,21 @@ if args.followerspending:
     if approveCtr==0:
         print('There are no follow requests pending approval.')
     sys.exit()
-        
-    
+
+
 if args.message:
     if not args.nickname:
         print('Specify a nickname with the --nickname option')
         sys.exit()
-        
+
     if not args.password:
         print('Specify a password with the --password option')
         sys.exit()
-        
-    session=createSession(useTor)        
+
+    session=createSession(useTor)
     if not args.sendto:
         print('Specify an account to sent to: --sendto [nickname@domain]')
-        sys.exit()        
+        sys.exit()
     if '@' not in args.sendto and \
        not args.sendto.lower().endswith('public') and \
        not args.sendto.lower().endswith('followers'):
@@ -628,7 +628,7 @@ if args.message:
             toNickname=None
             toDomain='public'
             toPort=port
-        
+
     #ccUrl=httpPrefix+'://'+domain+'/users/'+nickname+'/followers'
     ccUrl=None
     sendMessage=args.message
@@ -668,12 +668,12 @@ if args.announce:
     if not args.nickname:
         print('Specify a nickname with the --nickname option')
         sys.exit()
-        
+
     if not args.password:
         print('Specify a password with the --password option')
         sys.exit()
-        
-    session=createSession(useTor)        
+
+    session=createSession(useTor)
     personCache={}
     cachedWebfingers={}
     print('Sending announce/repeat of '+args.announce)
@@ -717,7 +717,7 @@ if args.itemName:
         print('Specify a duration to share the object with the --duration option')
         sys.exit()
 
-    session=createSession(useTor)        
+    session=createSession(useTor)
     personCache={}
     cachedWebfingers={}
     print('Sending shared item: '+args.itemName)
@@ -749,7 +749,7 @@ if args.undoItemName:
         print('Specify a nickname with the --nickname option')
         sys.exit()
 
-    session=createSession(useTor)        
+    session=createSession(useTor)
     personCache={}
     cachedWebfingers={}
     print('Sending undo of shared item: '+args.undoItemName)
@@ -770,12 +770,12 @@ if args.like:
     if not args.nickname:
         print('Specify a nickname with the --nickname option')
         sys.exit()
-        
+
     if not args.password:
         print('Specify a password with the --password option')
         sys.exit()
-        
-    session=createSession(useTor)        
+
+    session=createSession(useTor)
     personCache={}
     cachedWebfingers={}
     print('Sending like of '+args.like)
@@ -795,12 +795,12 @@ if args.undolike:
     if not args.nickname:
         print('Specify a nickname with the --nickname option')
         sys.exit()
-        
+
     if not args.password:
         print('Specify a password with the --password option')
         sys.exit()
-        
-    session=createSession(useTor)        
+
+    session=createSession(useTor)
     personCache={}
     cachedWebfingers={}
     print('Sending undo like of '+args.undolike)
@@ -820,12 +820,12 @@ if args.delete:
     if not args.nickname:
         print('Specify a nickname with the --nickname option')
         sys.exit()
-        
+
     if not args.password:
         print('Specify a password with the --password option')
         sys.exit()
-        
-    session=createSession(useTor)        
+
+    session=createSession(useTor)
     personCache={}
     cachedWebfingers={}
     print('Sending delete request of '+args.delete)
@@ -852,11 +852,11 @@ if args.follow:
     if not args.password:
         print('Please specify the password for '+args.nickname+' on '+domain)
         sys.exit()
-        
+
     followNickname=getNicknameFromActor(args.follow)
     if not followNickname:
         print('Unable to find nickname in '+args.follow)
-        sys.exit()        
+        sys.exit()
     followDomain,followPort=getDomainFromActor(args.follow)
 
     session=createSession(useTor)
@@ -890,11 +890,11 @@ if args.unfollow:
     if not args.password:
         print('Please specify the password for '+args.nickname+' on '+domain)
         sys.exit()
-        
+
     followNickname=getNicknameFromActor(args.unfollow)
     if not followNickname:
         print('WARN: unable to find nickname in '+args.unfollow)
-        sys.exit()        
+        sys.exit()
     followDomain,followPort=getDomainFromActor(args.unfollow)
 
     session=createSession(useTor)
@@ -927,7 +927,7 @@ if args.port:
 if args.proxyPort:
     proxyPort=args.proxyPort
     setConfigParam(baseDir,'proxyPort',proxyPort)
-ocapAlways=False    
+ocapAlways=False
 if args.ocap:
     ocapAlways=args.ocap
 if args.dat:
@@ -995,7 +995,7 @@ if args.actor:
             personUrl=originalActor
         else:
             sys.exit()
-        
+
     asHeader={
         'Accept': 'application/activity+json; profile="https://www.w3.org/ns/activitystreams"'
     }
@@ -1041,13 +1041,13 @@ if args.addaccount:
             sys.exit()
     if not validNickname(domain,nickname):
         print(nickname+' is a reserved name. Use something different.')
-        sys.exit()        
+        sys.exit()
     if not args.password:
         print('Use the --password option to set the password for '+nickname)
         sys.exit()
     if len(args.password.strip())<8:
         print('Password should be at least 8 characters')
-        sys.exit()            
+        sys.exit()
     if os.path.isdir(baseDir+'/accounts/'+nickname+'@'+domain):
         print('Account already exists')
         sys.exit()
@@ -1198,7 +1198,7 @@ if args.avatar:
         print('Avatar added for '+args.nickname)
     else:
         print('Avatar was not added for '+args.nickname)
-    sys.exit()    
+    sys.exit()
 
 if args.backgroundImage:
     if not os.path.isfile(args.backgroundImage):
@@ -1212,14 +1212,14 @@ if args.backgroundImage:
         print('Background image added for '+args.nickname)
     else:
         print('Background image was not added for '+args.nickname)
-    sys.exit()    
+    sys.exit()
 
 if args.project:
-    if not args.delegate and not args.undelegate:        
+    if not args.delegate and not args.undelegate:
         if not nickname:
             print('No nickname given')
             sys.exit()
-        
+
         if args.role.lower()=='none' or \
            args.role.lower()=='remove' or \
            args.role.lower()=='delete':
@@ -1236,7 +1236,7 @@ if args.skill:
     if not nickname:
         print('Specify a nickname with the --nickname option')
         sys.exit()
-        
+
     if not args.password:
         print('Specify a password with the --password option')
         sys.exit()
@@ -1249,7 +1249,7 @@ if args.skill:
         print('Skill level should be a percentage in the range 0-100')
         sys.exit()
 
-    session=createSession(useTor)        
+    session=createSession(useTor)
     personCache={}
     cachedWebfingers={}
     print('Sending '+args.skill+' skill level '+str(args.skillLevelPercent)+' for '+nickname)
@@ -1270,12 +1270,12 @@ if args.availability:
     if not nickname:
         print('Specify a nickname with the --nickname option')
         sys.exit()
-        
+
     if not args.password:
         print('Specify a password with the --password option')
         sys.exit()
 
-    session=createSession(useTor)        
+    session=createSession(useTor)
     personCache={}
     cachedWebfingers={}
     print('Sending availability status of '+nickname+' as '+args.availability)
@@ -1305,7 +1305,7 @@ if args.block:
     if not nickname:
         print('Specify a nickname with the --nickname option')
         sys.exit()
-        
+
     if not args.password:
         print('Specify a password with the --password option')
         sys.exit()
@@ -1320,7 +1320,7 @@ if args.block:
             print(args.block+' does not look like an actor url')
             sys.exit()
 
-    session=createSession(useTor)        
+    session=createSession(useTor)
     personCache={}
     cachedWebfingers={}
     print('Sending block of '+args.block)
@@ -1339,7 +1339,7 @@ if args.delegate:
     if not nickname:
         print('Specify a nickname with the --nickname option')
         sys.exit()
-        
+
     if not args.password:
         print('Specify a password with the --password option')
         sys.exit()
@@ -1356,7 +1356,7 @@ if args.delegate:
         delegatedNickname=args.delegate.split('@')[0]
         args.delegate=blockedActor
 
-    session=createSession(useTor)        
+    session=createSession(useTor)
     personCache={}
     cachedWebfingers={}
     print('Sending delegation for '+args.delegate+' with role '+args.role+' in project '+args.project)
@@ -1377,7 +1377,7 @@ if args.undelegate:
     if not nickname:
         print('Specify a nickname with the --nickname option')
         sys.exit()
-        
+
     if not args.password:
         print('Specify a password with the --password option')
         sys.exit()
@@ -1390,7 +1390,7 @@ if args.undelegate:
         delegatedNickname=args.undelegate.split('@')[0]
         args.undelegate=blockedActor
 
-    session=createSession(useTor)        
+    session=createSession(useTor)
     personCache={}
     cachedWebfingers={}
     print('Sending delegation removal for '+args.undelegate+' from role '+args.role+' in project '+args.project)
@@ -1411,7 +1411,7 @@ if args.unblock:
     if not nickname:
         print('Specify a nickname with the --nickname option')
         sys.exit()
-        
+
     if not args.password:
         print('Specify a password with the --password option')
         sys.exit()
@@ -1426,7 +1426,7 @@ if args.unblock:
             print(args.unblock+' does not look like an actor url')
             sys.exit()
 
-    session=createSession(useTor)        
+    session=createSession(useTor)
     personCache={}
     cachedWebfingers={}
     print('Sending undo block of '+args.unblock)
@@ -1458,7 +1458,7 @@ if args.unfilterStr:
     sys.exit()
 
 if args.testdata:
-    useBlurhash=False    
+    useBlurhash=False
     nickname='testuser567'
     password='boringpassword'
     print('Generating some test data for user: '+nickname)
@@ -1475,7 +1475,7 @@ if args.testdata:
         shutil.rmtree(baseDir+'/sharefiles')
     if os.path.isdir(baseDir+'/wfendpoints'):
         shutil.rmtree(baseDir+'/wfendpoints')
-    
+
     setConfigParam(baseDir,'registrationsRemaining',str(maxRegistrations))
 
     createPerson(baseDir,'maxboardroom',domain,port,httpPrefix,True,password)
@@ -1511,7 +1511,7 @@ if args.testdata:
              "City", \
              "3 months",
              debug)
-    
+
     deleteAllPosts(baseDir,nickname,domain,'inbox')
     deleteAllPosts(baseDir,nickname,domain,'outbox')
     createPublicPost(baseDir,nickname,domain,port,httpPrefix,"like, this is totally just a #test, man",False,True,False,None,None,useBlurhash)

+ 0 - 1
filters.py

@@ -74,4 +74,3 @@ def isFiltered(baseDir: str,nickname: str,domain: str,content: str) -> bool:
                             return False
                     return True
     return False
-

+ 22 - 22
follow.py

@@ -88,7 +88,7 @@ def isFollowingActor(baseDir: str,nickname: str,domain: str,actor: str) -> bool:
     handle=nickname+'@'+domain
     if not os.path.isdir(baseDir+'/accounts/'+handle):
         return False
-    followingFile=baseDir+'/accounts/'+handle+'/following.txt'    
+    followingFile=baseDir+'/accounts/'+handle+'/following.txt'
     if not os.path.isfile(followingFile):
         return False
     if actor in open(followingFile).read():
@@ -284,7 +284,7 @@ def getFollowingFeed(baseDir: str,domain: str,port: int,path: str, \
         return None
     # handle page numbers
     headerOnly=True
-    pageNumber=None    
+    pageNumber=None
     if '?page=' in path:
         pageNumber=path.split('?page=')[1]
         if pageNumber=='true' or not authenticated:
@@ -296,7 +296,7 @@ def getFollowingFeed(baseDir: str,domain: str,port: int,path: str, \
                 pass
         path=path.split('?page=')[0]
         headerOnly=False
-    
+
     if not path.endswith('/'+followFile):
         return None
     nickname=None
@@ -495,7 +495,7 @@ def receiveFollowRequest(session,baseDir: str,httpPrefix: str, \
        '/channel/' not in messageJson['actor'] and \
        '/profile/' not in messageJson['actor']:
         if debug:
-            print('DEBUG: "users" or "profile" missing from actor')            
+            print('DEBUG: "users" or "profile" missing from actor')
         return False
     domain,tempPort=getDomainFromActor(messageJson['actor'])
     fromPort=port
@@ -534,7 +534,7 @@ def receiveFollowRequest(session,baseDir: str,httpPrefix: str, \
     if tempPort:
         if tempPort!=80 and tempPort!=443:
             if ':' not in domainToFollow:
-                domainToFollowFull=domainToFollow+':'+str(tempPort)            
+                domainToFollowFull=domainToFollow+':'+str(tempPort)
     nicknameToFollow=getNicknameFromActor(messageJson['object'])
     if not nicknameToFollow:
         if debug:
@@ -547,7 +547,7 @@ def receiveFollowRequest(session,baseDir: str,httpPrefix: str, \
                 print('DEBUG: followed account not found - '+ \
                       baseDir+'/accounts/'+handleToFollow)
             return True
-        
+
     if isFollowerOfPerson(baseDir, \
                           nicknameToFollow,domainToFollowFull, \
                           nickname,domainFull):
@@ -556,13 +556,13 @@ def receiveFollowRequest(session,baseDir: str,httpPrefix: str, \
                   ' is already a follower of '+ \
                   nicknameToFollow+'@'+domainToFollow)
         return True
-    
+
     # what is the followers policy?
-    approveHandle=nickname+'@'+domainFull    
+    approveHandle=nickname+'@'+domainFull
     if followApprovalRequired(baseDir,nicknameToFollow, \
                               domainToFollow,debug,approveHandle):
         print('Follow approval is required')
-        if not domain.endswith('.onion'):            
+        if not domain.endswith('.onion'):
             if noOfFollowRequests(baseDir, \
                                   nicknameToFollow,domainToFollow, \
                                   nickname,domain,fromPort, \
@@ -730,10 +730,10 @@ def sendFollowRequest(session,baseDir: str, \
                       personCache: {},debug : bool, \
                       projectVersion: str) -> {}:
     """Gets the json object for sending a follow request
-    """    
+    """
     if not domainPermitted(followDomain,federationList):
         return None
-    
+
     fullDomain=domain
     followActor=httpPrefix+'://'+domain+'/users/'+nickname
     if port:
@@ -749,7 +749,7 @@ def sendFollowRequest(session,baseDir: str, \
                 requestDomain=followDomain+':'+str(followPort)
 
     statusNumber,published=getStatusNumber()
-    
+
     if followNickname:
         followedId=followHttpPrefix+'://'+requestDomain+'/users/'+followNickname
         followHandle=followNickname+'@'+requestDomain
@@ -812,7 +812,7 @@ def sendFollowRequestViaServer(baseDir: str,session, \
             if ':' not in followDomain:
                 followDomainFull=followDomain+':'+str(followPort)
 
-    followActor=httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname    
+    followActor=httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname
     followedId=httpPrefix+'://'+followDomainFull+'/users/'+followNickname
 
     statusNumber,published=getStatusNumber()
@@ -842,7 +842,7 @@ def sendFollowRequestViaServer(baseDir: str,session, \
         getPersonBox(baseDir,session,wfRequest,personCache, \
                      projectVersion,httpPrefix,fromNickname, \
                      fromDomain,postToBox)
-                     
+
     if not inboxUrl:
         if debug:
             print('DEBUG: No '+postToBox+' was found for '+handle)
@@ -851,9 +851,9 @@ def sendFollowRequestViaServer(baseDir: str,session, \
         if debug:
             print('DEBUG: No actor was found for '+handle)
         return 4
-    
+
     authHeader=createBasicAuthHeader(fromNickname,password)
-     
+
     headers={
         'host': fromDomain, \
         'Content-type': 'application/json', \
@@ -895,7 +895,7 @@ def sendUnfollowRequestViaServer(baseDir: str,session, \
             if ':' not in followDomain:
                 followDomainFull=followDomain+':'+str(followPort)
 
-    followActor=httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname    
+    followActor=httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname
     followedId=httpPrefix+'://'+followDomainFull+'/users/'+followNickname
     statusNumber,published=getStatusNumber()
 
@@ -930,7 +930,7 @@ def sendUnfollowRequestViaServer(baseDir: str,session, \
         getPersonBox(baseDir,session,wfRequest,personCache, \
                      projectVersion,httpPrefix,fromNickname, \
                      fromDomain,postToBox)
-                     
+
     if not inboxUrl:
         if debug:
             print('DEBUG: No '+postToBox+' was found for '+handle)
@@ -939,9 +939,9 @@ def sendUnfollowRequestViaServer(baseDir: str,session, \
         if debug:
             print('DEBUG: No actor was found for '+handle)
         return 4
-    
+
     authHeader=createBasicAuthHeader(fromNickname,password)
-     
+
     headers={
         'host': fromDomain, \
         'Content-type': 'application/json', \
@@ -1008,7 +1008,7 @@ def getFollowersOfActor(baseDir :str,actor :str,debug: bool) -> {}:
                                 if ocapJson.get('id'):
                                     if debug:
                                         print('DEBUG: capabilities id found for '+account)
-                
+
                                     recipientsDict[account]=ocapJson['id']
                                 else:
                                     if debug:
@@ -1058,7 +1058,7 @@ def outboxUndoFollow(baseDir: str,messageJson: {},debug: bool) -> None:
         if portFollower!=80 and portFollower!=443:
             if ':' not in domainFollower:
                 domainFollowerFull=domainFollower+':'+str(portFollower)
-    
+
     nicknameFollowing=getNicknameFromActor(messageJson['object']['object'])
     if not nicknameFollowing:
         print('WARN: unable to find nickname in '+messageJson['object']['object'])

+ 7 - 7
happening.py

@@ -67,7 +67,7 @@ def getTodaysEvents(baseDir: str,nickname: str,domain: str, \
 
     calendarPostIds=[]
     recreateEventsFile=False
-    with open(calendarFilename,'r') as eventsFile: 
+    with open(calendarFilename,'r') as eventsFile:
         for postId in eventsFile:
             postId=postId.replace('\n','')
             postFilename=locatePost(baseDir,nickname,domain,postId)
@@ -134,7 +134,7 @@ def todaysEventsCheck(baseDir: str,nickname: str,domain: str) -> bool:
         return False
 
     eventsExist=False
-    with open(calendarFilename,'r') as eventsFile: 
+    with open(calendarFilename,'r') as eventsFile:
         for postId in eventsFile:
             postId=postId.replace('\n','')
             postFilename=locatePost(baseDir,nickname,domain,postId)
@@ -180,7 +180,7 @@ def thisWeeksEventsCheck(baseDir: str,nickname: str,domain: str) -> bool:
         return False
 
     eventsExist=False
-    with open(calendarFilename,'r') as eventsFile: 
+    with open(calendarFilename,'r') as eventsFile:
         for postId in eventsFile:
             postId=postId.replace('\n','')
             postFilename=locatePost(baseDir,nickname,domain,postId)
@@ -207,7 +207,7 @@ def thisWeeksEventsCheck(baseDir: str,nickname: str,domain: str) -> bool:
                    int(eventTime.strftime("%m"))==monthNumber and \
                    (int(eventTime.strftime("%d"))>dayNumber and \
                     int(eventTime.strftime("%d"))<=dayNumber+6):
-                    eventsExist=True                            
+                    eventsExist=True
                     break
 
     return eventsExist
@@ -233,7 +233,7 @@ def getThisWeeksEvents(baseDir: str,nickname: str,domain: str) -> {}:
 
     calendarPostIds=[]
     recreateEventsFile=False
-    with open(calendarFilename,'r') as eventsFile: 
+    with open(calendarFilename,'r') as eventsFile:
         for postId in eventsFile:
             postId=postId.replace('\n','')
             postFilename=locatePost(baseDir,nickname,domain,postId)
@@ -317,7 +317,7 @@ def getCalendarEvents(baseDir: str,nickname: str,domain: str, \
 
     calendarPostIds=[]
     recreateEventsFile=False
-    with open(calendarFilename,'r') as eventsFile: 
+    with open(calendarFilename,'r') as eventsFile:
         for postId in eventsFile:
             postId=postId.replace('\n','')
             postFilename=locatePost(baseDir,nickname,domain,postId)
@@ -362,7 +362,7 @@ def getCalendarEvents(baseDir: str,nickname: str,domain: str, \
         for postId in calendarPostIds:
             calendarFile.write(postId+'\n')
         calendarFile.close()
-    
+
     return events
 
 def removeCalendarEvent(baseDir: str,nickname: str,domain: str, \

+ 2 - 2
httpsig.py

@@ -9,7 +9,7 @@ __status__="Production"
 
 # see https://tools.ietf.org/html/draft-cavage-http-signatures-06
 
-try: 
+try:
     from Cryptodome.PublicKey import RSA
     from Cryptodome.Hash import SHA256
     from Cryptodome.Signature import pkcs1_15
@@ -175,7 +175,7 @@ def verifyPostHeaders(httpPrefix: str,publicKeyPem: str,headers: dict, \
 
     if debug:
         print('DEBUG: verifyPostHeaders '+method)
-        
+
     publicKeyPem=RSA.import_key(publicKeyPem)
     # Build a dictionary of the signature values
     signatureHeader=headers['signature']

+ 46 - 46
inbox.py

@@ -79,7 +79,7 @@ def storeHashTags(baseDir: str,nickname: str,postJsonObject: {}) -> None:
         return
     if not isinstance(postJsonObject['object']['tag'], list):
         return
-    tagsDir=baseDir+'/tags'    
+    tagsDir=baseDir+'/tags'
     for tag in postJsonObject['object']['tag']:
         if not tag.get('type'):
             continue
@@ -149,7 +149,7 @@ def validInbox(baseDir: str,nickname: str,domain: str) -> bool:
             if 'postNickname' in open(filename).read():
                 print('queue file incorrectly saved to '+filename)
                 return False
-    return True    
+    return True
 
 def validInboxFilenames(baseDir: str,nickname: str,domain: str, \
                         expectedDomain: str,expectedPort: int) -> bool:
@@ -172,7 +172,7 @@ def validInboxFilenames(baseDir: str,nickname: str,domain: str, \
                 print('Expected: '+expectedStr)
                 print('Invalid filename: '+filename)
                 return False
-    return True    
+    return True
 
 def getPersonPubKey(baseDir: str,session,personUrl: str, \
                     personCache: {},debug: bool, \
@@ -184,7 +184,7 @@ def getPersonPubKey(baseDir: str,session,personUrl: str, \
     if personUrl.endswith('/users/inbox'):
         if debug:
             print('DEBUG: Obtaining public key for shared inbox')
-        personUrl=personUrl.replace('/users/inbox','/inbox')        
+        personUrl=personUrl.replace('/users/inbox','/inbox')
     personJson=getPersonFromCache(baseDir,personUrl,personCache)
     if not personJson:
         if debug:
@@ -345,9 +345,9 @@ def savePostToInboxQueue(baseDir: str,httpPrefix: str, \
             postId=actor+'/statuses/'+statusNumber
         else:
             postId=httpPrefix+'://'+originalDomain+'/users/'+nickname+'/statuses/'+statusNumber
-    
+
     # NOTE: don't change postJsonObject['id'] before signature check
-    
+
     inboxQueueDir=createInboxQueueDir(nickname,domain,baseDir)
 
     handle=nickname+'@'+domain
@@ -418,7 +418,7 @@ def inboxCheckCapabilities(baseDir :str,nickname :str,domain :str, \
         return False
 
     oc=loadJson(ocapFilename)
-    if not oc: 
+    if not oc:
         return False
 
     if not oc.get('id'):
@@ -533,7 +533,7 @@ def inboxPostRecipients(baseDir :str,postJsonObject :{}, \
 
     actor=postJsonObject['actor']
     # first get any specific people which the post is addressed to
-    
+
     followerRecipients=False
     if postJsonObject.get('object'):
         if isinstance(postJsonObject['object'], dict):
@@ -649,7 +649,7 @@ def receiveUndoFollow(session,baseDir: str,httpPrefix: str, \
         if portFollower!=80 and portFollower!=443:
             if ':' not in domainFollower:
                 domainFollowerFull=domainFollower+':'+str(portFollower)
-    
+
     nicknameFollowing=getNicknameFromActor(messageJson['object']['object'])
     if not nicknameFollowing:
         print('WARN: unable to find nickname in '+messageJson['object']['object'])
@@ -668,7 +668,7 @@ def receiveUndoFollow(session,baseDir: str,httpPrefix: str, \
         if debug:
             print('DEBUG: Follower '+nicknameFollower+'@'+domainFollowerFull+' was removed')
         return True
-    
+
     if debug:
         print('DEBUG: Follower '+nicknameFollower+'@'+domainFollowerFull+' was not removed')
     return False
@@ -693,7 +693,7 @@ def receiveUndo(session,baseDir: str,httpPrefix: str, \
        '/channel/' not in messageJson['actor'] and \
        '/profile/' not in messageJson['actor']:
         if debug:
-            print('DEBUG: "users" or "profile" missing from actor')            
+            print('DEBUG: "users" or "profile" missing from actor')
         return False
     if not messageJson.get('object'):
         if debug:
@@ -755,11 +755,11 @@ def personReceiveUpdate(baseDir: str, \
         return False
     if not personJson.get('publicKey'):
         if debug:
-            print('DEBUG: actor update does not contain a public key')        
+            print('DEBUG: actor update does not contain a public key')
         return False
     if not personJson['publicKey'].get('publicKeyPem'):
         if debug:
-            print('DEBUG: actor update does not contain a public key Pem')        
+            print('DEBUG: actor update does not contain a public key Pem')
         return False
     actorFilename=baseDir+'/cache/actors/'+personJson['id'].replace('/','#')+'.json'
     # check that the public keys match.
@@ -824,7 +824,7 @@ def receiveUpdateToQuestion(recentPostsCache: {},messageJson: {}, \
             os.remove(cachedPostFilename)
     # remove from memory cache
     removePostFromCache(messageJson,recentPostsCache)
-                            
+
 def receiveUpdate(recentPostsCache: {},session,baseDir: str, \
                   httpPrefix: str,domain :str,port: int, \
                   sendThreads: [],postLog: [],cachedWebfingers: {}, \
@@ -878,7 +878,7 @@ def receiveUpdate(recentPostsCache: {},session,baseDir: str, \
                     if debug:
                         print('DEBUG: Unwrapped profile update was received for '+messageJson['url'])
                         return True
-    
+
     if messageJson['object']['type']=='Person' or \
        messageJson['object']['type']=='Application' or \
        messageJson['object']['type']=='Group' or \
@@ -1056,11 +1056,11 @@ def receiveBookmark(recentPostsCache: {}, \
     if domain not in handle.split('@')[1]:
         if debug:
             print('DEBUG: unrecognized domain '+handle)
-        return False        
+        return False
     domainFull=domain
     if port:
         if port!=80 and port!=443:
-            domainFull=domain+':'+str(port)            
+            domainFull=domain+':'+str(port)
     nickname=handle.split('@')[0]
     if not messageJson['actor'].endswith(domainFull+'/users/'+nickname):
         if debug:
@@ -1121,12 +1121,12 @@ def receiveUndoBookmark(recentPostsCache: {}, \
     domainFull=domain
     if port:
         if port!=80 and port!=443:
-            domainFull=domain+':'+str(port)            
+            domainFull=domain+':'+str(port)
     nickname=handle.split('@')[0]
     if domain not in handle.split('@')[1]:
         if debug:
             print('DEBUG: unrecognized bookmark domain '+handle)
-        return False        
+        return False
     if not messageJson['actor'].endswith(domainFull+'/users/'+nickname):
         if debug:
             print('DEBUG: bookmark actor should be the same as the handle sent to '+handle+' != '+messageJson['actor'])
@@ -1180,7 +1180,7 @@ def receiveDelete(session,handle: str,isGroup: bool,baseDir: str, \
         not messageJson['actor'].startswith(deletePrefix)):
         if debug:
             print('DEBUG: delete not permitted from other instances')
-        return False        
+        return False
     if not messageJson.get('to'):
         if debug:
             print('DEBUG: '+messageJson['type']+' has no "to" list')
@@ -1197,9 +1197,9 @@ def receiveDelete(session,handle: str,isGroup: bool,baseDir: str, \
         return False
     if messageJson['actor'] not in messageJson['object']:
         if debug:
-            print('DEBUG: actor is not the owner of the post to be deleted')    
+            print('DEBUG: actor is not the owner of the post to be deleted')
     if not os.path.isdir(baseDir+'/accounts/'+handle):
-        print('DEBUG: unknown recipient of like - '+handle)    
+        print('DEBUG: unknown recipient of like - '+handle)
     # if this post in the outbox of the person?
     messageId=messageJson['object'].replace('/activity','').replace('/undo','')
     removeModerationPostFromIndex(baseDir,messageId,debug)
@@ -1227,7 +1227,7 @@ def receiveAnnounce(recentPostsCache: {}, \
     if '@' not in handle:
         if debug:
             print('DEBUG: bad handle '+handle)
-        return False        
+        return False
     if not messageJson.get('actor'):
         if debug:
             print('DEBUG: '+messageJson['type']+' has no actor')
@@ -1308,7 +1308,7 @@ def receiveAnnounce(recentPostsCache: {}, \
                         getPersonPubKey(baseDir,session,lookupActor, \
                                         personCache,debug, \
                                         __version__,httpPrefix, \
-                                        domain,onionDomain)                
+                                        domain,onionDomain)
                     if pubKey:
                         print('DEBUG: public key obtained for announce: '+lookupActor)
                         break
@@ -1316,7 +1316,7 @@ def receiveAnnounce(recentPostsCache: {}, \
                     if debug:
                         print('DEBUG: Retry '+str(tries+1)+ \
                               ' obtaining actor for '+lookupActor)
-                    time.sleep(5)                
+                    time.sleep(5)
     if debug:
         print('DEBUG: announced/repeated post arrived in inbox')
     return True
@@ -1342,7 +1342,7 @@ def receiveUndoAnnounce(recentPostsCache: {}, \
     if not isinstance(messageJson['object']['object'], str):
         return False
     if messageJson['object']['type']!='Announce':
-        return False    
+        return False
     if '/users/' not in messageJson['actor'] and \
        '/channel/' not in messageJson['actor'] and \
        '/profile/' not in messageJson['actor']:
@@ -1367,7 +1367,7 @@ def receiveUndoAnnounce(recentPostsCache: {}, \
             if postJsonObject['type']!='Announce':
                 if debug:
                     print("DEBUG: Attempt to undo something which isn't an announcement")
-                return False        
+                return False
     undoAnnounceCollectionEntry(recentPostsCache,baseDir,postFilename, \
                                 messageJson['actor'],domain,debug)
     if os.path.isfile(postFilename):
@@ -1376,7 +1376,7 @@ def receiveUndoAnnounce(recentPostsCache: {}, \
 
 def populateReplies(baseDir :str,httpPrefix :str,domain :str, \
                     messageJson :{},maxReplies: int,debug :bool) -> bool:
-    """Updates the list of replies for a post on this domain if 
+    """Updates the list of replies for a post on this domain if
     a reply to it arrives
     """
     if not messageJson.get('id'):
@@ -1412,7 +1412,7 @@ def populateReplies(baseDir :str,httpPrefix :str,domain :str, \
     if not postFilename:
         if debug:
             print('DEBUG: post may have expired - '+replyTo)
-        return False    
+        return False
     # populate a text file containing the ids of replies
     postRepliesFilename=postFilename.replace('.json','.replies')
     messageId=messageJson['id'].replace('/activity','').replace('/undo','')
@@ -1461,7 +1461,7 @@ def validPostContent(baseDir: str,nickname: str,domain: str, \
     if 'Z' not in messageJson['object']['published']:
         return False
     # check for bad html
-    invalidStrings=['<script>','<canvas>','<style>','</html>','</body>','<br>','<hr>']    
+    invalidStrings=['<script>','<canvas>','<style>','</html>','</body>','<br>','<hr>']
     for badStr in invalidStrings:
         if badStr in messageJson['object']['content']:
             if messageJson['object'].get('id'):
@@ -1504,7 +1504,7 @@ def obtainAvatarForReplyPost(session,baseDir: str,httpPrefix: str, \
     """
     if not postJsonObject.get('object'):
         return
-    
+
     if not isinstance(postJsonObject['object'], dict):
         return
 
@@ -1522,7 +1522,7 @@ def obtainAvatarForReplyPost(session,baseDir: str,httpPrefix: str, \
 
     if '/statuses/' in lookupActor:
         lookupActor=lookupActor.split('/statuses/')[0]
-            
+
     if debug:
         print('DEBUG: Obtaining actor for reply post '+lookupActor)
 
@@ -1531,7 +1531,7 @@ def obtainAvatarForReplyPost(session,baseDir: str,httpPrefix: str, \
             getPersonPubKey(baseDir,session,lookupActor, \
                             personCache,debug, \
                             __version__,httpPrefix, \
-                            domain,onionDomain)                
+                            domain,onionDomain)
         if pubKey:
             print('DEBUG: public key obtained for reply: '+lookupActor)
             break
@@ -1539,7 +1539,7 @@ def obtainAvatarForReplyPost(session,baseDir: str,httpPrefix: str, \
         if debug:
             print('DEBUG: Retry '+str(tries+1)+ \
                   ' obtaining actor for '+lookupActor)
-        time.sleep(5)                
+        time.sleep(5)
 
 def dmNotify(baseDir: str,handle: str,url: str) -> None:
     """Creates a notification that a new DM has arrived
@@ -1687,7 +1687,7 @@ def inboxUpdateCalendar(baseDir: str,handle: str,postJsonObject: {}) -> None:
         if not tagDict.get('startTime'):
             continue
         # get the year and month from the event
-        eventTime=datetime.datetime.strptime(tagDict['startTime'],"%Y-%m-%dT%H:%M:%S%z")            
+        eventTime=datetime.datetime.strptime(tagDict['startTime'],"%Y-%m-%dT%H:%M:%S%z")
         eventYear=int(eventTime.strftime("%Y"))
         eventMonthNumber=int(eventTime.strftime("%m"))
         eventDayOfMonth=int(eventTime.strftime("%d"))
@@ -1819,7 +1819,7 @@ def inboxAfterCapabilities(recentPostsCache: {},maxRecentPosts: int, \
         if debug:
             print('DEBUG: Undo bookmark accepted from '+actor)
         return False
-    
+
     if receiveAnnounce(recentPostsCache, \
                        session,handle,isGroup, \
                        baseDir,httpPrefix, \
@@ -2004,7 +2004,7 @@ def runInboxQueueWatchdog(projectVersion: str,httpd) -> None:
     #httpd.thrInboxQueue=inboxQueueOriginal
     httpd.thrInboxQueue.start()
     while True:
-        time.sleep(20) 
+        time.sleep(20)
         if not httpd.thrInboxQueue.isAlive():
             httpd.thrInboxQueue.kill()
             httpd.thrInboxQueue=inboxQueueOriginal.clone(runInboxQueue)
@@ -2068,7 +2068,7 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
             if not session or currTime-sessionLastUpdate>1200:
                 print('Creating inbox session')
                 session=createSession(useTor)
-                sessionLastUpdate=currTime            
+                sessionLastUpdate=currTime
 
             # oldest item first
             queue.sort()
@@ -2081,7 +2081,7 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
                 continue
 
             print('Loading queue item '+queueFilename)
-            
+
             # Load the queue json
             queueJson=loadJson(queueFilename,1)
             if not queueJson:
@@ -2096,14 +2096,14 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
                     except:
                         pass
                 continue
-            
+
             # clear the daily quotas for maximum numbers of received posts
             if currTime-quotasLastUpdate>60*60*24:
                 quotas={
                     'domains': {},
                     'accounts': {}
                 }
-                quotasLastUpdate=currTime            
+                quotasLastUpdate=currTime
 
             # limit the number of posts which can arrive per domain per day
             postDomain=queueJson['postDomain']
@@ -2138,7 +2138,7 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
                         pprint(quotas)
 
             print('Obtaining public key for actor '+queueJson['actor'])
-                        
+
             # Try a few times to obtain the public key
             pubKey=None
             keyId=None
@@ -2169,7 +2169,7 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
                     if debug:
                         print('DEBUG: public key: '+str(pubKey))
                     break
-                    
+
                 if debug:
                     print('DEBUG: Retry '+str(tries+1)+ \
                           ' obtaining public key for '+keyId)
@@ -2210,7 +2210,7 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
             # This makes the filename and the id consistent
             #if queueJson['post'].get('id'):
             #    queueJson['post']['id']=queueJson['id']
-            
+
             if receiveUndo(session, \
                            baseDir,httpPrefix,port, \
                            sendThreads,postLog, \
@@ -2344,7 +2344,7 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
                     saveJson(queueJson['post'],sharedInboxPostFilename)
 
             # for posts addressed to specific accounts
-            for handle,capsId in recipientsDict.items():              
+            for handle,capsId in recipientsDict.items():
                 destination=queueJson['destination'].replace(inboxHandle,handle)
                 # check that capabilities are accepted
                 if queueJson['post'].get('capability'):
@@ -2395,7 +2395,7 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
                         print('No capability list within post')
                         print('ocapAlways: '+str(ocapAlways))
                         print('DEBUG: object capabilities check failed')
-            
+
                 if debug:
                     print('DEBUG: Queue post accepted')
             if os.path.isfile(queueFilename):

+ 13 - 13
like.py

@@ -143,7 +143,7 @@ def updateLikesCollection(recentPostsCache: {}, \
                 'items': [{
                     'type': 'Like',
                     'actor': actor
-                }]                
+                }]
             }
             postJsonObject['object']['likes']=likesJson
         else:
@@ -225,11 +225,11 @@ def like(recentPostsCache: {}, \
             print('DEBUG: like domain: '+domain)
             print('DEBUG: like objectUrl: '+objectUrl)
             return None
-        
+
         updateLikesCollection(recentPostsCache, \
                               baseDir,postFilename,objectUrl, \
                               newLikeJson['actor'],domain,debug)
-        
+
         sendSignedJson(newLikeJson,session,baseDir, \
                        nickname,domain,port, \
                        likedPostNickname,likedPostDomain,likedPostPort, \
@@ -338,7 +338,7 @@ def undolike(recentPostsCache: {}, \
 
         undoLikesCollectionEntry(baseDir,postFilename,objectUrl, \
                                  newLikeJson['actor'],domain,debug)
-        
+
         sendSignedJson(newUndoLikeJson,session,baseDir, \
                        nickname,domain,port, \
                        likedPostNickname,likedPostDomain,likedPostPort, \
@@ -379,7 +379,7 @@ def undoLikePost(recentPostsCache: {}, \
                 ccUrl= \
                     httpPrefix+'://'+likeDomain+':'+ \
                     str(likePort)+'/users/'+likeNickname
-        
+
     return undoLike(recentPostsCache, \
                     session,baseDir,federationList,nickname,domain,port, \
                     ccList,httpPrefix,objectUrl,clientToServer, \
@@ -408,7 +408,7 @@ def sendLikeViaServer(baseDir: str,session, \
 
     if '/statuses/' in likeUrl:
         toUrl=[likeUrl.split('/statuses/')[0]]
-    
+
     newLikeJson={
         "@context": "https://www.w3.org/ns/activitystreams",
         'type': 'Like',
@@ -433,7 +433,7 @@ def sendLikeViaServer(baseDir: str,session, \
         getPersonBox(baseDir,session,wfRequest,personCache, \
                      projectVersion,httpPrefix,fromNickname, \
                      fromDomain,postToBox)
-                     
+
     if not inboxUrl:
         if debug:
             print('DEBUG: No '+postToBox+' was found for '+handle)
@@ -442,9 +442,9 @@ def sendLikeViaServer(baseDir: str,session, \
         if debug:
             print('DEBUG: No actor was found for '+handle)
         return 4
-    
+
     authHeader=createBasicAuthHeader(fromNickname,password)
-     
+
     headers={
         'host': fromDomain, \
         'Content-type': 'application/json', \
@@ -515,7 +515,7 @@ def sendUndoLikeViaServer(baseDir: str,session, \
         getPersonBox(baseDir,session,wfRequest,personCache, \
                      projectVersion,httpPrefix,fromNickname, \
                      fromDomain,postToBox)
-                     
+
     if not inboxUrl:
         if debug:
             print('DEBUG: No '+postToBox+' was found for '+handle)
@@ -524,9 +524,9 @@ def sendUndoLikeViaServer(baseDir: str,session, \
         if debug:
             print('DEBUG: No actor was found for '+handle)
         return 4
-    
+
     authHeader=createBasicAuthHeader(fromNickname,password)
-     
+
     headers={
         'host': fromDomain, \
         'Content-type': 'application/json', \
@@ -598,7 +598,7 @@ def outboxUndoLike(baseDir: str,httpPrefix: str, \
     if not isinstance(messageJson['object'], dict):
         if debug:
             print('DEBUG: undo like object is not dict')
-        return    
+        return
     if not messageJson['object'].get('type'):
         if debug:
             print('DEBUG: undo like - no type')

+ 8 - 8
manualapprove.py

@@ -33,17 +33,17 @@ def manualDenyFollowRequest(session,baseDir: str, \
     rejectedFollowsFilename=accountsDir+'/followrejects.txt'
     if os.path.isfile(rejectedFollowsFilename):
         if denyHandle in open(rejectedFollowsFilename).read():
-            removeFromFollowRequests(baseDir,nickname,domain,denyHandle,debug)        
+            removeFromFollowRequests(baseDir,nickname,domain,denyHandle,debug)
             print(denyHandle+' has already been rejected as a follower of '+nickname)
             return
 
-    removeFromFollowRequests(baseDir,nickname,domain,denyHandle,debug)        
+    removeFromFollowRequests(baseDir,nickname,domain,denyHandle,debug)
 
     # Store rejected follows
     rejectsFile=open(rejectedFollowsFilename, "a+")
     rejectsFile.write(denyHandle+'\n')
     rejectsFile.close()
-    
+
     denyNickname=denyHandle.split('@')[0]
     denyDomain=denyHandle.split('@')[1].replace('\n','')
     denyPort=port
@@ -59,11 +59,11 @@ def manualDenyFollowRequest(session,baseDir: str, \
                            debug,projectVersion)
 
     print('Follow request from '+denyHandle+' was denied.')
-    
+
 def approveFollowerHandle(accountDir: str,approveHandle: str) -> None:
     """ Record manually approved handles so that if they unfollow and then
      re-follow later then they don't need to be manually approved again
-    """    
+    """
     approvedFilename=accountDir+'/approved.txt'
     if os.path.isfile(approvedFilename):
         if approveHandle not in open(approvedFilename).read():
@@ -73,8 +73,8 @@ def approveFollowerHandle(accountDir: str,approveHandle: str) -> None:
     else:
         approvedFile=open(approvedFilename, "w+")
         approvedFile.write(approveHandle+'\n')
-        approvedFile.close()    
-    
+        approvedFile.close()
+
 def manualApproveFollowRequest(session,baseDir: str, \
                                httpPrefix: str,
                                nickname: str,domain: str,port: int, \
@@ -98,7 +98,7 @@ def manualApproveFollowRequest(session,baseDir: str, \
     if approveHandle not in open(approveFollowsFilename).read():
         print('Manual follow accept: '+approveHandle+' not in requests file '+approveFollowsFilename)
         return
-    
+
     approvefilenew=open(approveFollowsFilename+'.new', 'w+')
     updateApprovedFollowers=False
     followActivityfilename=None

+ 6 - 6
media.py

@@ -49,13 +49,13 @@ def getImageHash(imageFilename: str) -> str:
 
 def isMedia(imageFilename: str) -> bool:
     permittedMedia=['png','jpg','gif','webp','mp4','ogv','mp3','ogg']
-    for m in permittedMedia:        
+    for m in permittedMedia:
         if imageFilename.endswith('.'+m):
             return True
     print('WARN: '+imageFilename+' is not a permitted media type')
     return False
 
-def createMediaDirs(baseDir: str,mediaPath: str) -> None:    
+def createMediaDirs(baseDir: str,mediaPath: str) -> None:
     if not os.path.isdir(baseDir+'/media'):
         os.mkdir(baseDir+'/media')
     if not os.path.isdir(baseDir+'/'+mediaPath):
@@ -100,7 +100,7 @@ def updateEtag(mediaFilename: str) -> None:
     data=None
     try:
         with open(mediaFilename, 'rb') as mediaFile:
-            data=mediaFile.read()                
+            data=mediaFile.read()
     except:
         pass
 
@@ -125,7 +125,7 @@ def attachMedia(baseDir: str,httpPrefix: str,domain: str,port: int, \
     """
     if not isMedia(imageFilename):
         return postJson
-    
+
     fileExtension=None
     acceptedTypes=['png','jpg','gif','webp','mp4','webm','ogv','mp3','ogg']
     for mType in acceptedTypes:
@@ -135,7 +135,7 @@ def attachMedia(baseDir: str,httpPrefix: str,domain: str,port: int, \
             if mType=='mp3':
                 mType='mpeg'
             fileExtension=mType
-    if not fileExtension:        
+    if not fileExtension:
         return postJson
     mediaType=mediaType+'/'+fileExtension
     print('Attached media type: '+mediaType)
@@ -189,7 +189,7 @@ def archiveMedia(baseDir: str,archiveDirectory: str,maxWeeks=4) -> None:
             os.mkdir(archiveDirectory)
         if not os.path.isdir(archiveDirectory+'/media'):
             os.mkdir(archiveDirectory+'/media')
-    
+
     for subdir, dirs, files in os.walk(baseDir+'/media'):
         for weekDir in dirs:
             if int(weekDir)<minWeek:

+ 2 - 2
metadata.py

@@ -58,7 +58,7 @@ def metaDataInstance(instanceTitle: str, \
     isBot=False
     if adminActor['type']!='Person':
         isBot=True
-        
+
     instance={
         'approval_required': False,
         'contact_account': {
@@ -98,5 +98,5 @@ def metaDataInstance(instanceTitle: str, \
         'urls': {},
         'version': version
     }
-    
+
     return instance

+ 1 - 1
outbox.py

@@ -272,7 +272,7 @@ def postMessageToOutbox(messageJson: {},postToNickname: str, \
                        messageJson,debug)
 
     if debug:
-        print('DEBUG: handle delete requests')        
+        print('DEBUG: handle delete requests')
     outboxDelete(baseDir,httpPrefix, \
                  postToNickname,domain, \
                  messageJson,debug, \

+ 16 - 16
person.py

@@ -39,7 +39,7 @@ from utils import loadJson
 from utils import saveJson
 from auth import createPassword
 from config import setConfigParam
-from config import getConfigParam    
+from config import getConfigParam
 
 def generateRSAKey() -> (str,str):
     key=RSA.generate(2048)
@@ -85,7 +85,7 @@ def setProfileImage(baseDir: str,httpPrefix :str,nickname: str,domain: str, \
         iconFilenameBase='icon'
     else:
         iconFilenameBase='image'
-        
+
     mediaType='image/png'
     iconFilename=iconFilenameBase+'.png'
     if imageFilename.endswith('.jpg') or \
@@ -103,7 +103,7 @@ def setProfileImage(baseDir: str,httpPrefix :str,nickname: str,domain: str, \
         personJson[iconFilenameBase]['url']= \
             httpPrefix+'://'+fullDomain+'/users/'+nickname+'/'+iconFilename
         saveJson(personJson,personFilename)
-            
+
         cmd= \
             '/usr/bin/convert '+imageFilename+' -size '+ \
             resolution+' -quality 50 '+profileFilename
@@ -365,20 +365,20 @@ def createPerson(baseDir: str,nickname: str,domain: str,port: int, \
         os.mkdir(baseDir+'/accounts')
     if not os.path.isdir(baseDir+'/accounts/'+nickname+'@'+domain):
         os.mkdir(baseDir+'/accounts/'+nickname+'@'+domain)
-    
+
     if os.path.isfile(baseDir+'/img/default-avatar.png'):
         copyfile(baseDir+'/img/default-avatar.png',baseDir+'/accounts/'+nickname+'@'+domain+'/avatar.png')
     theme=getConfigParam(baseDir,'theme')
     defaultProfileImageFilename=baseDir+'/img/image.png'
     if theme:
         if os.path.isfile(baseDir+'/img/image_'+theme+'.png'):
-            defaultBannerFilename=baseDir+'/img/image_'+theme+'.png'        
+            defaultBannerFilename=baseDir+'/img/image_'+theme+'.png'
     if os.path.isfile(defaultProfileImageFilename):
         copyfile(defaultProfileImageFilename,baseDir+'/accounts/'+nickname+'@'+domain+'/image.png')
     defaultBannerFilename=baseDir+'/img/banner.png'
     if theme:
         if os.path.isfile(baseDir+'/img/banner_'+theme+'.png'):
-            defaultBannerFilename=baseDir+'/img/banner_'+theme+'.png'        
+            defaultBannerFilename=baseDir+'/img/banner_'+theme+'.png'
     if os.path.isfile(defaultBannerFilename):
         copyfile(defaultBannerFilename,baseDir+'/accounts/'+nickname+'@'+domain+'/banner.png')
     if remainingConfigExists:
@@ -405,7 +405,7 @@ def personUpgradeActor(baseDir: str,personJson: {},handle: str,filename: str) ->
     if not os.path.isfile(filename):
         print('WARN: actor file not found '+filename)
         return
-    if not personJson:        
+    if not personJson:
         personJson=loadJson(filename)
     if not personJson.get('nomadicLocations'):
         personJson['nomadicLocations']=[{
@@ -415,7 +415,7 @@ def personUpgradeActor(baseDir: str,personJson: {},handle: str,filename: str) ->
             'locationPrimary':True,
             'locationDeleted':False
         }]
-        print('Nomadic locations added to to actor '+handle)        
+        print('Nomadic locations added to to actor '+handle)
         updateActor=True
 
     if updateActor:
@@ -450,7 +450,7 @@ def personLookup(domain: str,path: str,baseDir: str) -> {}:
         notPersonLookup=['/inbox','/outbox','/outboxarchive', \
                          '/followers','/following','/featured', \
                          '.png','.jpg','.gif','.mpv']
-        for ending in notPersonLookup:        
+        for ending in notPersonLookup:
             if path.endswith(ending):
                 return None
     nickname=None
@@ -494,7 +494,7 @@ def personBoxJson(recentPostsCache: {}, \
     headerOnly=True
 
     # handle page numbers
-    pageNumber=None    
+    pageNumber=None
     if '?page=' in path:
         pageNumber=path.split('?page=')[1]
         if pageNumber=='true':
@@ -558,7 +558,7 @@ def personInboxJson(recentPostsCache: {}, \
     headerOnly=True
 
     # handle page numbers
-    pageNumber=None    
+    pageNumber=None
     if '?page=' in path:
         pageNumber=path.split('?page=')[1]
         if pageNumber=='true':
@@ -594,7 +594,7 @@ def setDisplayNickname(baseDir: str,nickname: str, domain: str, \
     if not os.path.isfile(filename):
         return False
 
-    personJson=loadJson(filename)            
+    personJson=loadJson(filename)
     if not personJson:
         return False
     personJson['name']=displayName
@@ -616,7 +616,7 @@ def setBio(baseDir: str,nickname: str, domain: str, bio: str) -> bool:
         return False
     personJson['summary']=bio
 
-    saveJson(personJson,filename)        
+    saveJson(personJson,filename)
     return True
 
 def isSuspended(baseDir: str,nickname: str) -> bool:
@@ -672,7 +672,7 @@ def suspendAccount(baseDir: str,nickname: str,domain: str) -> None:
     tokenFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/.token'
     if os.path.isfile(tokenFilename):
         os.remove(tokenFilename)
-    
+
     suspendedFilename=baseDir+'/accounts/suspended.txt'
     if os.path.isfile(suspendedFilename):
         with open(suspendedFilename, "r") as f:
@@ -746,11 +746,11 @@ def removeTagsForNickname(baseDir: str,nickname: str,domain: str,port: int) -> N
             for tagline in lines:
                 if matchStr not in tagline:
                     tagFile.write(tagline)
-            tagFile.close()                
+            tagFile.close()
 
 def removeAccount(baseDir: str,nickname: str,domain: str,port: int) -> bool:
     """Removes an account
-    """    
+    """
     # Don't remove the admin
     adminNickname=getConfigParam(baseDir,'admin')
     if nickname==adminNickname:

+ 61 - 61
posts.py

@@ -52,7 +52,7 @@ from auth import createBasicAuthHeader
 from config import getConfigParam
 from blocking import isBlocked
 from filters import isFiltered
-#try: 
+#try:
 #    from BeautifulSoup import BeautifulSoup
 #except ImportError:
 #    from bs4 import BeautifulSoup
@@ -114,7 +114,7 @@ def getPersonKey(nickname: str,domain: str,baseDir: str,keyType='public', \
             print('DEBUG: private key was too short: '+keyPem)
         return ''
     return keyPem
-    
+
 def cleanHtml(rawHtml: str) -> str:
     #text=BeautifulSoup(rawHtml, 'html.parser').get_text()
     text=rawHtml
@@ -159,8 +159,8 @@ def parseUserFeed(session,feedUrl: str,asHeader: {}, \
             userFeed=nextUrl
             if userFeed.get('orderedItems'):
                 for item in userFeed['orderedItems']:
-                    yield item        
-    
+                    yield item
+
 def getPersonBox(baseDir: str,session,wfRequest: {},personCache: {}, \
                  projectVersion: str,httpPrefix: str, \
                  nickname: str,domain: str, \
@@ -251,7 +251,7 @@ def getPosts(session,outboxUrl: str,maxPosts: int, \
              projectVersion: str,httpPrefix: str,domain: str) -> {}:
     """Gets public posts from an outbox
     """
-    personPosts={}    
+    personPosts={}
     if not outboxUrl:
         return personPosts
     asHeader={
@@ -315,7 +315,7 @@ def getPosts(session,outboxUrl: str,maxPosts: int, \
                         break
                 if not isPublic:
                     continue
-            
+
             content=item['object']['content'].replace('&apos;',"'")
 
             mentions=[]
@@ -371,7 +371,7 @@ def getPosts(session,outboxUrl: str,maxPosts: int, \
                 if item['object']['conversation']:
                     # no conversations originated in non-permitted domains
                     if urlPermitted(item['object']['conversation'], \
-                                    federationList,"objects:read"):  
+                                    federationList,"objects:read"):
                         conversation=item['object']['conversation']
 
             attachment=[]
@@ -438,7 +438,7 @@ def savePostToBox(baseDir: str,httpPrefix: str,postId: str, \
     if boxname!='inbox' and boxname!='outbox' and \
        boxname!='tlblogs' and boxname!='scheduled':
         return None
-    originalDomain=domain    
+    originalDomain=domain
     if ':' in domain:
         domain=domain.split(':')[0]
 
@@ -452,7 +452,7 @@ def savePostToBox(baseDir: str,httpPrefix: str,postId: str, \
         if isinstance(postJsonObject['object'], dict):
             postJsonObject['object']['id']=postId
             postJsonObject['object']['atomUri']=postId
-         
+
     boxDir=createPersonDir(nickname,domain,baseDir,boxname)
     filename=boxDir+'/'+postId.replace('/','#')+'.json'
     saveJson(postJsonObject,filename)
@@ -465,7 +465,7 @@ def updateHashtagsIndex(baseDir: str,tag: {},newPostId: str) -> None:
     if tag['type']!='Hashtag':
         return
 
-    # create hashtags directory    
+    # create hashtags directory
     tagsDir=baseDir+'/tags'
     if not os.path.isdir(tagsDir):
         os.mkdir(tagsDir)
@@ -514,7 +514,7 @@ def addSchedulePost(baseDir: str,nickname: str,domain: str, \
         scheduleFile=open(scheduleIndexFilename,'w')
         if scheduleFile:
             scheduleFile.write(indexStr+'\n')
-            scheduleFile.close()        
+            scheduleFile.close()
 
 def createPostBase(baseDir: str,nickname: str,domain: str,port: int, \
                    toUrl: str,ccUrl: str,httpPrefix: str,content: str, \
@@ -583,7 +583,7 @@ def createPostBase(baseDir: str,nickname: str,domain: str,port: int, \
         if not isinstance(toUrl, str):
             print('ERROR: toUrl is not a string')
             return None
-        toRecipients=[toUrl]        
+        toRecipients=[toUrl]
 
     # who to send to
     if mentionedRecipients:
@@ -656,7 +656,7 @@ def createPostBase(baseDir: str,nickname: str,domain: str,port: int, \
             'votersCount': 'toot:votersCount'
         }
     ]
-            
+
     if not clientToServer:
         actorUrl=httpPrefix+'://'+domain+'/users/'+nickname
 
@@ -714,7 +714,7 @@ def createPostBase(baseDir: str,nickname: str,domain: str,port: int, \
             newPost['object']= \
                 attachMedia(baseDir,httpPrefix,domain,port, \
                             newPost['object'],attachImageFilename, \
-                            mediaType,imageDescription,useBlurhash)            
+                            mediaType,imageDescription,useBlurhash)
     else:
         newPost={
             "@context": postContext,
@@ -750,7 +750,7 @@ def createPostBase(baseDir: str,nickname: str,domain: str,port: int, \
             newPost= \
                 attachMedia(baseDir,httpPrefix,domain,port, \
                             newPost,attachImageFilename, \
-                            mediaType,imageDescription,useBlurhash)            
+                            mediaType,imageDescription,useBlurhash)
     if ccUrl:
         if len(ccUrl)>0:
             newPost['cc']=[ccUrl]
@@ -772,7 +772,7 @@ def createPostBase(baseDir: str,nickname: str,domain: str,port: int, \
             modFile.close()
 
     if schedulePost:
-        if eventDate and eventTime:    
+        if eventDate and eventTime:
             # add an item to the scheduled post index file
             addSchedulePost(baseDir,nickname,domain,eventDateStr,newPostId)
             savePostToBox(baseDir,httpPrefix,newPostId, \
@@ -853,7 +853,7 @@ def postIsAddressedToFollowers(baseDir: str,
             toList=postJsonObject['to']
         if postJsonObject.get('cc'):
             ccList=postJsonObject['cc']
-        
+
     followersUrl=httpPrefix+'://'+domain+'/users/'+nickname+'/followers'
 
     # does the followers url exist in 'to' or 'cc' lists?
@@ -871,7 +871,7 @@ def postIsAddressedToPublic(baseDir: str,postJsonObject: {}) -> bool:
         return False
     if not postJsonObject['object'].get('to'):
         return False
-        
+
     publicUrl='https://www.w3.org/ns/activitystreams#Public'
 
     # does the public url exist in 'to' or 'cc' lists?
@@ -932,7 +932,7 @@ def createBlogPost(baseDir: str, \
                          eventDate,eventTime,location)
     blog['object']['type']='Article'
     return blog
-    
+
 
 def createQuestionPost(baseDir: str,
                        nickname: str,domain: str,port: int,httpPrefix: str, \
@@ -1017,7 +1017,7 @@ def createFollowersOnlyPost(baseDir: str,
     """
     domainFull=domain
     if port:
-        if port!=80 and port!=443: 
+        if port!=80 and port!=443:
             if ':' not in domain:
                 domainFull=domain+':'+str(port)
     return createPostBase(baseDir,nickname,domain,port, \
@@ -1167,7 +1167,7 @@ def createReportPost(baseDir: str,
     postTo=moderatorsList
     postCc=None
     postJsonObject=None
-    for toUrl in postTo:        
+    for toUrl in postTo:
         # who is this report going to?
         toNickname=toUrl.split('/users/')[1]
         handle=toNickname+'@'+domain
@@ -1187,7 +1187,7 @@ def createReportPost(baseDir: str,
         # update the inbox index with the report filename
         #indexFilename=baseDir+'/accounts/'+handle+'/inbox.index'
         #indexEntry=postJsonObject['id'].replace('/activity','').replace('/','#')+'.json'
-        #if indexEntry not in open(indexFilename).read():        
+        #if indexEntry not in open(indexFilename).read():
         #    try:
         #        with open(indexFilename, 'a+') as fp:
         #            fp.write(indexEntry)
@@ -1255,7 +1255,7 @@ def threadSendPost(session,postJsonStr: str,federationList: [],\
                   str(sendIntervalSec)+' seconds.')
         time.sleep(sendIntervalSec)
         tries+=1
-        
+
 def sendPost(projectVersion: str, \
              session,baseDir: str,nickname: str, domain: str, port: int, \
              toNickname: str, toDomain: str, toPort: int, cc: str, \
@@ -1279,7 +1279,7 @@ def sendPost(projectVersion: str, \
     if toPort:
         if toPort!=80 and toPort!=443:
             if ':' not in toDomain:
-                toDomain=toDomain+':'+str(toPort)        
+                toDomain=toDomain+':'+str(toPort)
 
     handle=httpPrefix+'://'+toDomain+'/@'+toNickname
 
@@ -1308,7 +1308,7 @@ def sendPost(projectVersion: str, \
         inboxUrl=capabilityAcquisition
         if not capabilityAcquisition:
             return 2
-                     
+
     if not inboxUrl:
         return 3
     if not pubKey:
@@ -1316,7 +1316,7 @@ def sendPost(projectVersion: str, \
     if not toPersonId:
         return 5
     # sharedInbox and capabilities are optional
-    
+
     postJsonObject= \
             createPostBase(baseDir,nickname,domain,port, \
                            toPersonId,cc,httpPrefix,content, \
@@ -1407,7 +1407,7 @@ def sendPostViaServer(projectVersion: str, \
         getPersonBox(baseDir,session,wfRequest,personCache, \
                      projectVersion,httpPrefix,fromNickname, \
                      fromDomain,postToBox)
-                     
+
     if not inboxUrl:
         if debug:
             print('DEBUG: No '+postToBox+' was found for '+handle)
@@ -1427,7 +1427,7 @@ def sendPostViaServer(projectVersion: str, \
         if fromPort:
             if fromPort!=80 and fromPort!=443:
                 if ':' not in fromDomain:
-                    fromDomainFull=fromDomain+':'+str(fromPort)                
+                    fromDomainFull=fromDomain+':'+str(fromPort)
         cc=httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname+'/followers'
     else:
         if toDomain.lower().endswith('followers') or \
@@ -1440,7 +1440,7 @@ def sendPostViaServer(projectVersion: str, \
             if toPort:
                 if toPort!=80 and toPort!=443:
                     if ':' not in toDomain:
-                        toDomainFull=toDomain+':'+str(toPort)        
+                        toDomainFull=toDomain+':'+str(toPort)
             toPersonId=httpPrefix+'://'+toDomainFull+'/users/'+toNickname
 
     postJsonObject= \
@@ -1452,7 +1452,7 @@ def sendPostViaServer(projectVersion: str, \
                            imageDescription,useBlurhash, \
                            False,isArticle,inReplyTo,inReplyToAtomUri,subject, \
                            False,None,None,None)
-    
+
     authHeader=createBasicAuthHeader(fromNickname,password)
 
     if attachImageFilename:
@@ -1467,7 +1467,7 @@ def sendPostViaServer(projectVersion: str, \
         #    if debug:
         #        print('DEBUG: Failed to upload image')
         #    return 9
-     
+
     headers={
         'host': fromDomain, \
         'Content-type': 'application/json', \
@@ -1553,7 +1553,7 @@ def sendSignedJson(postJsonObject: {},session,baseDir: str, \
 
     if toDomain.endswith('.onion'):
         httpPrefix='http'
-    
+
     sharedInbox=False
     if toNickname=='inbox':
         # shared inbox actor on @domain@domain
@@ -1564,7 +1564,7 @@ def sendSignedJson(postJsonObject: {},session,baseDir: str, \
     if toPort:
         if toPort!=80 and toPort!=443:
             if ':' not in toDomain:
-                toDomain=toDomain+':'+str(toPort)        
+                toDomain=toDomain+':'+str(toPort)
 
     handleBase=httpPrefix+'://'+toDomain+'/@'
     if toNickname:
@@ -1572,7 +1572,7 @@ def sendSignedJson(postJsonObject: {},session,baseDir: str, \
     else:
         singleUserInstanceNickname='dev'
         handle=handleBase+singleUserInstanceNickname
-        
+
     if debug:
         print('DEBUG: handle - '+handle+' toPort '+str(toPort))
 
@@ -1587,7 +1587,7 @@ def sendSignedJson(postJsonObject: {},session,baseDir: str, \
     if wfRequest.get('errors'):
         if debug:
             print('DEBUG: webfinger for '+handle+' failed with errors '+str(wfRequest['errors']))
-    
+
     if not clientToServer:
         postToBox='inbox'
     else:
@@ -1617,7 +1617,7 @@ def sendSignedJson(postJsonObject: {},session,baseDir: str, \
 
     if debug:
         print('DEBUG: Sending to endpoint '+inboxUrl)
-                     
+
     if not pubKey:
         if debug:
             print('DEBUG: missing pubkey')
@@ -1643,7 +1643,7 @@ def sendSignedJson(postJsonObject: {},session,baseDir: str, \
     postPath=inboxUrl.split(toDomain,1)[1]
 
     addFollowersToPublicPost(postJsonObject)
-    
+
     # convert json to string so that there are no
     # subsequent conversions after creating message body digest
     postJsonStr=json.dumps(postJsonObject)
@@ -1653,7 +1653,7 @@ def sendSignedJson(postJsonObject: {},session,baseDir: str, \
         createSignedHeader(privateKeyPem,nickname,domain,port, \
                            toDomain,toPort, \
                            postPath,httpPrefix,withDigest,postJsonStr)
-    
+
     # Keep the number of threads being used small
     while len(sendThreads)>1000:
         print('WARN: Maximum threads reached - killing send thread')
@@ -1684,7 +1684,7 @@ def addToField(activityType: str,postJsonObject: {},debug: bool) -> ({},bool):
     """
     if postJsonObject.get('to'):
         return postJsonObject,True
-    
+
     if debug:
         pprint(postJsonObject)
         print('DEBUG: no "to" field when sending to named addresses 2')
@@ -1751,13 +1751,13 @@ def sendToNamedAddresses(session,baseDir: str, \
                 # use the original object, which has a 'to'
                 recipientsObject=postJsonObject
                 isProfileUpdate=True
-        
+
         if not isProfileUpdate:
             if not postJsonObject['object'].get('to'):
                 if debug:
                     pprint(postJsonObject)
                     print('DEBUG: no "to" field when sending to named addresses')
-                if postJsonObject['object'].get('type'):                    
+                if postJsonObject['object'].get('type'):
                     if postJsonObject['object']['type']=='Follow':
                         if isinstance(postJsonObject['object']['object'], str):
                             if debug:
@@ -1767,7 +1767,7 @@ def sendToNamedAddresses(session,baseDir: str, \
                 if not postJsonObject['object'].get('to'):
                     return
             recipientsObject=postJsonObject['object']
-    else: 
+    else:
         post