Avoid errors when loading inbox queue items

master
Bob Mottram 2019-08-05 22:14:38 +01:00
parent 4dbf07031a
commit 47aa3fbc1e
3 changed files with 14 additions and 5 deletions

View File

@ -360,6 +360,7 @@ class PubServer(BaseHTTPRequestHandler):
""" """
# Check if the queue is full # Check if the queue is full
if len(self.server.inboxQueue)>=self.server.maxQueueLength: if len(self.server.inboxQueue)>=self.server.maxQueueLength:
print('Inbox queue is full')
return 1 return 1
domainFull=self.server.domain domainFull=self.server.domain

View File

@ -1011,13 +1011,17 @@ def runInboxQueue(baseDir: str,httpPrefix: str,sendThreads: [],postLog: [], \
queueFilename=queue[0] queueFilename=queue[0]
if not os.path.isfile(queueFilename): if not os.path.isfile(queueFilename):
if debug: if debug:
print("DEBUG: queue item rejected becase it has no file: "+queueFilename) print("DEBUG: queue item rejected because it has no file: "+queueFilename)
queue.pop(0) queue.pop(0)
continue continue
# Load the queue json # Load the queue json
try:
with open(queueFilename, 'r') as fp: with open(queueFilename, 'r') as fp:
queueJson=commentjson.load(fp) queueJson=commentjson.load(fp)
except:
print('WARN: Failed to load inbox queue item '+queueFilename)
continue
# clear the daily quotas for maximum numbers of received posts # clear the daily quotas for maximum numbers of received posts
if currTime-quotasLastUpdate>60*60*24: if currTime-quotasLastUpdate>60*60*24:
@ -1033,6 +1037,8 @@ def runInboxQueue(baseDir: str,httpPrefix: str,sendThreads: [],postLog: [], \
if domainMaxPostsPerDay>0: if domainMaxPostsPerDay>0:
if quotas['domains'].get(postDomain): if quotas['domains'].get(postDomain):
if quotas['domains'][postDomain]>domainMaxPostsPerDay: if quotas['domains'][postDomain]>domainMaxPostsPerDay:
if debug:
print('DEBUG: Maximum posts for '+postDomain+' reached')
queue.pop(0) queue.pop(0)
continue continue
quotas['domains'][postDomain]+=1 quotas['domains'][postDomain]+=1
@ -1043,6 +1049,8 @@ def runInboxQueue(baseDir: str,httpPrefix: str,sendThreads: [],postLog: [], \
postHandle=queueJson['postNickname']+'@'+postDomain postHandle=queueJson['postNickname']+'@'+postDomain
if quotas['accounts'].get(postHandle): if quotas['accounts'].get(postHandle):
if quotas['accounts'][postHandle]>accountMaxPostsPerDay: if quotas['accounts'][postHandle]>accountMaxPostsPerDay:
if debug:
print('DEBUG: Maximum posts for '+postHandle+' reached')
queue.pop(0) queue.pop(0)
continue continue
quotas['accounts'][postHandle]+=1 quotas['accounts'][postHandle]+=1

View File

@ -1090,7 +1090,7 @@ def sendToNamedAddresses(session,baseDir: str, \
if not recipients: if not recipients:
return return
if debug: if debug:
print('Sending individually addressed posts: '+str(recipients)) print('DEBUG: Sending individually addressed posts: '+str(recipients))
# this is after the message has arrived at the server # this is after the message has arrived at the server
clientToServer=False clientToServer=False
for address in recipients: for address in recipients:
@ -1109,7 +1109,7 @@ def sendToNamedAddresses(session,baseDir: str, \
if toPort: if toPort:
if toPort!=80 and toPort!=443: if toPort!=80 and toPort!=443:
toDomainFull=toDomain+':'+str(toPort) toDomainFull=toDomain+':'+str(toPort)
print('Post sending s2s: '+nickname+'@'+domainFull+' to '+toNickname+'@'+toDomainFull) print('DEBUG: Post sending s2s: '+nickname+'@'+domainFull+' to '+toNickname+'@'+toDomainFull)
cc=[] cc=[]
sendSignedJson(postJsonObject,session,baseDir, \ sendSignedJson(postJsonObject,session,baseDir, \
nickname,domain,port, \ nickname,domain,port, \