mirror of https://gitlab.com/bashrc2/epicyon
base directory in tests
parent
006cc3bbb3
commit
888e4831f2
|
@ -109,13 +109,13 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.wfile.write(json.dumps(outboxFeed).encode('utf-8'))
|
||||
self.GETbusy=False
|
||||
return
|
||||
following=getFollowingFeed(self.server.domain,self.server.port,self.path,self.server.https,followsPerPage)
|
||||
following=getFollowingFeed(self.server.baseDir,self.server.domain,self.server.port,self.path,self.server.https,followsPerPage)
|
||||
if following:
|
||||
self._set_headers('application/json')
|
||||
self.wfile.write(json.dumps(following).encode('utf-8'))
|
||||
self.GETbusy=False
|
||||
return
|
||||
followers=getFollowingFeed(self.server.domain,self.server.port,self.path,self.server.https,followsPerPage,'followers')
|
||||
followers=getFollowingFeed(self.server.baseDir,self.server.domain,self.server.port,self.path,self.server.https,followsPerPage,'followers')
|
||||
if followers:
|
||||
self._set_headers('application/json')
|
||||
self.wfile.write(json.dumps(followers).encode('utf-8'))
|
||||
|
|
|
@ -16,6 +16,7 @@ from posts import deleteAllPosts
|
|||
from posts import createOutbox
|
||||
from posts import archivePosts
|
||||
from posts import sendPost
|
||||
from posts import getPersonBox
|
||||
from session import createSession
|
||||
from session import getJson
|
||||
import json
|
||||
|
@ -82,7 +83,7 @@ setBio(baseDir,username,domain,'Some personal info')
|
|||
#outboxJson=createOutbox(baseDir,username,domain,port,https,2,True,None)
|
||||
#pprint(outboxJson)
|
||||
|
||||
#testPostMessageBetweenServers()
|
||||
testPostMessageBetweenServers()
|
||||
#runDaemon(domain,port,https,federationList,useTor)
|
||||
|
||||
#testHttpsig()
|
||||
|
@ -96,6 +97,11 @@ handle="https://mastodon.social/@Gargron"
|
|||
wfRequest = webfingerHandle(session,handle,True)
|
||||
if not wfRequest:
|
||||
sys.exit()
|
||||
|
||||
personJson,pubKeyId,pubKey,personId=getPersonBox(session,wfRequest)
|
||||
pprint(personJson)
|
||||
sys.exit()
|
||||
|
||||
wfResult = json.dumps(wfRequest, indent=4, sort_keys=True)
|
||||
print(str(wfResult))
|
||||
sys.exit()
|
||||
|
|
12
posts.py
12
posts.py
|
@ -82,7 +82,7 @@ def parseUserFeed(session,feedUrl,asHeader) -> None:
|
|||
for item in parseUserFeed(session,nextUrl,asHeader):
|
||||
yield item
|
||||
|
||||
def getPersonBox(session,wfRequest,boxName='inbox'):
|
||||
def getPersonBox(session,wfRequest,boxName='inbox') -> (str,str,str,str):
|
||||
asHeader = {'Accept': 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'}
|
||||
personUrl = getUserUrl(wfRequest)
|
||||
if not personUrl:
|
||||
|
@ -90,23 +90,27 @@ def getPersonBox(session,wfRequest,boxName='inbox'):
|
|||
personJson = getPersonFromCache(personUrl)
|
||||
if not personJson:
|
||||
personJson = getJson(session,personUrl,asHeader,None)
|
||||
pprint(personJson)
|
||||
if not personJson.get(boxName):
|
||||
return personPosts
|
||||
personId=None
|
||||
if personJson.get('id'):
|
||||
personId=personJson['id']
|
||||
pubKeyId=None
|
||||
pubKey=None
|
||||
if personJson.get('publicKey'):
|
||||
if personJson['publicKey'].get('id'):
|
||||
pubKeyId=personJson['publicKey']['id']
|
||||
if personJson['publicKey'].get('publicKeyPem'):
|
||||
pubKey=personJson['publicKey']['publicKeyPem']
|
||||
|
||||
storePersonInCache(personUrl,personJson)
|
||||
|
||||
return personJson[boxName],pubKey,personId
|
||||
return personJson[boxName],pubKeyId,pubKey,personId
|
||||
|
||||
def getUserPosts(session,wfRequest,maxPosts,maxMentions,maxEmoji,maxAttachments,federationList) -> {}:
|
||||
userPosts={}
|
||||
feedUrl,pubKey,personId = getPersonBox(session,wfRequest,'outbox')
|
||||
feedUrl,pubKeyId,pubKey,personId = getPersonBox(session,wfRequest,'outbox')
|
||||
if not feedUrl:
|
||||
return userPosts
|
||||
|
||||
|
@ -356,7 +360,7 @@ def sendPost(session,baseDir,username: str, domain: str, port: int, toUsername:
|
|||
return 1
|
||||
|
||||
# get the actor inbox for the To handle
|
||||
inboxUrl,pubKey,toPersonId = getPersonBox(session,wfRequest,'inbox')
|
||||
inboxUrl,pubKeyId,pubKey,toPersonId = getPersonBox(session,wfRequest,'inbox')
|
||||
if not inboxUrl:
|
||||
return 2
|
||||
if not pubKey:
|
||||
|
|
8
tests.py
8
tests.py
|
@ -106,8 +106,8 @@ def createServerAlice(path: str,port: int):
|
|||
useTor=False
|
||||
privateKeyPem,publicKeyPem,person,wfEndpoint=createPerson(path,username,domain,port,https,True)
|
||||
deleteAllPosts(username,domain,path)
|
||||
followPerson(username,domain,'bob','127.0.0.1:61936',federationList)
|
||||
followerOfPerson(username,domain,'bob','127.0.0.1:61936',federationList)
|
||||
followPerson(path,username,domain,'bob','127.0.0.1:61936',federationList)
|
||||
followerOfPerson(path,username,domain,'bob','127.0.0.1:61936',federationList)
|
||||
createPublicPost(username, domain, https, "No wise fish would go anywhere without a porpoise", False, True)
|
||||
createPublicPost(username, domain, https, "Curiouser and curiouser!", False, True)
|
||||
createPublicPost(username, domain, https, "In the gardens of memory, in the palace of dreams, that is where you and I shall meet", False, True)
|
||||
|
@ -129,8 +129,8 @@ def createServerBob(path: str,port: int):
|
|||
useTor=False
|
||||
privateKeyPem,publicKeyPem,person,wfEndpoint=createPerson(path,username,domain,port,https,True)
|
||||
deleteAllPosts(username,domain,path)
|
||||
followPerson(username,domain,'alice','127.0.0.1:61935',federationList)
|
||||
followerOfPerson(username,domain,'alice','127.0.0.1:61935',federationList)
|
||||
followPerson(path,username,domain,'alice','127.0.0.1:61935',federationList)
|
||||
followerOfPerson(path,username,domain,'alice','127.0.0.1:61935',federationList)
|
||||
createPublicPost(username, domain, https, "It's your life, live it your way.", False, True)
|
||||
createPublicPost(username, domain, https, "One of the things I've realised is that I am very simple", False, True)
|
||||
createPublicPost(username, domain, https, "Quantum physics is a bit of a passion of mine", False, True)
|
||||
|
|
Loading…
Reference in New Issue