forked from indymedia/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)
|
createSession(self.server.domain,self.server.port,self.server.useTor)
|
||||||
|
|
||||||
# treat shared inbox paths consistently
|
# 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'
|
self.path='/inbox'
|
||||||
|
|
||||||
# is this a html request?
|
# is this a html request?
|
||||||
|
|
16
epicyon.py
16
epicyon.py
|
@ -817,17 +817,9 @@ if args.actor:
|
||||||
port=443
|
port=443
|
||||||
session = createSession(domain,port,useTor)
|
session = createSession(domain,port,useTor)
|
||||||
if nickname!='inbox':
|
if nickname!='inbox':
|
||||||
wfRequest = webfingerHandle(session,nickname+'@'+domain,httpPrefix,wfCache, \
|
nickname=domain
|
||||||
domain,__version__)
|
wfRequest = webfingerHandle(session,nickname+'@'+domain,httpPrefix,wfCache, \
|
||||||
else:
|
domain,__version__)
|
||||||
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:
|
if not wfRequest:
|
||||||
print('Unable to webfinger '+nickname+'@'+domain)
|
print('Unable to webfinger '+nickname+'@'+domain)
|
||||||
|
@ -858,7 +850,7 @@ if args.addaccount:
|
||||||
if not args.domain or not getConfigParam(baseDir,'domain'):
|
if not args.domain or not getConfigParam(baseDir,'domain'):
|
||||||
print('Use the --domain option to set the domain name')
|
print('Use the --domain option to set the domain name')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
if not validNickname(nickname):
|
if not validNickname(domain,nickname):
|
||||||
print(nickname+' is a reserved name. Use something different.')
|
print(nickname+' is a reserved name. Use something different.')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
if not args.password:
|
if not args.password:
|
||||||
|
|
|
@ -207,7 +207,7 @@ def getFollowingFeed(baseDir: str,domain: str,port: int,path: str, \
|
||||||
nickname=path.replace('/@','',1).replace('/'+followFile,'')
|
nickname=path.replace('/@','',1).replace('/'+followFile,'')
|
||||||
if not nickname:
|
if not nickname:
|
||||||
return None
|
return None
|
||||||
if not validNickname(nickname):
|
if not validNickname(domain,nickname):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if port:
|
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):
|
if accountExists(baseDir,nickname,domain):
|
||||||
return False
|
return False
|
||||||
if not validNickname(nickname):
|
if not validNickname(domain,nickname):
|
||||||
print('REGISTER: Nickname '+nickname+' is invalid')
|
print('REGISTER: Nickname '+nickname+' is invalid')
|
||||||
return False
|
return False
|
||||||
if len(password)<8:
|
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,{},{}):
|
httpPrefix: str, saveToFile: bool,password=None) -> (str,str,{},{}):
|
||||||
"""Returns the private key, public key, actor and webfinger endpoint
|
"""Returns the private key, public key, actor and webfinger endpoint
|
||||||
"""
|
"""
|
||||||
if not validNickname(nickname):
|
if not validNickname(domain,nickname):
|
||||||
return None,None,None,None
|
return None,None,None,None
|
||||||
|
|
||||||
# If a config.json file doesn't exist then don't decrement
|
# 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?
|
# is this a shared inbox lookup?
|
||||||
isSharedInbox=False
|
isSharedInbox=False
|
||||||
if path=='/inbox' or path=='/users/inbox' or path=='/sharedInbox':
|
if path=='/inbox' or path=='/users/inbox' or path=='/sharedInbox':
|
||||||
path='/users/inbox'
|
# shared inbox actor on @domain@domain
|
||||||
|
path='/users/'+domain
|
||||||
isSharedInbox=True
|
isSharedInbox=True
|
||||||
else:
|
else:
|
||||||
notPersonLookup=['/inbox','/outbox','/outboxarchive', \
|
notPersonLookup=['/inbox','/outbox','/outboxarchive', \
|
||||||
|
@ -337,7 +338,7 @@ def personLookup(domain: str,path: str,baseDir: str) -> {}:
|
||||||
nickname=path.replace('/@','',1)
|
nickname=path.replace('/@','',1)
|
||||||
if not nickname:
|
if not nickname:
|
||||||
return None
|
return None
|
||||||
if not isSharedInbox and not validNickname(nickname):
|
if not isSharedInbox and not validNickname(domain,nickname):
|
||||||
return None
|
return None
|
||||||
if ':' in domain:
|
if ':' in domain:
|
||||||
domain=domain.split(':')[0]
|
domain=domain.split(':')[0]
|
||||||
|
@ -391,7 +392,7 @@ def personBoxJson(baseDir: str,domain: str,port: int,path: str, \
|
||||||
nickname=path.replace('/@','',1).replace('/'+boxname,'')
|
nickname=path.replace('/@','',1).replace('/'+boxname,'')
|
||||||
if not nickname:
|
if not nickname:
|
||||||
return None
|
return None
|
||||||
if not validNickname(nickname):
|
if not validNickname(domain,nickname):
|
||||||
return None
|
return None
|
||||||
if boxname=='inbox':
|
if boxname=='inbox':
|
||||||
return createInbox(baseDir,nickname,domain,port,httpPrefix, \
|
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','')
|
nickname=path.replace('/@','',1).replace('/inbox','')
|
||||||
if not nickname:
|
if not nickname:
|
||||||
return None
|
return None
|
||||||
if not validNickname(nickname):
|
if not validNickname(domain,nickname):
|
||||||
return None
|
return None
|
||||||
return createInbox(baseDir,nickname,domain,port,httpPrefix, \
|
return createInbox(baseDir,nickname,domain,port,httpPrefix, \
|
||||||
noOfItems,headerOnly,ocapAlways,pageNumber)
|
noOfItems,headerOnly,ocapAlways,pageNumber)
|
||||||
|
|
42
posts.py
42
posts.py
|
@ -792,7 +792,10 @@ def getMentionedPeople(baseDir: str,httpPrefix: str, \
|
||||||
if not ('.' in externalDomain or externalDomain=='localhost'):
|
if not ('.' in externalDomain or externalDomain=='localhost'):
|
||||||
continue
|
continue
|
||||||
mentionedNickname=handle.split('@')[0]
|
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
|
continue
|
||||||
actor=httpPrefix+'://'+handle.split('@')[1]+'/users/'+mentionedNickname
|
actor=httpPrefix+'://'+handle.split('@')[1]+'/users/'+mentionedNickname
|
||||||
mentions.append(actor)
|
mentions.append(actor)
|
||||||
|
@ -1167,6 +1170,8 @@ def sendSignedJson(postJsonObject: {},session,baseDir: str, \
|
||||||
|
|
||||||
sharedInbox=False
|
sharedInbox=False
|
||||||
if toNickname=='inbox':
|
if toNickname=='inbox':
|
||||||
|
# shared inbox actor on @domain@domain
|
||||||
|
toNickname=toDomain
|
||||||
sharedInbox=True
|
sharedInbox=True
|
||||||
|
|
||||||
if toPort:
|
if toPort:
|
||||||
|
@ -1174,37 +1179,18 @@ def sendSignedJson(postJsonObject: {},session,baseDir: str, \
|
||||||
if ':' not in toDomain:
|
if ':' not in toDomain:
|
||||||
toDomain=toDomain+':'+str(toPort)
|
toDomain=toDomain+':'+str(toPort)
|
||||||
|
|
||||||
if not sharedInbox:
|
handle=httpPrefix+'://'+toDomain+'/@'+toNickname
|
||||||
handle=httpPrefix+'://'+toDomain+'/@'+toNickname
|
|
||||||
else:
|
|
||||||
handle=httpPrefix+'://'+toDomain+'/'+toNickname
|
|
||||||
sharedInboxUrl=handle
|
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: handle - '+handle+' toPort '+str(toPort))
|
print('DEBUG: handle - '+handle+' toPort '+str(toPort))
|
||||||
|
|
||||||
if not sharedInbox:
|
# lookup the inbox for the To handle
|
||||||
# lookup the inbox for the To handle
|
wfRequest=webfingerHandle(session,handle,httpPrefix,cachedWebfingers, \
|
||||||
wfRequest=webfingerHandle(session,handle,httpPrefix,cachedWebfingers, \
|
domain,projectVersion)
|
||||||
domain,projectVersion)
|
if not wfRequest:
|
||||||
if not wfRequest:
|
if debug:
|
||||||
if debug:
|
print('DEBUG: webfinger for '+handle+' failed')
|
||||||
print('DEBUG: webfinger for '+handle+' failed')
|
return 1
|
||||||
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:
|
if not clientToServer:
|
||||||
postToBox='inbox'
|
postToBox='inbox'
|
||||||
|
|
|
@ -202,7 +202,7 @@ def getSharesFeedForPerson(baseDir: str, \
|
||||||
nickname=path.replace('/@','',1).replace('/shares','')
|
nickname=path.replace('/@','',1).replace('/shares','')
|
||||||
if not nickname:
|
if not nickname:
|
||||||
return None
|
return None
|
||||||
if not validNickname(nickname):
|
if not validNickname(domain,nickname):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if port:
|
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
|
# finally, remove the post itself
|
||||||
os.remove(postFilename)
|
os.remove(postFilename)
|
||||||
|
|
||||||
def validNickname(nickname: str) -> bool:
|
def validNickname(domain: str,nickname: str) -> bool:
|
||||||
forbiddenChars=['.',' ','/','?',':',';','@']
|
forbiddenChars=['.',' ','/','?',':',';','@']
|
||||||
for c in forbiddenChars:
|
for c in forbiddenChars:
|
||||||
if c in nickname:
|
if c in nickname:
|
||||||
return False
|
return False
|
||||||
|
if nickname==domain:
|
||||||
|
return False
|
||||||
reservedNames=['inbox','outbox','following','followers','capabilities']
|
reservedNames=['inbox','outbox','following','followers','capabilities']
|
||||||
if nickname in reservedNames:
|
if nickname in reservedNames:
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in New Issue