forked from indymedia/epicyon
Return capabilities endpoint
parent
d257b59c3a
commit
b11c8e4735
|
@ -6,6 +6,8 @@ Based on the specification: https://www.w3.org/TR/activitypub
|
|||
|
||||
Also: https://raw.githubusercontent.com/w3c/activitypub/gh-pages/activitypub-tutorial.txt
|
||||
|
||||
https://blog.dereferenced.org/what-is-ocap-and-why-should-i-care
|
||||
|
||||
This project is currently *pre alpha* and not recommended for any real world uses.
|
||||
|
||||
## Goals
|
||||
|
@ -21,6 +23,7 @@ This project is currently *pre alpha* and not recommended for any real world use
|
|||
* http signatures and basic auth.
|
||||
* Compatible with http (onion addresses), https and dat.
|
||||
* Minimal dependencies.
|
||||
* Capabilities based security
|
||||
* Data minimization principle. Configurable post expiry time.
|
||||
* Commandline interface. If there's a GUI it should be a separate project.
|
||||
* Designed for intermittent connectivity. Assume network disruptions.
|
||||
|
|
12
follow.py
12
follow.py
|
@ -280,7 +280,7 @@ def sendFollowRequest(baseDir: str,nickname: str,domain: str,port: int,httpPrefi
|
|||
if followPort!=80 and followPort!=443:
|
||||
followDomain=followDomain+':'+str(followPort)
|
||||
|
||||
newFollow = {
|
||||
newFollowJson = {
|
||||
'type': 'Follow',
|
||||
'actor': httpPrefix+'://'+domain+'/users/'+nickname,
|
||||
'object': followHttpPrefix+'://'+followDomain+'/users/'+followNickname,
|
||||
|
@ -290,5 +290,11 @@ def sendFollowRequest(baseDir: str,nickname: str,domain: str,port: int,httpPrefi
|
|||
|
||||
if ccUrl:
|
||||
if len(ccUrl)>0:
|
||||
newFollow['cc']=ccUrl
|
||||
return newFollow
|
||||
newFollowJson['cc']=ccUrl
|
||||
|
||||
sendSignedJson(newFollowJson,session,baseDir,nickname,domain,port, \
|
||||
nicknameToFollow,domainToFollow,toPort, '', \
|
||||
httpPrefix,saveToFile,clientToServer,federationList, \
|
||||
sendThreads,postLog,cachedWebfingers,personCache)
|
||||
|
||||
return newFollowJson
|
||||
|
|
|
@ -54,7 +54,8 @@ def createPersonBase(baseDir: str,nickname: str,domain: str,port: int, \
|
|||
'endpoints': {
|
||||
'id': httpPrefix+'://'+domain+'/users/'+nickname+'/endpoints',
|
||||
'sharedInbox': httpPrefix+'://'+domain+'/inbox',
|
||||
'uploadMedia': httpPrefix+'://'+domain+'/users/'+nickname+'/endpoints/uploadMedia'
|
||||
'uploadMedia': httpPrefix+'://'+domain+'/users/'+nickname+'/endpoints/uploadMedia',
|
||||
"capabilityAcquisition": httpPrefix+'://'+domain+'/caps/new'
|
||||
},
|
||||
'featured': httpPrefix+'://'+domain+'/users/'+nickname+'/collections/featured',
|
||||
'followers': httpPrefix+'://'+domain+'/users/'+nickname+'/followers',
|
||||
|
|
21
posts.py
21
posts.py
|
@ -134,10 +134,23 @@ def getPersonBox(session,wfRequest: {},personCache: {},boxName='inbox') -> (str,
|
|||
if personJson.get('endpoints'):
|
||||
if personJson['endpoints'].get('sharedInbox'):
|
||||
sharedInbox=personJson['endpoints']['sharedInbox']
|
||||
capabilityAcquisition=None
|
||||
if personJson.get('capabilityAcquisition'):
|
||||
capabilityAcquisition=personJson['capabilityAcquisition']
|
||||
else:
|
||||
if personJson.get('capabilityAcquisitionEndpoint'):
|
||||
capabilityAcquisition=personJson['capabilityAcquisitionEndpoint']
|
||||
else:
|
||||
if personJson.get('endpoints'):
|
||||
if personJson['endpoints'].get('capabilityAcquisition'):
|
||||
capabilityAcquisition=personJson['endpoints']['capabilityAcquisition']
|
||||
else:
|
||||
if personJson['endpoints'].get('capabilityAcquisitionEndpoint'):
|
||||
capabilityAcquisition=personJson['endpoints']['capabilityAcquisitionEndpoint']
|
||||
|
||||
storePersonInCache(personUrl,personJson,personCache)
|
||||
|
||||
return boxJson,pubKeyId,pubKey,personId,sharedInbox
|
||||
return boxJson,pubKeyId,pubKey,personId,sharedInbox,capabilityAcquisition
|
||||
|
||||
def getPosts(session,outboxUrl: str,maxPosts: int,maxMentions: int, \
|
||||
maxEmoji: int,maxAttachments: int,federationList: [], \
|
||||
|
@ -470,7 +483,7 @@ def sendPost(session,baseDir: str,nickname: str, domain: str, port: int, \
|
|||
return 1
|
||||
|
||||
# get the actor inbox for the To handle
|
||||
inboxUrl,pubKeyId,pubKey,toPersonId,sharedInbox = \
|
||||
inboxUrl,pubKeyId,pubKey,toPersonId,sharedInbox,capabilityAcquisition = \
|
||||
getPersonBox(session,wfRequest,personCache,'inbox')
|
||||
|
||||
# If there are more than one followers on the target domain
|
||||
|
@ -540,7 +553,7 @@ def sendSignedJson(postJsonObject: {},session,baseDir: str,nickname: str, domain
|
|||
return 1
|
||||
|
||||
# get the actor inbox for the To handle
|
||||
inboxUrl,pubKeyId,pubKey,toPersonId,sharedInbox = \
|
||||
inboxUrl,pubKeyId,pubKey,toPersonId,sharedInbox,capabilityAcquisition = \
|
||||
getPersonBox(session,wfRequest,personCache,'inbox')
|
||||
|
||||
# If there are more than one followers on the target domain
|
||||
|
@ -730,7 +743,7 @@ def getPublicPostsOfPerson(nickname: str,domain: str,raw: bool,simple: bool) ->
|
|||
if not wfRequest:
|
||||
sys.exit()
|
||||
|
||||
personUrl,pubKeyId,pubKey,personId,shaedInbox= \
|
||||
personUrl,pubKeyId,pubKey,personId,shaedInbox,capabilityAcquisition= \
|
||||
getPersonBox(session,wfRequest,personCache,'outbox')
|
||||
wfResult = json.dumps(wfRequest, indent=4, sort_keys=True)
|
||||
|
||||
|
|
Loading…
Reference in New Issue