mirror of https://gitlab.com/bashrc2/epicyon
Extra checks when removing inbox queue items
parent
b2b4d37517
commit
1f0a869fbe
36
inbox.py
36
inbox.py
|
@ -313,7 +313,9 @@ def inboxCheckCapabilities(baseDir :str,nickname :str,domain :str, \
|
|||
if debug:
|
||||
print('DEBUG: capabilities for '+ \
|
||||
actor+' do not exist')
|
||||
if os.path.isfile(queueFilename):
|
||||
os.remove(queueFilename)
|
||||
if len(queue)>0:
|
||||
queue.pop(0)
|
||||
return False
|
||||
|
||||
|
@ -334,28 +336,36 @@ def inboxCheckCapabilities(baseDir :str,nickname :str,domain :str, \
|
|||
if not oc.get('id'):
|
||||
if debug:
|
||||
print('DEBUG: capabilities for '+actor+' do not contain an id')
|
||||
if os.path.isfile(queueFilename):
|
||||
os.remove(queueFilename)
|
||||
if len(queue)>0:
|
||||
queue.pop(0)
|
||||
return False
|
||||
|
||||
if oc['id']!=capabilityId:
|
||||
if debug:
|
||||
print('DEBUG: capability id mismatch')
|
||||
if os.path.isfile(queueFilename):
|
||||
os.remove(queueFilename)
|
||||
if len(queue)>0:
|
||||
queue.pop(0)
|
||||
return False
|
||||
|
||||
if not oc.get('capability'):
|
||||
if debug:
|
||||
print('DEBUG: missing capability list')
|
||||
if os.path.isfile(queueFilename):
|
||||
os.remove(queueFilename)
|
||||
if len(queue)>0:
|
||||
queue.pop(0)
|
||||
return False
|
||||
|
||||
if not CapablePost(queueJson['post'],oc['capability'],debug):
|
||||
if debug:
|
||||
print('DEBUG: insufficient capabilities to write to inbox from '+actor)
|
||||
if os.path.isfile(queueFilename):
|
||||
os.remove(queueFilename)
|
||||
if len(queue)>0:
|
||||
queue.pop(0)
|
||||
return False
|
||||
|
||||
|
@ -1111,6 +1121,7 @@ def receiveUndoAnnounce(session,handle: str,isGroup: bool,baseDir: str, \
|
|||
print("DEBUG: Attempt to undo something which isn't an announcement")
|
||||
return False
|
||||
undoAnnounceCollectionEntry(postFilename,messageJson['actor'],debug)
|
||||
if os.path.isfile(postFilename):
|
||||
os.remove(postFilename)
|
||||
return True
|
||||
|
||||
|
@ -1683,6 +1694,7 @@ def runInboxQueue(projectVersion: str, \
|
|||
if not os.path.isfile(queueFilename):
|
||||
if debug:
|
||||
print("DEBUG: queue item rejected because it has no file: "+queueFilename)
|
||||
if len(queue)>0:
|
||||
queue.pop(0)
|
||||
continue
|
||||
|
||||
|
@ -1698,9 +1710,11 @@ def runInboxQueue(projectVersion: str, \
|
|||
if itemReadFailed>4:
|
||||
# After a few tries we can assume that the file
|
||||
# is probably corrupt/unreadable
|
||||
if len(queue)>0:
|
||||
queue.pop(0)
|
||||
itemReadFailed=0
|
||||
# delete the queue file
|
||||
if os.path.isfile(queueFilename):
|
||||
os.remove(queueFilename)
|
||||
continue
|
||||
itemReadFailed=0
|
||||
|
@ -1721,6 +1735,7 @@ def runInboxQueue(projectVersion: str, \
|
|||
if quotas['domains'][postDomain]>domainMaxPostsPerDay:
|
||||
if debug:
|
||||
print('DEBUG: Maximum posts for '+postDomain+' reached')
|
||||
if len(queue)>0:
|
||||
queue.pop(0)
|
||||
continue
|
||||
quotas['domains'][postDomain]+=1
|
||||
|
@ -1733,6 +1748,7 @@ def runInboxQueue(projectVersion: str, \
|
|||
if quotas['accounts'][postHandle]>accountMaxPostsPerDay:
|
||||
if debug:
|
||||
print('DEBUG: Maximum posts for '+postHandle+' reached')
|
||||
if len(queue)>0:
|
||||
queue.pop(0)
|
||||
continue
|
||||
quotas['accounts'][postHandle]+=1
|
||||
|
@ -1760,7 +1776,9 @@ def runInboxQueue(projectVersion: str, \
|
|||
if debug:
|
||||
print('DEBUG: No keyId in signature: '+ \
|
||||
queueJson['httpHeaders']['signature'])
|
||||
if os.path.isfile(queueFilename):
|
||||
os.remove(queueFilename)
|
||||
if len(queue)>0:
|
||||
queue.pop(0)
|
||||
continue
|
||||
|
||||
|
@ -1780,7 +1798,9 @@ def runInboxQueue(projectVersion: str, \
|
|||
if not pubKey:
|
||||
if debug:
|
||||
print('DEBUG: public key could not be obtained from '+keyId)
|
||||
if os.path.isfile(queueFilename):
|
||||
os.remove(queueFilename)
|
||||
if len(queue)>0:
|
||||
queue.pop(0)
|
||||
continue
|
||||
|
||||
|
@ -1796,7 +1816,9 @@ def runInboxQueue(projectVersion: str, \
|
|||
json.dumps(queueJson['post'])):
|
||||
if debug:
|
||||
print('DEBUG: Header signature check failed')
|
||||
if os.path.isfile(queueFilename):
|
||||
os.remove(queueFilename)
|
||||
if len(queue)>0:
|
||||
queue.pop(0)
|
||||
continue
|
||||
|
||||
|
@ -1819,7 +1841,9 @@ def runInboxQueue(projectVersion: str, \
|
|||
acceptedCaps=["inbox:write","objects:read"]):
|
||||
if debug:
|
||||
print('DEBUG: Undo accepted from '+keyId)
|
||||
if os.path.isfile(queueFilename):
|
||||
os.remove(queueFilename)
|
||||
if len(queue)>0:
|
||||
queue.pop(0)
|
||||
continue
|
||||
|
||||
|
@ -1834,7 +1858,9 @@ def runInboxQueue(projectVersion: str, \
|
|||
federationList, \
|
||||
debug,projectVersion, \
|
||||
acceptedCaps=["inbox:write","objects:read"]):
|
||||
if os.path.isfile(queueFilename):
|
||||
os.remove(queueFilename)
|
||||
if len(queue)>0:
|
||||
queue.pop(0)
|
||||
if debug:
|
||||
print('DEBUG: Follow activity for '+keyId+' removed from accepted from queue')
|
||||
|
@ -1853,7 +1879,9 @@ def runInboxQueue(projectVersion: str, \
|
|||
debug):
|
||||
if debug:
|
||||
print('DEBUG: Accept/Reject received from '+keyId)
|
||||
if os.path.isfile(queueFilename):
|
||||
os.remove(queueFilename)
|
||||
if len(queue)>0:
|
||||
queue.pop(0)
|
||||
continue
|
||||
|
||||
|
@ -1868,7 +1896,9 @@ def runInboxQueue(projectVersion: str, \
|
|||
debug):
|
||||
if debug:
|
||||
print('DEBUG: Update accepted from '+keyId)
|
||||
if os.path.isfile(queueFilename):
|
||||
os.remove(queueFilename)
|
||||
if len(queue)>0:
|
||||
queue.pop(0)
|
||||
continue
|
||||
|
||||
|
@ -1881,7 +1911,9 @@ def runInboxQueue(projectVersion: str, \
|
|||
if debug:
|
||||
pprint(queueJson['post'])
|
||||
print('DEBUG: no recipients were resolved for post arriving in inbox')
|
||||
if os.path.isfile(queueFilename):
|
||||
os.remove(queueFilename)
|
||||
if len(queue)>0:
|
||||
queue.pop(0)
|
||||
continue
|
||||
|
||||
|
@ -1910,7 +1942,9 @@ def runInboxQueue(projectVersion: str, \
|
|||
if not isinstance(queueJson['post']['capability'], list):
|
||||
if debug:
|
||||
print('DEBUG: capability on post should be a list')
|
||||
if os.path.isfile(queueFilename):
|
||||
os.remove(queueFilename)
|
||||
if len(queue)>0:
|
||||
queue.pop(0)
|
||||
continue
|
||||
|
||||
|
@ -1985,5 +2019,7 @@ def runInboxQueue(projectVersion: str, \
|
|||
|
||||
if debug:
|
||||
print('DEBUG: Queue post accepted')
|
||||
if os.path.isfile(queueFilename):
|
||||
os.remove(queueFilename)
|
||||
if len(queue)>0:
|
||||
queue.pop(0)
|
||||
|
|
Loading…
Reference in New Issue