mirror of https://gitlab.com/bashrc2/epicyon
Optionally enable shared inbox
parent
e7e35131f8
commit
2c8d6721d2
18
daemon.py
18
daemon.py
|
@ -315,6 +315,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
def _400(self) -> None:
|
def _400(self) -> None:
|
||||||
self._httpReturnCode(400,'Bad Request')
|
self._httpReturnCode(400,'Bad Request')
|
||||||
|
|
||||||
|
def _503(self) -> None:
|
||||||
|
self._httpReturnCode(503,'Service Unavailable')
|
||||||
|
|
||||||
def _write(self,msg) -> None:
|
def _write(self,msg) -> None:
|
||||||
tries=0
|
tries=0
|
||||||
while tries<5:
|
while tries<5:
|
||||||
|
@ -916,6 +919,12 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.path=='/users/inbox' or \
|
self.path=='/users/inbox' or \
|
||||||
self.path=='/actor/inbox' or \
|
self.path=='/actor/inbox' or \
|
||||||
self.path=='/users/'+self.server.domain:
|
self.path=='/users/'+self.server.domain:
|
||||||
|
# if shared inbox is not enabled
|
||||||
|
if not self.server.enableSharedInbox:
|
||||||
|
self._503()
|
||||||
|
self._benchmarkGET(GETstartTime)
|
||||||
|
return
|
||||||
|
|
||||||
self.path='/inbox'
|
self.path='/inbox'
|
||||||
|
|
||||||
# show the person options screen with view/follow/block/report
|
# show the person options screen with view/follow/block/report
|
||||||
|
@ -3248,6 +3257,12 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.path= \
|
self.path= \
|
||||||
self.path.replace('/outbox/','/outbox').replace('/inbox/','/inbox').replace('/shares/','/shares').replace('/sharedInbox/','/sharedInbox')
|
self.path.replace('/outbox/','/outbox').replace('/inbox/','/inbox').replace('/shares/','/shares').replace('/sharedInbox/','/sharedInbox')
|
||||||
|
|
||||||
|
if self.path=='/inbox':
|
||||||
|
if not self.server.enableSharedInbox:
|
||||||
|
self._503()
|
||||||
|
self._benchmarkPOST(POSTstartTime)
|
||||||
|
return
|
||||||
|
|
||||||
cookie=None
|
cookie=None
|
||||||
if self.headers.get('Cookie'):
|
if self.headers.get('Cookie'):
|
||||||
cookie=self.headers['Cookie']
|
cookie=self.headers['Cookie']
|
||||||
|
@ -4771,7 +4786,7 @@ def loadTokens(baseDir: str,tokensDict: {},tokensLookup: {}) -> None:
|
||||||
tokensDict[nickname]=token
|
tokensDict[nickname]=token
|
||||||
tokensLookup[token]=nickname
|
tokensLookup[token]=nickname
|
||||||
|
|
||||||
def runDaemon(registration: bool, \
|
def runDaemon(enableSharedInbox: bool,registration: bool, \
|
||||||
language: str,projectVersion: str, \
|
language: str,projectVersion: str, \
|
||||||
instanceId: str,clientToServer: bool, \
|
instanceId: str,clientToServer: bool, \
|
||||||
baseDir: str,domain: str, \
|
baseDir: str,domain: str, \
|
||||||
|
@ -4828,6 +4843,7 @@ def runDaemon(registration: bool, \
|
||||||
httpd.registration=True
|
httpd.registration=True
|
||||||
else:
|
else:
|
||||||
httpd.registration=False
|
httpd.registration=False
|
||||||
|
httpd.enableSharedInbox=enableSharedInbox
|
||||||
httpd.outboxThread={}
|
httpd.outboxThread={}
|
||||||
httpd.newPostThread={}
|
httpd.newPostThread={}
|
||||||
httpd.projectVersion=projectVersion
|
httpd.projectVersion=projectVersion
|
||||||
|
|
|
@ -287,6 +287,9 @@ parser.add_argument('--duration', dest='duration', type=str,default=None, \
|
||||||
help='Duration for which to share an item')
|
help='Duration for which to share an item')
|
||||||
parser.add_argument('--registration', dest='registration', type=str,default=None, \
|
parser.add_argument('--registration', dest='registration', type=str,default=None, \
|
||||||
help='Whether new registrations are open or closed')
|
help='Whether new registrations are open or closed')
|
||||||
|
parser.add_argument("--sharedinbox", type=str2bool, nargs='?', \
|
||||||
|
const=True, default=False, \
|
||||||
|
help='Enable shared inbox')
|
||||||
parser.add_argument('--maxregistrations', dest='maxRegistrations', type=int,default=None, \
|
parser.add_argument('--maxregistrations', dest='maxRegistrations', type=int,default=None, \
|
||||||
help='The maximum number of new registrations')
|
help='The maximum number of new registrations')
|
||||||
parser.add_argument("--resetregistrations", type=str2bool, nargs='?', \
|
parser.add_argument("--resetregistrations", type=str2bool, nargs='?', \
|
||||||
|
@ -1474,7 +1477,8 @@ registration=getConfigParam(baseDir,'registration')
|
||||||
if not registration:
|
if not registration:
|
||||||
registration=False
|
registration=False
|
||||||
|
|
||||||
runDaemon(registration,args.language,__version__, \
|
runDaemon(args.sharedinbox, \
|
||||||
|
registration,args.language,__version__, \
|
||||||
instanceId,args.client,baseDir, \
|
instanceId,args.client,baseDir, \
|
||||||
domain,port,proxyPort,httpPrefix, \
|
domain,port,proxyPort,httpPrefix, \
|
||||||
federationList,args.maxMentions, \
|
federationList,args.maxMentions, \
|
||||||
|
|
9
tests.py
9
tests.py
|
@ -229,7 +229,8 @@ def createServerAlice(path: str,domain: str,port: int,federationList: [], \
|
||||||
testServerAliceRunning = True
|
testServerAliceRunning = True
|
||||||
maxMentions=10
|
maxMentions=10
|
||||||
print('Server running: Alice')
|
print('Server running: Alice')
|
||||||
runDaemon(True,'en',__version__,"instanceId",False,path,domain,port,port, \
|
runDaemon(True,True,'en',__version__, \
|
||||||
|
"instanceId",False,path,domain,port,port, \
|
||||||
httpPrefix,federationList,maxMentions,False, \
|
httpPrefix,federationList,maxMentions,False, \
|
||||||
noreply,nolike,nopics,noannounce,cw,ocapAlways, \
|
noreply,nolike,nopics,noannounce,cw,ocapAlways, \
|
||||||
useTor,maxReplies, \
|
useTor,maxReplies, \
|
||||||
|
@ -283,7 +284,8 @@ def createServerBob(path: str,domain: str,port: int,federationList: [], \
|
||||||
testServerBobRunning = True
|
testServerBobRunning = True
|
||||||
maxMentions=10
|
maxMentions=10
|
||||||
print('Server running: Bob')
|
print('Server running: Bob')
|
||||||
runDaemon(True,'en',__version__,"instanceId",False,path,domain,port,port, \
|
runDaemon(True,True,'en',__version__, \
|
||||||
|
"instanceId",False,path,domain,port,port, \
|
||||||
httpPrefix,federationList,maxMentions,False, \
|
httpPrefix,federationList,maxMentions,False, \
|
||||||
noreply,nolike,nopics,noannounce,cw,ocapAlways, \
|
noreply,nolike,nopics,noannounce,cw,ocapAlways, \
|
||||||
useTor,maxReplies, \
|
useTor,maxReplies, \
|
||||||
|
@ -317,7 +319,8 @@ def createServerEve(path: str,domain: str,port: int,federationList: [], \
|
||||||
testServerEveRunning = True
|
testServerEveRunning = True
|
||||||
maxMentions=10
|
maxMentions=10
|
||||||
print('Server running: Eve')
|
print('Server running: Eve')
|
||||||
runDaemon(True,'en',__version__,"instanceId",False,path,domain,port,port, \
|
runDaemon(True,True,'en',__version__, \
|
||||||
|
"instanceId",False,path,domain,port,port, \
|
||||||
httpPrefix,federationList,maxMentions,False, \
|
httpPrefix,federationList,maxMentions,False, \
|
||||||
noreply,nolike,nopics,noannounce,cw,ocapAlways, \
|
noreply,nolike,nopics,noannounce,cw,ocapAlways, \
|
||||||
useTor,maxReplies,allowDeletion,True,True,False,sendThreads)
|
useTor,maxReplies,allowDeletion,True,True,False,sendThreads)
|
||||||
|
|
Loading…
Reference in New Issue