Download posts for announce activities as they arrive

main2
Bob Mottram 2019-09-29 10:15:10 +01:00
parent 675e8a88d5
commit d11d8082e9
1 changed files with 7 additions and 0 deletions

View File

@ -43,6 +43,7 @@ from filters import isFiltered
from announce import updateAnnounceCollection from announce import updateAnnounceCollection
from httpsig import messageContentDigest from httpsig import messageContentDigest
from blocking import isBlockedDomain from blocking import isBlockedDomain
from posts import downloadAnnounce
def validInbox(baseDir: str,nickname: str,domain: str) -> bool: def validInbox(baseDir: str,nickname: str,domain: str) -> bool:
"""Checks whether files were correctly saved to the inbox """Checks whether files were correctly saved to the inbox
@ -922,6 +923,10 @@ def receiveAnnounce(session,handle: str,baseDir: str, \
""" """
if messageJson['type']!='Announce': if messageJson['type']!='Announce':
return False return False
if '@' not in handle:
if debug:
print('DEBUG: bad handle '+handle)
return False
if not messageJson.get('actor'): if not messageJson.get('actor'):
if debug: if debug:
print('DEBUG: '+messageJson['type']+' has no actor') print('DEBUG: '+messageJson['type']+' has no actor')
@ -969,6 +974,8 @@ def receiveAnnounce(session,handle: str,baseDir: str, \
print(messageJson['object']) print(messageJson['object'])
return True return True
updateAnnounceCollection(postFilename,messageJson['actor'],debug) updateAnnounceCollection(postFilename,messageJson['actor'],debug)
nickname=handle.split('@')[0]
downloadAnnounce(session,baseDir,httpPrefix,nickname,domain,messageJson,__version__)
if debug: if debug:
print('DEBUG: announced/repeated post found in inbox') print('DEBUG: announced/repeated post found in inbox')
return True return True