More general accept

merge-requests/30/head
Bob Mottram 2021-09-10 22:47:26 +01:00
parent 2da7cd958e
commit d7cbe93391
1 changed files with 40 additions and 10 deletions

View File

@ -413,12 +413,18 @@ def _getPosts(session, outboxUrl: str, maxPosts: int,
if not outboxUrl: if not outboxUrl:
return personPosts return personPosts
profileStr = 'https://www.w3.org/ns/activitystreams' profileStr = 'https://www.w3.org/ns/activitystreams'
acceptStr = \
'application/activity+json, application/ld+json; ' + \
'profile="' + profileStr + '"'
asHeader = { asHeader = {
'Accept': 'application/activity+json; profile="' + profileStr + '"' 'Accept': acceptStr
} }
if '/outbox/' in outboxUrl: if '/outbox/' in outboxUrl:
acceptStr = \
'application/ld+json, application/activity+json; ' + \
'profile="' + profileStr + '"'
asHeader = { asHeader = {
'Accept': 'application/ld+json; profile="' + profileStr + '"' 'Accept': acceptStr
} }
if raw: if raw:
if debug: if debug:
@ -664,12 +670,18 @@ def getPostDomains(session, outboxUrl: str, maxPosts: int,
if not outboxUrl: if not outboxUrl:
return [] return []
profileStr = 'https://www.w3.org/ns/activitystreams' profileStr = 'https://www.w3.org/ns/activitystreams'
acceptStr = \
'application/activity+json, application/ld+json; ' + \
'profile="' + profileStr + '"'
asHeader = { asHeader = {
'Accept': 'application/activity+json; profile="' + profileStr + '"' 'Accept': acceptStr
} }
if '/outbox/' in outboxUrl: if '/outbox/' in outboxUrl:
acceptStr = \
'application/ld+json, application/activity+json; ' + \
'profile="' + profileStr + '"'
asHeader = { asHeader = {
'Accept': 'application/ld+json; profile="' + profileStr + '"' 'Accept': acceptStr
} }
postDomains = domainList postDomains = domainList
@ -721,12 +733,18 @@ def _getPostsForBlockedDomains(baseDir: str,
if not outboxUrl: if not outboxUrl:
return {} return {}
profileStr = 'https://www.w3.org/ns/activitystreams' profileStr = 'https://www.w3.org/ns/activitystreams'
acceptStr = \
'application/activity+json, application/ld+json; ' + \
'profile="' + profileStr + '"'
asHeader = { asHeader = {
'Accept': 'application/activity+json; profile="' + profileStr + '"' 'Accept': acceptStr
} }
if '/outbox/' in outboxUrl: if '/outbox/' in outboxUrl:
acceptStr = \
'application/ld+json, application/activity+json; ' + \
'profile="' + profileStr + '"'
asHeader = { asHeader = {
'Accept': 'application/ld+json; profile="' + profileStr + '"' 'Accept': acceptStr
} }
blockedPosts = {} blockedPosts = {}
@ -3916,12 +3934,18 @@ def downloadFollowCollection(signingPrivateKeyPem: str,
""" """
prof = 'https://www.w3.org/ns/activitystreams' prof = 'https://www.w3.org/ns/activitystreams'
if '/channel/' not in actor or '/accounts/' not in actor: if '/channel/' not in actor or '/accounts/' not in actor:
acceptStr = \
'application/activity+json, application/ld+json; ' + \
'profile="' + prof + '"'
sessionHeaders = { sessionHeaders = {
'Accept': 'application/activity+json; profile="' + prof + '"' 'Accept': acceptStr
} }
else: else:
acceptStr = \
'application/ld+json, application/activity+json; ' + \
'profile="' + prof + '"'
sessionHeaders = { sessionHeaders = {
'Accept': 'application/ld+json; profile="' + prof + '"' 'Accept': acceptStr
} }
result = [] result = []
for pageCtr in range(noOfPages): for pageCtr in range(noOfPages):
@ -4261,13 +4285,19 @@ def downloadAnnounce(session, baseDir: str, httpPrefix: str,
return postJsonObject return postJsonObject
else: else:
profileStr = 'https://www.w3.org/ns/activitystreams' profileStr = 'https://www.w3.org/ns/activitystreams'
acceptStr = \
'application/activity+json, application/ld+json; ' + \
'profile="' + profileStr + '"'
asHeader = { asHeader = {
'Accept': 'application/activity+json; profile="' + profileStr + '"' 'Accept': acceptStr
} }
if '/channel/' in postJsonObject['actor'] or \ if '/channel/' in postJsonObject['actor'] or \
'/accounts/' in postJsonObject['actor']: '/accounts/' in postJsonObject['actor']:
acceptStr = \
'application/ld+json, application/activity+json; ' + \
'profile="' + profileStr + '"'
asHeader = { asHeader = {
'Accept': 'application/ld+json; profile="' + profileStr + '"' 'Accept': acceptStr
} }
actorNickname = getNicknameFromActor(postJsonObject['actor']) actorNickname = getNicknameFromActor(postJsonObject['actor'])
actorDomain, actorPort = getDomainFromActor(postJsonObject['actor']) actorDomain, actorPort = getDomainFromActor(postJsonObject['actor'])