Optionally enable shared inbox

main
Bob Mottram 2019-11-15 21:43:20 +00:00
parent e7e35131f8
commit 2c8d6721d2
3 changed files with 28 additions and 5 deletions

View File

@ -314,6 +314,9 @@ class PubServer(BaseHTTPRequestHandler):
def _400(self) -> None:
self._httpReturnCode(400,'Bad Request')
def _503(self) -> None:
self._httpReturnCode(503,'Service Unavailable')
def _write(self,msg) -> None:
tries=0
@ -916,6 +919,12 @@ class PubServer(BaseHTTPRequestHandler):
self.path=='/users/inbox' or \
self.path=='/actor/inbox' or \
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'
# show the person options screen with view/follow/block/report
@ -3248,6 +3257,12 @@ class PubServer(BaseHTTPRequestHandler):
self.path= \
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
if self.headers.get('Cookie'):
cookie=self.headers['Cookie']
@ -4771,7 +4786,7 @@ def loadTokens(baseDir: str,tokensDict: {},tokensLookup: {}) -> None:
tokensDict[nickname]=token
tokensLookup[token]=nickname
def runDaemon(registration: bool, \
def runDaemon(enableSharedInbox: bool,registration: bool, \
language: str,projectVersion: str, \
instanceId: str,clientToServer: bool, \
baseDir: str,domain: str, \
@ -4828,6 +4843,7 @@ def runDaemon(registration: bool, \
httpd.registration=True
else:
httpd.registration=False
httpd.enableSharedInbox=enableSharedInbox
httpd.outboxThread={}
httpd.newPostThread={}
httpd.projectVersion=projectVersion

View File

@ -287,6 +287,9 @@ parser.add_argument('--duration', dest='duration', type=str,default=None, \
help='Duration for which to share an item')
parser.add_argument('--registration', dest='registration', type=str,default=None, \
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, \
help='The maximum number of new registrations')
parser.add_argument("--resetregistrations", type=str2bool, nargs='?', \
@ -1474,7 +1477,8 @@ registration=getConfigParam(baseDir,'registration')
if not registration:
registration=False
runDaemon(registration,args.language,__version__, \
runDaemon(args.sharedinbox, \
registration,args.language,__version__, \
instanceId,args.client,baseDir, \
domain,port,proxyPort,httpPrefix, \
federationList,args.maxMentions, \

View File

@ -229,7 +229,8 @@ def createServerAlice(path: str,domain: str,port: int,federationList: [], \
testServerAliceRunning = True
maxMentions=10
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, \
noreply,nolike,nopics,noannounce,cw,ocapAlways, \
useTor,maxReplies, \
@ -283,7 +284,8 @@ def createServerBob(path: str,domain: str,port: int,federationList: [], \
testServerBobRunning = True
maxMentions=10
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, \
noreply,nolike,nopics,noannounce,cw,ocapAlways, \
useTor,maxReplies, \
@ -317,7 +319,8 @@ def createServerEve(path: str,domain: str,port: int,federationList: [], \
testServerEveRunning = True
maxMentions=10
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, \
noreply,nolike,nopics,noannounce,cw,ocapAlways, \
useTor,maxReplies,allowDeletion,True,True,False,sendThreads)