mirror of https://gitlab.com/bashrc2/epicyon
@context headers
parent
1997f9ee1b
commit
325672208f
|
@ -40,6 +40,7 @@ def createAcceptReject(baseDir: str,federationList: [], \
|
|||
domain=domain+':'+str(port)
|
||||
|
||||
newAccept = {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
'type': acceptType,
|
||||
'actor': httpPrefix+'://'+domain+'/users/'+nickname,
|
||||
'to': [toUrl],
|
||||
|
|
|
@ -119,6 +119,7 @@ def updateAnnounceCollection(postFilename: str,actor: str,debug: bool) -> None:
|
|||
if debug:
|
||||
print('DEBUG: Adding initial shares (announcements) to '+postUrl)
|
||||
announcementsJson = {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
'id': postUrl,
|
||||
'type': 'Collection',
|
||||
"totalItems": 1,
|
||||
|
@ -195,6 +196,7 @@ def createAnnounce(session,baseDir: str,federationList: [], \
|
|||
newAnnounceId= \
|
||||
httpPrefix+'://'+fullDomain+'/users/'+nickname+'/statuses/'+statusNumber
|
||||
newAnnounce = {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
'actor': httpPrefix+'://'+fullDomain+'/users/'+nickname,
|
||||
'atomUri': httpPrefix+'://'+fullDomain+'/users/'+nickname+'/statuses/'+statusNumber,
|
||||
'cc': [],
|
||||
|
@ -307,6 +309,7 @@ def undoAnnounce(session,baseDir: str,federationList: [], \
|
|||
fullDomain=domain+':'+str(port)
|
||||
|
||||
newUndoAnnounce = {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
'actor': httpPrefix+'://'+fullDomain+'/users/'+nickname,
|
||||
'type': 'Undo',
|
||||
'cc': [],
|
||||
|
@ -416,6 +419,7 @@ def sendAnnounceViaServer(session,fromNickname: str,password: str,
|
|||
newAnnounceId= \
|
||||
httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname+'/statuses/'+statusNumber
|
||||
newAnnounceJson = {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
'actor': httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname,
|
||||
'atomUri': newAnnounceId,
|
||||
'cc': [ccUrl],
|
||||
|
|
|
@ -158,6 +158,7 @@ def sendBlockViaServer(session,fromNickname: str,password: str,
|
|||
|
||||
blockActor=httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname
|
||||
newBlockJson = {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
'type': 'Block',
|
||||
'actor': blockActor,
|
||||
'object': blockedUrl,
|
||||
|
@ -230,6 +231,7 @@ def sendUndoBlockViaServer(session,fromNickname: str,password: str,
|
|||
|
||||
blockActor=httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname
|
||||
newBlockJson = {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
'type': 'Undo',
|
||||
'actor': blockActor,
|
||||
'object': {
|
||||
|
|
|
@ -875,6 +875,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
createSession(self.server.domain,self.server.port,self.server.useTor)
|
||||
undoAnnounceActor=self.server.httpPrefix+'://'+self.server.domainFull+'/users/'+self.postToNickname
|
||||
newUndoAnnounce = {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
'actor': undoAnnounceActor,
|
||||
'type': 'Undo',
|
||||
'cc': [undoAnnounceActor+'/followers'],
|
||||
|
@ -942,6 +943,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
likeActor=self.server.httpPrefix+'://'+self.server.domainFull+'/users/'+self.postToNickname
|
||||
actorLiked=likeUrl.split('/statuses/')[0]
|
||||
likeJson= {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
'type': 'Like',
|
||||
'actor': likeActor,
|
||||
'object': likeUrl,
|
||||
|
@ -964,6 +966,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
undoActor=self.server.httpPrefix+'://'+self.server.domainFull+'/users/'+self.postToNickname
|
||||
actorLiked=likeUrl.split('/statuses/')[0]
|
||||
undoLikeJson= {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
'type': 'Undo',
|
||||
'actor': undoActor,
|
||||
'object': {
|
||||
|
@ -1001,6 +1004,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
createSession(self.server.domain,self.server.port,self.server.useTor)
|
||||
deleteActor=self.server.httpPrefix+'://'+self.server.domainFull+'/users/'+self.postToNickname
|
||||
deleteJson= {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
'actor': actor,
|
||||
'object': deleteUrl,
|
||||
'to': ['https://www.w3.org/ns/activitystreams#Public',actor],
|
||||
|
|
|
@ -51,6 +51,7 @@ def createDelete(session,baseDir: str,federationList: [], \
|
|||
newDeleteId= \
|
||||
httpPrefix+'://'+fullDomain+'/users/'+nickname+'/statuses/'+statusNumber
|
||||
newDelete = {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
'actor': httpPrefix+'://'+fullDomain+'/users/'+nickname,
|
||||
'atomUri': httpPrefix+'://'+fullDomain+'/users/'+nickname+'/statuses/'+statusNumber,
|
||||
'cc': [],
|
||||
|
@ -102,6 +103,7 @@ def sendDeleteViaServer(session,fromNickname: str,password: str,
|
|||
ccUrl = httpPrefix + '://'+fromDomainFull+'/users/'+fromNickname+'/followers'
|
||||
|
||||
newDeleteJson = {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
'actor': httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname,
|
||||
'cc': [ccUrl],
|
||||
'object': deleteObjectUrl,
|
||||
|
|
5
like.py
5
like.py
|
@ -92,6 +92,7 @@ def updateLikesCollection(postFilename: str,objectUrl: str, actor: str,debug: bo
|
|||
if debug:
|
||||
print('DEBUG: Adding initial likes to '+objectUrl)
|
||||
likesJson = {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
'id': objectUrl,
|
||||
'type': 'Collection',
|
||||
"totalItems": 1,
|
||||
|
@ -147,6 +148,7 @@ def like(session,baseDir: str,federationList: [],nickname: str,domain: str,port:
|
|||
likeTo=[objectUrl.split('/statuses/')[0]]
|
||||
|
||||
newLikeJson = {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
'type': 'Like',
|
||||
'actor': httpPrefix+'://'+fullDomain+'/users/'+nickname,
|
||||
'object': objectUrl,
|
||||
|
@ -240,6 +242,7 @@ def undolike(session,baseDir: str,federationList: [],nickname: str,domain: str,p
|
|||
likeTo=[objectUrl.split('/statuses/')[0]]
|
||||
|
||||
newUndoLikeJson = {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
'type': 'Undo',
|
||||
'actor': httpPrefix+'://'+fullDomain+'/users/'+nickname,
|
||||
'object': {
|
||||
|
@ -338,6 +341,7 @@ def sendLikeViaServer(session,fromNickname: str,password: str,
|
|||
toUrl=[likeUrl.split('/statuses/')[0]]
|
||||
|
||||
newLikeJson = {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
'type': 'Like',
|
||||
'actor': httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname,
|
||||
'object': likeUrl,
|
||||
|
@ -412,6 +416,7 @@ def sendUndoLikeViaServer(session,fromNickname: str,password: str,
|
|||
toUrl=[likeUrl.split('/statuses/')[0]]
|
||||
|
||||
newUndoLikeJson = {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
'type': 'Undo',
|
||||
'actor': httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname,
|
||||
'object': {
|
||||
|
|
9
posts.py
9
posts.py
|
@ -494,6 +494,7 @@ def createPostBase(baseDir: str,nickname: str, domain: str, port: int, \
|
|||
capabilityIdList=[oc['id']]
|
||||
|
||||
newPost = {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
'id': newPostId+'/activity',
|
||||
'capability': capabilityIdList,
|
||||
'type': 'Create',
|
||||
|
@ -539,6 +540,7 @@ def createPostBase(baseDir: str,nickname: str, domain: str, port: int, \
|
|||
imageDescription,useBlurhash)
|
||||
else:
|
||||
newPost = {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
'id': newPostId,
|
||||
'type': 'Note',
|
||||
'summary': summary,
|
||||
|
@ -619,6 +621,7 @@ def outboxMessageCreateWrap(httpPrefix: str, \
|
|||
# TODO
|
||||
capabilityUrl=[]
|
||||
newPost = {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
'id': newPostId+'/activity',
|
||||
'capability': capabilityUrl,
|
||||
'type': 'Create',
|
||||
|
@ -889,8 +892,8 @@ def threadSendPost(session,postJsonStr: str,federationList: [],\
|
|||
for attempt in range(20):
|
||||
postResult = \
|
||||
postJsonString(session,postJsonStr,federationList, \
|
||||
inboxUrl,signatureHeaderJson, \
|
||||
"inbox:write")
|
||||
inboxUrl,signatureHeaderJson, \
|
||||
"inbox:write",debug)
|
||||
if postResult:
|
||||
if debug:
|
||||
print('DEBUG: json post to '+inboxUrl+' succeeded')
|
||||
|
@ -1102,7 +1105,7 @@ def sendPostViaServer(projectVersion: str, \
|
|||
'Content-type': 'application/json', \
|
||||
'Authorization': authHeader}
|
||||
postResult = \
|
||||
postJsonString(session,json.dumps(postJsonObject),[],inboxUrl,headers,"inbox:write")
|
||||
postJsonString(session,json.dumps(postJsonObject),[],inboxUrl,headers,"inbox:write",debug)
|
||||
#if not postResult:
|
||||
# if debug:
|
||||
# print('DEBUG: POST failed for c2s to '+inboxUrl)
|
||||
|
|
|
@ -65,7 +65,12 @@ def postJson(session,postJsonObject: {},federationList: [],inboxUrl: str,headers
|
|||
postResult = session.post(url = inboxUrl, data = json.dumps(postJsonObject), headers=headers)
|
||||
return postResult.text
|
||||
|
||||
def postJsonString(session,postJsonStr: str,federationList: [],inboxUrl: str,headers: {},capability: str) -> str:
|
||||
def postJsonString(session,postJsonStr: str, \
|
||||
federationList: [], \
|
||||
inboxUrl: str, \
|
||||
headers: {}, \
|
||||
capability: str, \
|
||||
debug: bool) -> str:
|
||||
"""Post a json message string to the inbox of another person
|
||||
Supplying a capability, such as "inbox:write"
|
||||
NOTE: Here we post a string rather than the original json so that
|
||||
|
@ -77,7 +82,7 @@ def postJsonString(session,postJsonStr: str,federationList: [],inboxUrl: str,hea
|
|||
if not capability.startswith('cap'):
|
||||
# check that we are posting to a permitted domain
|
||||
if not urlPermitted(inboxUrl,federationList,capability):
|
||||
print('postJson: '+inboxUrl+' not permitted')
|
||||
print('postJson: '+inboxUrl+' not permitted by capabilities')
|
||||
return None
|
||||
|
||||
postResult = session.post(url = inboxUrl, data = postJsonStr, headers=headers)
|
||||
|
|
|
@ -296,6 +296,7 @@ def sendShareViaServer(session,fromNickname: str,password: str,
|
|||
ccUrl = httpPrefix + '://'+fromDomainFull+'/users/'+fromNickname+'/followers'
|
||||
|
||||
newShareJson = {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
'type': 'Add',
|
||||
'actor': httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname,
|
||||
'target': httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname+'/shares',
|
||||
|
@ -385,6 +386,7 @@ def sendUndoShareViaServer(session,fromNickname: str,password: str,
|
|||
ccUrl = httpPrefix + '://'+fromDomainFull+'/users/'+fromNickname+'/followers'
|
||||
|
||||
undoShareJson = {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
'type': 'Remove',
|
||||
'actor': httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname,
|
||||
'target': httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname+'/shares',
|
||||
|
|
Loading…
Reference in New Issue