mirror of https://gitlab.com/bashrc2/epicyon
Include port numbers in messages
parent
156e36aa66
commit
ec8b82ec9c
|
@ -78,7 +78,7 @@ privateKeyPem,publicKeyPem,person,wfEndpoint=createPerson(baseDir,username,domai
|
||||||
#deleteAllPosts(username,domain)
|
#deleteAllPosts(username,domain)
|
||||||
setPreferredUsername(baseDir,username,domain,'badger')
|
setPreferredUsername(baseDir,username,domain,'badger')
|
||||||
setBio(baseDir,username,domain,'Some personal info')
|
setBio(baseDir,username,domain,'Some personal info')
|
||||||
#createPublicPost(baseDir,username, domain, https, "G'day world!", False, True, None, None, 'Not suitable for Vogons')
|
#createPublicPost(baseDir,username, domain, port,https, "G'day world!", False, True, None, None, 'Not suitable for Vogons')
|
||||||
#archivePosts(username,domain,baseDir,4)
|
#archivePosts(username,domain,baseDir,4)
|
||||||
#outboxJson=createOutbox(baseDir,username,domain,port,https,2,True,None)
|
#outboxJson=createOutbox(baseDir,username,domain,port,https,2,True,None)
|
||||||
#pprint(outboxJson)
|
#pprint(outboxJson)
|
||||||
|
|
15
posts.py
15
posts.py
|
@ -67,7 +67,6 @@ def getUserUrl(wfRequest) -> str:
|
||||||
|
|
||||||
def parseUserFeed(session,feedUrl: str,asHeader: {}) -> None:
|
def parseUserFeed(session,feedUrl: str,asHeader: {}) -> None:
|
||||||
feedJson = getJson(session,feedUrl,asHeader,None)
|
feedJson = getJson(session,feedUrl,asHeader,None)
|
||||||
pprint(feedJson)
|
|
||||||
|
|
||||||
if 'orderedItems' in feedJson:
|
if 'orderedItems' in feedJson:
|
||||||
for item in feedJson['orderedItems']:
|
for item in feedJson['orderedItems']:
|
||||||
|
@ -245,12 +244,16 @@ def getStatusNumber() -> (str,str):
|
||||||
conversationDate=currTime.strftime("%Y-%m-%d")
|
conversationDate=currTime.strftime("%Y-%m-%d")
|
||||||
return statusNumber,published
|
return statusNumber,published
|
||||||
|
|
||||||
def createPostBase(baseDir: str,username: str, domain: str, toUrl: str, ccUrl: str, https: bool, content: str, followersOnly: bool, saveToFile: bool, inReplyTo=None, inReplyToAtomUri=None, subject=None) -> {}:
|
def createPostBase(baseDir: str,username: str, domain: str, port: int,toUrl: str, ccUrl: str, https: bool, content: str, followersOnly: bool, saveToFile: bool, inReplyTo=None, inReplyToAtomUri=None, subject=None) -> {}:
|
||||||
"""Creates a message
|
"""Creates a message
|
||||||
"""
|
"""
|
||||||
prefix='https'
|
prefix='https'
|
||||||
if not https:
|
if not https:
|
||||||
prefix='http'
|
prefix='http'
|
||||||
|
|
||||||
|
if port!=80 and port!=443:
|
||||||
|
domain=domain+':'+str(port)
|
||||||
|
|
||||||
statusNumber,published = getStatusNumber()
|
statusNumber,published = getStatusNumber()
|
||||||
conversationDate=published.split('T')[0]
|
conversationDate=published.split('T')[0]
|
||||||
conversationId=statusNumber
|
conversationId=statusNumber
|
||||||
|
@ -311,13 +314,13 @@ def createPostBase(baseDir: str,username: str, domain: str, toUrl: str, ccUrl: s
|
||||||
commentjson.dump(newPost, fp, indent=4, sort_keys=False)
|
commentjson.dump(newPost, fp, indent=4, sort_keys=False)
|
||||||
return newPost
|
return newPost
|
||||||
|
|
||||||
def createPublicPost(baseDir: str,username: str, domain: str, https: bool, content: str, followersOnly: bool, saveToFile: bool, inReplyTo=None, inReplyToAtomUri=None, subject=None) -> {}:
|
def createPublicPost(baseDir: str,username: str, domain: str, port: int,https: bool, content: str, followersOnly: bool, saveToFile: bool, inReplyTo=None, inReplyToAtomUri=None, subject=None) -> {}:
|
||||||
"""Public post to the outbox
|
"""Public post to the outbox
|
||||||
"""
|
"""
|
||||||
prefix='https'
|
prefix='https'
|
||||||
if not https:
|
if not https:
|
||||||
prefix='http'
|
prefix='http'
|
||||||
return createPostBase(baseDir,username, domain, 'https://www.w3.org/ns/activitystreams#Public', prefix+'://'+domain+'/users/'+username+'/followers', https, content, followersOnly, saveToFile, inReplyTo, inReplyToAtomUri, subject)
|
return createPostBase(baseDir,username, domain, port,'https://www.w3.org/ns/activitystreams#Public', prefix+'://'+domain+'/users/'+username+'/followers', https, content, followersOnly, saveToFile, inReplyTo, inReplyToAtomUri, subject)
|
||||||
|
|
||||||
def threadSendPost(session,postJsonObject: {},federationList: [],inboxUrl: str,baseDir: str,signatureHeaderJson: {},postLog: []) -> None:
|
def threadSendPost(session,postJsonObject: {},federationList: [],inboxUrl: str,baseDir: str,signatureHeaderJson: {},postLog: []) -> None:
|
||||||
"""Sends a post with exponential backoff
|
"""Sends a post with exponential backoff
|
||||||
|
@ -370,9 +373,7 @@ def sendPost(session,baseDir: str,username: str, domain: str, port: int, toUsern
|
||||||
if not toPersonId:
|
if not toPersonId:
|
||||||
return 4
|
return 4
|
||||||
|
|
||||||
print('*************Creating post')
|
postJsonObject=createPostBase(baseDir,username,domain,port,toPersonId,cc,https,content,followersOnly,saveToFile,inReplyTo,inReplyToAtomUri,subject)
|
||||||
print('toPersonId: '+toPersonId)
|
|
||||||
postJsonObject=createPostBase(baseDir,username, domain, toPersonId, cc, https, content, followersOnly, saveToFile, inReplyTo, inReplyToAtomUri, subject)
|
|
||||||
|
|
||||||
# get the senders private key
|
# get the senders private key
|
||||||
privateKeyPem=getPersonKey(username,domain,baseDir,'private')
|
privateKeyPem=getPersonKey(username,domain,baseDir,'private')
|
||||||
|
|
12
tests.py
12
tests.py
|
@ -112,9 +112,9 @@ def createServerAlice(path: str,port: int):
|
||||||
deleteAllPosts(username,domain,path)
|
deleteAllPosts(username,domain,path)
|
||||||
followPerson(path,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)
|
followerOfPerson(path,username,domain,'bob','127.0.0.1:61936',federationList)
|
||||||
createPublicPost(path,username, domain, https, "No wise fish would go anywhere without a porpoise", False, True)
|
createPublicPost(path,username, domain, port,https, "No wise fish would go anywhere without a porpoise", False, True)
|
||||||
createPublicPost(path,username, domain, https, "Curiouser and curiouser!", False, True)
|
createPublicPost(path,username, domain, port,https, "Curiouser and curiouser!", False, True)
|
||||||
createPublicPost(path,username, domain, https, "In the gardens of memory, in the palace of dreams, that is where you and I shall meet", False, True)
|
createPublicPost(path,username, domain, port,https, "In the gardens of memory, in the palace of dreams, that is where you and I shall meet", False, True)
|
||||||
global testServerAliceRunning
|
global testServerAliceRunning
|
||||||
testServerAliceRunning = True
|
testServerAliceRunning = True
|
||||||
print('Server running: Alice')
|
print('Server running: Alice')
|
||||||
|
@ -135,9 +135,9 @@ def createServerBob(path: str,port: int):
|
||||||
deleteAllPosts(username,domain,path)
|
deleteAllPosts(username,domain,path)
|
||||||
followPerson(path,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)
|
followerOfPerson(path,username,domain,'alice','127.0.0.1:61935',federationList)
|
||||||
createPublicPost(path,username, domain, https, "It's your life, live it your way.", False, True)
|
createPublicPost(path,username, domain, port,https, "It's your life, live it your way.", False, True)
|
||||||
createPublicPost(path,username, domain, https, "One of the things I've realised is that I am very simple", False, True)
|
createPublicPost(path,username, domain, port,https, "One of the things I've realised is that I am very simple", False, True)
|
||||||
createPublicPost(path,username, domain, https, "Quantum physics is a bit of a passion of mine", False, True)
|
createPublicPost(path,username, domain, port,https, "Quantum physics is a bit of a passion of mine", False, True)
|
||||||
global testServerBobRunning
|
global testServerBobRunning
|
||||||
testServerBobRunning = True
|
testServerBobRunning = True
|
||||||
print('Server running: Bob')
|
print('Server running: Bob')
|
||||||
|
|
Loading…
Reference in New Issue