forked from indymedia/epicyon
Daily quotas variable names
parent
25bff0dfbf
commit
92c84c4dc2
30
inbox.py
30
inbox.py
|
@ -2036,9 +2036,9 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
|
||||||
# then this loads any outstanding items back into the queue
|
# then this loads any outstanding items back into the queue
|
||||||
restoreQueueItems(baseDir,queue)
|
restoreQueueItems(baseDir,queue)
|
||||||
|
|
||||||
# keep track of numbers of incoming posts per unit of time
|
# keep track of numbers of incoming posts per day
|
||||||
quotasLastUpdate=int(time.time())
|
quotasLastUpdateDaily=int(time.time())
|
||||||
quotas={
|
quotasDaily={
|
||||||
'domains': {},
|
'domains': {},
|
||||||
'accounts': {}
|
'accounts': {}
|
||||||
}
|
}
|
||||||
|
@ -2098,44 +2098,44 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
|
||||||
continue
|
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-quotasLastUpdateDaily>60*60*24:
|
||||||
quotas={
|
quotasDaily={
|
||||||
'domains': {},
|
'domains': {},
|
||||||
'accounts': {}
|
'accounts': {}
|
||||||
}
|
}
|
||||||
quotasLastUpdate=currTime
|
quotasLastUpdateDaily=currTime
|
||||||
|
|
||||||
# limit the number of posts which can arrive per domain per day
|
# limit the number of posts which can arrive per domain per day
|
||||||
postDomain=queueJson['postDomain']
|
postDomain=queueJson['postDomain']
|
||||||
if postDomain:
|
if postDomain:
|
||||||
if domainMaxPostsPerDay>0:
|
if domainMaxPostsPerDay>0:
|
||||||
if quotas['domains'].get(postDomain):
|
if quotasDaily['domains'].get(postDomain):
|
||||||
if quotas['domains'][postDomain]>domainMaxPostsPerDay:
|
if quotasDaily['domains'][postDomain]>domainMaxPostsPerDay:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: Maximum posts for '+postDomain+' reached')
|
print('DEBUG: Maximum posts for '+postDomain+' reached')
|
||||||
if len(queue)>0:
|
if len(queue)>0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
continue
|
continue
|
||||||
quotas['domains'][postDomain]+=1
|
quotasDaily['domains'][postDomain]+=1
|
||||||
else:
|
else:
|
||||||
quotas['domains'][postDomain]=1
|
quotasDaily['domains'][postDomain]=1
|
||||||
|
|
||||||
if accountMaxPostsPerDay>0:
|
if accountMaxPostsPerDay>0:
|
||||||
postHandle=queueJson['postNickname']+'@'+postDomain
|
postHandle=queueJson['postNickname']+'@'+postDomain
|
||||||
if quotas['accounts'].get(postHandle):
|
if quotasDaily['accounts'].get(postHandle):
|
||||||
if quotas['accounts'][postHandle]>accountMaxPostsPerDay:
|
if quotasDaily['accounts'][postHandle]>accountMaxPostsPerDay:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: Maximum posts for '+postHandle+' reached')
|
print('DEBUG: Maximum posts for '+postHandle+' reached')
|
||||||
if len(queue)>0:
|
if len(queue)>0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
continue
|
continue
|
||||||
quotas['accounts'][postHandle]+=1
|
quotasDaily['accounts'][postHandle]+=1
|
||||||
else:
|
else:
|
||||||
quotas['accounts'][postHandle]=1
|
quotasDaily['accounts'][postHandle]=1
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
if accountMaxPostsPerDay>0 or domainMaxPostsPerDay>0:
|
if accountMaxPostsPerDay>0 or domainMaxPostsPerDay>0:
|
||||||
pprint(quotas)
|
pprint(quotasDaily)
|
||||||
|
|
||||||
print('Obtaining public key for actor '+queueJson['actor'])
|
print('Obtaining public key for actor '+queueJson['actor'])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue