mirror of https://gitlab.com/bashrc2/epicyon
Shared inbox actor on @domain@domain
parent
d9c8dc46c2
commit
377940a31f
|
@ -488,7 +488,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
createSession(self.server.domain,self.server.port,self.server.useTor)
|
||||
|
||||
# treat shared inbox paths consistently
|
||||
if self.path=='/sharedInbox' or self.path=='/users/inbox':
|
||||
if self.path=='/sharedInbox' or \
|
||||
self.path=='/users/inbox' or \
|
||||
self.path=='/users/'+self.server.domain:
|
||||
self.path='/inbox'
|
||||
|
||||
# is this a html request?
|
||||
|
|
12
epicyon.py
12
epicyon.py
|
@ -817,17 +817,9 @@ if args.actor:
|
|||
port=443
|
||||
session = createSession(domain,port,useTor)
|
||||
if nickname!='inbox':
|
||||
nickname=domain
|
||||
wfRequest = webfingerHandle(session,nickname+'@'+domain,httpPrefix,wfCache, \
|
||||
domain,__version__)
|
||||
else:
|
||||
wfRequest={
|
||||
'aliases': [httpPrefix+'://'+domain+'/@inbox',
|
||||
httpPrefix+'://'+domain+'/users/inbox'],
|
||||
'links': [{'href': httpPrefix+'://'+domain+'/users/inbox',
|
||||
'rel': 'self',
|
||||
'type': 'application/activity+json'}],
|
||||
'subject': 'acct:inbox@'+domain
|
||||
}
|
||||
|
||||
if not wfRequest:
|
||||
print('Unable to webfinger '+nickname+'@'+domain)
|
||||
|
@ -858,7 +850,7 @@ if args.addaccount:
|
|||
if not args.domain or not getConfigParam(baseDir,'domain'):
|
||||
print('Use the --domain option to set the domain name')
|
||||
sys.exit()
|
||||
if not validNickname(nickname):
|
||||
if not validNickname(domain,nickname):
|
||||
print(nickname+' is a reserved name. Use something different.')
|
||||
sys.exit()
|
||||
if not args.password:
|
||||
|
|
|
@ -207,7 +207,7 @@ def getFollowingFeed(baseDir: str,domain: str,port: int,path: str, \
|
|||
nickname=path.replace('/@','',1).replace('/'+followFile,'')
|
||||
if not nickname:
|
||||
return None
|
||||
if not validNickname(nickname):
|
||||
if not validNickname(domain,nickname):
|
||||
return None
|
||||
|
||||
if port:
|
||||
|
|
13
person.py
13
person.py
|
@ -248,7 +248,7 @@ def registerAccount(baseDir: str,httpPrefix: str,domain: str,port: int, \
|
|||
"""
|
||||
if accountExists(baseDir,nickname,domain):
|
||||
return False
|
||||
if not validNickname(nickname):
|
||||
if not validNickname(domain,nickname):
|
||||
print('REGISTER: Nickname '+nickname+' is invalid')
|
||||
return False
|
||||
if len(password)<8:
|
||||
|
@ -265,7 +265,7 @@ def createPerson(baseDir: str,nickname: str,domain: str,port: int, \
|
|||
httpPrefix: str, saveToFile: bool,password=None) -> (str,str,{},{}):
|
||||
"""Returns the private key, public key, actor and webfinger endpoint
|
||||
"""
|
||||
if not validNickname(nickname):
|
||||
if not validNickname(domain,nickname):
|
||||
return None,None,None,None
|
||||
|
||||
# If a config.json file doesn't exist then don't decrement
|
||||
|
@ -321,7 +321,8 @@ def personLookup(domain: str,path: str,baseDir: str) -> {}:
|
|||
# is this a shared inbox lookup?
|
||||
isSharedInbox=False
|
||||
if path=='/inbox' or path=='/users/inbox' or path=='/sharedInbox':
|
||||
path='/users/inbox'
|
||||
# shared inbox actor on @domain@domain
|
||||
path='/users/'+domain
|
||||
isSharedInbox=True
|
||||
else:
|
||||
notPersonLookup=['/inbox','/outbox','/outboxarchive', \
|
||||
|
@ -337,7 +338,7 @@ def personLookup(domain: str,path: str,baseDir: str) -> {}:
|
|||
nickname=path.replace('/@','',1)
|
||||
if not nickname:
|
||||
return None
|
||||
if not isSharedInbox and not validNickname(nickname):
|
||||
if not isSharedInbox and not validNickname(domain,nickname):
|
||||
return None
|
||||
if ':' in domain:
|
||||
domain=domain.split(':')[0]
|
||||
|
@ -391,7 +392,7 @@ def personBoxJson(baseDir: str,domain: str,port: int,path: str, \
|
|||
nickname=path.replace('/@','',1).replace('/'+boxname,'')
|
||||
if not nickname:
|
||||
return None
|
||||
if not validNickname(nickname):
|
||||
if not validNickname(domain,nickname):
|
||||
return None
|
||||
if boxname=='inbox':
|
||||
return createInbox(baseDir,nickname,domain,port,httpPrefix, \
|
||||
|
@ -438,7 +439,7 @@ def personInboxJson(baseDir: str,domain: str,port: int,path: str, \
|
|||
nickname=path.replace('/@','',1).replace('/inbox','')
|
||||
if not nickname:
|
||||
return None
|
||||
if not validNickname(nickname):
|
||||
if not validNickname(domain,nickname):
|
||||
return None
|
||||
return createInbox(baseDir,nickname,domain,port,httpPrefix, \
|
||||
noOfItems,headerOnly,ocapAlways,pageNumber)
|
||||
|
|
26
posts.py
26
posts.py
|
@ -792,7 +792,10 @@ def getMentionedPeople(baseDir: str,httpPrefix: str, \
|
|||
if not ('.' in externalDomain or externalDomain=='localhost'):
|
||||
continue
|
||||
mentionedNickname=handle.split('@')[0]
|
||||
if not validNickname(mentionedNickname):
|
||||
mentionedDomain=handle.split('@')[1].strip('\n')
|
||||
if ':' in mentionedDomain:
|
||||
mentionedDomain=mentionedDomain.split(':')[0]
|
||||
if not validNickname(mentionedDomain,mentionedNickname):
|
||||
continue
|
||||
actor=httpPrefix+'://'+handle.split('@')[1]+'/users/'+mentionedNickname
|
||||
mentions.append(actor)
|
||||
|
@ -1167,6 +1170,8 @@ def sendSignedJson(postJsonObject: {},session,baseDir: str, \
|
|||
|
||||
sharedInbox=False
|
||||
if toNickname=='inbox':
|
||||
# shared inbox actor on @domain@domain
|
||||
toNickname=toDomain
|
||||
sharedInbox=True
|
||||
|
||||
if toPort:
|
||||
|
@ -1174,16 +1179,11 @@ def sendSignedJson(postJsonObject: {},session,baseDir: str, \
|
|||
if ':' not in toDomain:
|
||||
toDomain=toDomain+':'+str(toPort)
|
||||
|
||||
if not sharedInbox:
|
||||
handle=httpPrefix+'://'+toDomain+'/@'+toNickname
|
||||
else:
|
||||
handle=httpPrefix+'://'+toDomain+'/'+toNickname
|
||||
sharedInboxUrl=handle
|
||||
|
||||
if debug:
|
||||
print('DEBUG: handle - '+handle+' toPort '+str(toPort))
|
||||
|
||||
if not sharedInbox:
|
||||
# lookup the inbox for the To handle
|
||||
wfRequest=webfingerHandle(session,handle,httpPrefix,cachedWebfingers, \
|
||||
domain,projectVersion)
|
||||
|
@ -1191,20 +1191,6 @@ def sendSignedJson(postJsonObject: {},session,baseDir: str, \
|
|||
if debug:
|
||||
print('DEBUG: webfinger for '+handle+' failed')
|
||||
return 1
|
||||
else:
|
||||
wfRequest={
|
||||
"aliases": [
|
||||
httpPrefix+'://'+toDomain+'/users/inbox'
|
||||
],
|
||||
"links": [
|
||||
{
|
||||
"href": httpPrefix+'://'+toDomain+'/users/inbox',
|
||||
"rel": "self",
|
||||
"type": "application/activity+json"
|
||||
}
|
||||
],
|
||||
"subject": 'acct:inbox@'+toDomain
|
||||
}
|
||||
|
||||
if not clientToServer:
|
||||
postToBox='inbox'
|
||||
|
|
|
@ -202,7 +202,7 @@ def getSharesFeedForPerson(baseDir: str, \
|
|||
nickname=path.replace('/@','',1).replace('/shares','')
|
||||
if not nickname:
|
||||
return None
|
||||
if not validNickname(nickname):
|
||||
if not validNickname(domain,nickname):
|
||||
return None
|
||||
|
||||
if port:
|
||||
|
|
4
utils.py
4
utils.py
|
@ -265,11 +265,13 @@ def deletePost(baseDir: str,httpPrefix: str,nickname: str,domain: str,postFilena
|
|||
# finally, remove the post itself
|
||||
os.remove(postFilename)
|
||||
|
||||
def validNickname(nickname: str) -> bool:
|
||||
def validNickname(domain: str,nickname: str) -> bool:
|
||||
forbiddenChars=['.',' ','/','?',':',';','@']
|
||||
for c in forbiddenChars:
|
||||
if c in nickname:
|
||||
return False
|
||||
if nickname==domain:
|
||||
return False
|
||||
reservedNames=['inbox','outbox','following','followers','capabilities']
|
||||
if nickname in reservedNames:
|
||||
return False
|
||||
|
|
Loading…
Reference in New Issue