forked from indymedia/epicyon
Content warnings
parent
b508abaf9d
commit
c64ee34355
|
@ -33,7 +33,7 @@ session = createSession(useTor)
|
||||||
privateKeyPem,publicKeyPem,person,wfEndpoint=createPerson(username,domain,https,True)
|
privateKeyPem,publicKeyPem,person,wfEndpoint=createPerson(username,domain,https,True)
|
||||||
setPreferredUsername(username,domain,'badger')
|
setPreferredUsername(username,domain,'badger')
|
||||||
setBio(username,domain,'Some personal info')
|
setBio(username,domain,'Some personal info')
|
||||||
createPublicPost(username, domain, https, "G'day world!", False, True)
|
createPublicPost(username, domain, https, "G'day world!", False, True, 'Not suitable for Vogons')
|
||||||
|
|
||||||
#runDaemon(domain,port,federationList,useTor)
|
#runDaemon(domain,port,federationList,useTor)
|
||||||
|
|
||||||
|
|
11
posts.py
11
posts.py
|
@ -167,7 +167,7 @@ def createOutboxDir(username: str,domain: str) -> (str,str):
|
||||||
outboxJsonFilename=baseDir+'/accounts/'+handle+'/outbox.json'
|
outboxJsonFilename=baseDir+'/accounts/'+handle+'/outbox.json'
|
||||||
return outboxJsonFilename,outboxDir
|
return outboxJsonFilename,outboxDir
|
||||||
|
|
||||||
def createPublicPost(username: str, domain: str, https: bool, content: str, followersOnly: bool, saveToFile: bool) -> {}:
|
def createPublicPost(username: str, domain: str, https: bool, content: str, followersOnly: bool, saveToFile: bool, subject=None) -> {}:
|
||||||
"""Creates a post
|
"""Creates a post
|
||||||
"""
|
"""
|
||||||
prefix='https'
|
prefix='https'
|
||||||
|
@ -175,6 +175,7 @@ def createPublicPost(username: str, domain: str, https: bool, content: str, foll
|
||||||
prefix='http'
|
prefix='http'
|
||||||
currTime=datetime.datetime.utcnow()
|
currTime=datetime.datetime.utcnow()
|
||||||
daysSinceEpoch=(currTime - datetime.datetime(1970,1,1)).days
|
daysSinceEpoch=(currTime - datetime.datetime(1970,1,1)).days
|
||||||
|
# status is the number of seconds since epoch
|
||||||
statusNumber=str((daysSinceEpoch*24*60*60) + (currTime.hour*60*60) + (currTime.minute*60) + currTime.second)
|
statusNumber=str((daysSinceEpoch*24*60*60) + (currTime.hour*60*60) + (currTime.minute*60) + currTime.second)
|
||||||
published=currTime.strftime("%Y-%m-%dT%H:%M:%SZ")
|
published=currTime.strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||||
conversationDate=currTime.strftime("%Y-%m-%d")
|
conversationDate=currTime.strftime("%Y-%m-%d")
|
||||||
|
@ -185,6 +186,10 @@ def createPublicPost(username: str, domain: str, https: bool, content: str, foll
|
||||||
postTo=postCC
|
postTo=postCC
|
||||||
postCC=''
|
postCC=''
|
||||||
newPostId=prefix+'://'+domain+'/users/'+username+'/statuses/'+statusNumber
|
newPostId=prefix+'://'+domain+'/users/'+username+'/statuses/'+statusNumber
|
||||||
|
sensitive=False
|
||||||
|
if subject:
|
||||||
|
summary=subject
|
||||||
|
sensitive=True
|
||||||
newPost = {
|
newPost = {
|
||||||
'id': newPostId+'/activity',
|
'id': newPostId+'/activity',
|
||||||
'type': 'Create',
|
'type': 'Create',
|
||||||
|
@ -194,14 +199,14 @@ def createPublicPost(username: str, domain: str, https: bool, content: str, foll
|
||||||
'cc': [prefix+'://'+domain+'/users/'+username+'/followers'],
|
'cc': [prefix+'://'+domain+'/users/'+username+'/followers'],
|
||||||
'object': {'id': newPostId,
|
'object': {'id': newPostId,
|
||||||
'type': 'Note',
|
'type': 'Note',
|
||||||
'summary': None,
|
'summary': summary,
|
||||||
'inReplyTo': None,
|
'inReplyTo': None,
|
||||||
'published': published,
|
'published': published,
|
||||||
'url': prefix+'://'+domain+'/@'+username+'/'+statusNumber,
|
'url': prefix+'://'+domain+'/@'+username+'/'+statusNumber,
|
||||||
'attributedTo': prefix+'://'+domain+'/users/'+username,
|
'attributedTo': prefix+'://'+domain+'/users/'+username,
|
||||||
'to': ['https://www.w3.org/ns/activitystreams#Public'],
|
'to': ['https://www.w3.org/ns/activitystreams#Public'],
|
||||||
'cc': [prefix+'://'+domain+'/users/'+username+'/followers'],
|
'cc': [prefix+'://'+domain+'/users/'+username+'/followers'],
|
||||||
'sensitive': False,
|
'sensitive': sensitive,
|
||||||
'atomUri': prefix+'://'+domain+'/users/'+username+'/statuses/'+statusNumber,
|
'atomUri': prefix+'://'+domain+'/users/'+username+'/statuses/'+statusNumber,
|
||||||
'inReplyToAtomUri': None,
|
'inReplyToAtomUri': None,
|
||||||
'conversation': 'tag:'+domain+','+conversationDate+':objectId='+conversationId+':objectType=Conversation',
|
'conversation': 'tag:'+domain+','+conversationDate+':objectId='+conversationId+':objectType=Conversation',
|
||||||
|
|
Loading…
Reference in New Issue