More verbose inbox queue processing

main
Bob Mottram 2020-03-30 20:32:25 +01:00
parent 8b4c1103e7
commit 7cfc046859
1 changed files with 26 additions and 35 deletions

View File

@ -2079,8 +2079,7 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
queue.sort() queue.sort()
queueFilename=queue[0] queueFilename=queue[0]
if not os.path.isfile(queueFilename): if not os.path.isfile(queueFilename):
if debug: print("Queue: queue item rejected because it has no file: "+queueFilename)
print("DEBUG: queue item rejected because it has no file: "+queueFilename)
if len(queue)>0: if len(queue)>0:
queue.pop(0) queue.pop(0)
continue continue
@ -2090,7 +2089,7 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
# Load the queue json # Load the queue json
queueJson=loadJson(queueFilename,1) queueJson=loadJson(queueFilename,1)
if not queueJson: if not queueJson:
print('WARN: runInboxQueue failed to load inbox queue item '+queueFilename) print('Queue: runInboxQueue failed to load inbox queue item '+queueFilename)
# Assume that the file is probably corrupt/unreadable # Assume that the file is probably corrupt/unreadable
if len(queue)>0: if len(queue)>0:
queue.pop(0) queue.pop(0)
@ -2124,7 +2123,8 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
if domainMaxPostsPerDay>0: if domainMaxPostsPerDay>0:
if quotasDaily['domains'].get(postDomain): if quotasDaily['domains'].get(postDomain):
if quotasDaily['domains'][postDomain]>domainMaxPostsPerDay: if quotasDaily['domains'][postDomain]>domainMaxPostsPerDay:
print('DEBUG: Quota per day - Maximum posts for '+postDomain+' reached ('+str(domainMaxPostsPerDay)+')') print('Queue: Quota per day - Maximum posts for '+ \
postDomain+' reached ('+str(domainMaxPostsPerDay)+')')
if len(queue)>0: if len(queue)>0:
try: try:
os.remove(queueFilename) os.remove(queueFilename)
@ -2141,7 +2141,8 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
if domainMaxPostsPerMin<10: if domainMaxPostsPerMin<10:
domainMaxPostsPerMin=10 domainMaxPostsPerMin=10
if quotasPerMin['domains'][postDomain]>domainMaxPostsPerMin: if quotasPerMin['domains'][postDomain]>domainMaxPostsPerMin:
print('DEBUG: Quota per min - Maximum posts for '+postDomain+' reached ('+str(domainMaxPostsPerMin)+')') print('Queue: Quota per min - Maximum posts for '+ \
postDomain+' reached ('+str(domainMaxPostsPerMin)+')')
if len(queue)>0: if len(queue)>0:
try: try:
os.remove(queueFilename) os.remove(queueFilename)
@ -2157,7 +2158,8 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
postHandle=queueJson['postNickname']+'@'+postDomain postHandle=queueJson['postNickname']+'@'+postDomain
if quotasDaily['accounts'].get(postHandle): if quotasDaily['accounts'].get(postHandle):
if quotasDaily['accounts'][postHandle]>accountMaxPostsPerDay: if quotasDaily['accounts'][postHandle]>accountMaxPostsPerDay:
print('DEBUG: Quota account posts per day - Maximum posts for '+postHandle+' reached ('+str(accountMaxPostsPerDay)+')') print('Queue: Quota account posts per day - Maximum posts for '+ \
postHandle+' reached ('+str(accountMaxPostsPerDay)+')')
if len(queue)>0: if len(queue)>0:
try: try:
os.remove(queueFilename) os.remove(queueFilename)
@ -2174,7 +2176,8 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
if accountMaxPostsPerMin<10: if accountMaxPostsPerMin<10:
accountMaxPostsPerMin=10 accountMaxPostsPerMin=10
if quotasPerMin['accounts'][postHandle]>accountMaxPostsPerMin: if quotasPerMin['accounts'][postHandle]>accountMaxPostsPerMin:
print('DEBUG: Quota account posts per min - Maximum posts for '+postHandle+' reached ('+str(accountMaxPostsPerMin)+')') print('Queue: Quota account posts per min - Maximum posts for '+ \
postHandle+' reached ('+str(accountMaxPostsPerMin)+')')
if len(queue)>0: if len(queue)>0:
try: try:
os.remove(queueFilename) os.remove(queueFilename)
@ -2204,9 +2207,8 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
keyId=signatureItem.split('"')[1] keyId=signatureItem.split('"')[1]
break break
if not keyId: if not keyId:
if debug: print('Queue: No keyId in signature: '+ \
print('DEBUG: No keyId in signature: '+ \ queueJson['httpHeaders']['signature'])
queueJson['httpHeaders']['signature'])
if os.path.isfile(queueFilename): if os.path.isfile(queueFilename):
os.remove(queueFilename) os.remove(queueFilename)
if len(queue)>0: if len(queue)>0:
@ -2229,8 +2231,7 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
time.sleep(5) time.sleep(5)
if not pubKey: if not pubKey:
if debug: print('Queue: public key could not be obtained from '+keyId)
print('DEBUG: public key could not be obtained from '+keyId)
if os.path.isfile(queueFilename): if os.path.isfile(queueFilename):
os.remove(queueFilename) os.remove(queueFilename)
if len(queue)>0: if len(queue)>0:
@ -2248,12 +2249,11 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
queueJson['digest'], \ queueJson['digest'], \
json.dumps(queueJson['post']), \ json.dumps(queueJson['post']), \
debug): debug):
if debug: print('Queue: Header signature check failed')
print('DEBUG: Header signature check failed') if os.path.isfile(queueFilename):
if os.path.isfile(queueFilename): os.remove(queueFilename)
os.remove(queueFilename) if len(queue)>0:
if len(queue)>0: queue.pop(0)
queue.pop(0)
continue continue
if debug: if debug:
@ -2273,8 +2273,7 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
federationList, \ federationList, \
debug, \ debug, \
acceptedCaps=["inbox:write","objects:read"]): acceptedCaps=["inbox:write","objects:read"]):
if debug: print('Queue: Undo accepted from '+keyId)
print('DEBUG: Undo accepted from '+keyId)
if os.path.isfile(queueFilename): if os.path.isfile(queueFilename):
os.remove(queueFilename) os.remove(queueFilename)
if len(queue)>0: if len(queue)>0:
@ -2296,8 +2295,7 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
os.remove(queueFilename) os.remove(queueFilename)
if len(queue)>0: if len(queue)>0:
queue.pop(0) queue.pop(0)
if debug: print('Queue: Follow activity for '+keyId+' removed from accepted from queue')
print('DEBUG: Follow activity for '+keyId+' removed from accepted from queue')
continue continue
else: else:
if debug: if debug:
@ -2311,8 +2309,7 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
queueJson['post'], \ queueJson['post'], \
federationList, \ federationList, \
debug): debug):
if debug: print('Queue: Accept/Reject received from '+keyId)
print('DEBUG: Accept/Reject received from '+keyId)
if os.path.isfile(queueFilename): if os.path.isfile(queueFilename):
os.remove(queueFilename) os.remove(queueFilename)
if len(queue)>0: if len(queue)>0:
@ -2329,8 +2326,7 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
federationList, \ federationList, \
queueJson['postNickname'], \ queueJson['postNickname'], \
debug): debug):
if debug: print('Queue: Update accepted from '+keyId)
print('DEBUG: Update accepted from '+keyId)
if os.path.isfile(queueFilename): if os.path.isfile(queueFilename):
os.remove(queueFilename) os.remove(queueFilename)
if len(queue)>0: if len(queue)>0:
@ -2343,9 +2339,7 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
httpPrefix,domain,port,debug) httpPrefix,domain,port,debug)
if len(recipientsDict.items())==0 and \ if len(recipientsDict.items())==0 and \
len(recipientsDictFollowers.items())==0: len(recipientsDictFollowers.items())==0:
if debug: print('Queue: no recipients were resolved for post arriving in inbox')
pprint(queueJson['post'])
print('DEBUG: no recipients were resolved for post arriving in inbox')
if os.path.isfile(queueFilename): if os.path.isfile(queueFilename):
os.remove(queueFilename) os.remove(queueFilename)
if len(queue)>0: if len(queue)>0:
@ -2376,8 +2370,7 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
if queueJson['post'].get('capability'): if queueJson['post'].get('capability'):
if not isinstance(queueJson['post']['capability'], list): if not isinstance(queueJson['post']['capability'], list):
if debug: print('Queue: capability on post should be a list')
print('DEBUG: capability on post should be a list')
if os.path.isfile(queueFilename): if os.path.isfile(queueFilename):
os.remove(queueFilename) os.remove(queueFilename)
if len(queue)>0: if len(queue)>0:
@ -2423,8 +2416,8 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
maxMentions,maxEmoji, \ maxMentions,maxEmoji, \
translate,unitTest) translate,unitTest)
else: else:
print('Queue: object capabilities check has failed')
if debug: if debug:
print('DEBUG: object capabilities check has failed')
pprint(queueJson['post']) pprint(queueJson['post'])
else: else:
if not ocapAlways: if not ocapAlways:
@ -2447,10 +2440,8 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
pprint(queueJson['post']) pprint(queueJson['post'])
print('No capability list within post') print('No capability list within post')
print('ocapAlways: '+str(ocapAlways)) print('ocapAlways: '+str(ocapAlways))
print('DEBUG: object capabilities check failed')
if debug: print('Queue: Queue post accepted')
print('DEBUG: Queue post accepted')
if os.path.isfile(queueFilename): if os.path.isfile(queueFilename):
os.remove(queueFilename) os.remove(queueFilename)
if len(queue)>0: if len(queue)>0: