mirror of https://gitlab.com/bashrc2/epicyon
Quota for domain posts per minute
parent
57306c798c
commit
05ef1933b4
|
@ -5973,7 +5973,7 @@ def runDaemon(blogsInstance: bool,mediaInstance: bool, \
|
|||
noreply=False,nolike=False,nopics=False, \
|
||||
noannounce=False,cw=False,ocapAlways=False, \
|
||||
useTor=False,maxReplies=64, \
|
||||
domainMaxPostsPerDay=8640,accountMaxPostsPerDay=8640, \
|
||||
domainMaxPostsPerDay=8640,accountMaxPostsPerDay=864, \
|
||||
allowDeletion=False,debug=False,unitTest=False, \
|
||||
instanceOnlySkillsSearch=False,sendThreads=[], \
|
||||
useBlurHash=False) -> None:
|
||||
|
|
26
inbox.py
26
inbox.py
|
@ -2042,6 +2042,11 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
|
|||
'domains': {},
|
||||
'accounts': {}
|
||||
}
|
||||
quotasLastUpdatePerMin=int(time.time())
|
||||
quotasPerMin={
|
||||
'domains': {},
|
||||
'accounts': {}
|
||||
}
|
||||
|
||||
heartBeatCtr=0
|
||||
queueRestoreCtr=0
|
||||
|
@ -2105,13 +2110,21 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
|
|||
}
|
||||
quotasLastUpdateDaily=currTime
|
||||
|
||||
# clear the per minute quotas for maximum numbers of received posts
|
||||
if currTime-quotasLastUpdatePerMin>60:
|
||||
quotasPerMin={
|
||||
'domains': {},
|
||||
'accounts': {}
|
||||
}
|
||||
quotasLastUpdatePerMin=currTime
|
||||
|
||||
# limit the number of posts which can arrive per domain per day
|
||||
postDomain=queueJson['postDomain']
|
||||
if postDomain:
|
||||
if domainMaxPostsPerDay>0:
|
||||
if quotasDaily['domains'].get(postDomain):
|
||||
if quotasDaily['domains'][postDomain]>domainMaxPostsPerDay:
|
||||
print('DEBUG: Quota - Maximum posts for '+postDomain+' reached')
|
||||
print('DEBUG: Quota per day - Maximum posts for '+postDomain+' reached')
|
||||
if len(queue)>0:
|
||||
queue.pop(0)
|
||||
continue
|
||||
|
@ -2119,6 +2132,17 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
|
|||
else:
|
||||
quotasDaily['domains'][postDomain]=1
|
||||
|
||||
if quotasPerMin['domains'].get(postDomain):
|
||||
domainMaxPostsPerMin=int(domainMaxPostsPerDay/(24*60))
|
||||
if quotasPerMin['domains'][postDomain]>domainMaxPostsPerMin:
|
||||
print('DEBUG: Quota per min - Maximum posts for '+postDomain+' reached')
|
||||
if len(queue)>0:
|
||||
queue.pop(0)
|
||||
continue
|
||||
quotasPerMin['domains'][postDomain]+=1
|
||||
else:
|
||||
quotasPerMin['domains'][postDomain]=1
|
||||
|
||||
if accountMaxPostsPerDay>0:
|
||||
postHandle=queueJson['postNickname']+'@'+postDomain
|
||||
if quotasDaily['accounts'].get(postHandle):
|
||||
|
|
Loading…
Reference in New Issue