Checks on public status for viewed replies

master
Bob Mottram 2019-07-13 21:16:07 +01:00
parent 08a16714c0
commit ce9f403f92
2 changed files with 28 additions and 12 deletions

View File

@ -347,8 +347,17 @@ class PubServer(BaseHTTPRequestHandler):
'https://www.w3.org/ns/activitystreams#Public' in open(searchFilename).read(): 'https://www.w3.org/ns/activitystreams#Public' in open(searchFilename).read():
with open(searchFilename, 'r') as fp: with open(searchFilename, 'r') as fp:
postJson=commentjson.load(fp) postJson=commentjson.load(fp)
repliesJson['orderedItems'].append(postJson) if postJson['object'].get('cc'):
replyFound=True if authorized or \
('https://www.w3.org/ns/activitystreams#Public' in postJson['object']['to'] or \
'https://www.w3.org/ns/activitystreams#Public' in postJson['object']['cc']):
repliesJson['orderedItems'].append(postJson)
replyFound=True
else:
if authorized or \
'https://www.w3.org/ns/activitystreams#Public' in postJson['object']['to']:
repliesJson['orderedItems'].append(postJson)
replyFound=True
break break
# if not in either inbox or outbox then examine the shared inbox # if not in either inbox or outbox then examine the shared inbox
if not replyFound: if not replyFound:
@ -363,7 +372,15 @@ class PubServer(BaseHTTPRequestHandler):
# get the json of the reply and append it to the collection # get the json of the reply and append it to the collection
with open(searchFilename, 'r') as fp: with open(searchFilename, 'r') as fp:
postJson=commentjson.load(fp) postJson=commentjson.load(fp)
repliesJson['orderedItems'].append(postJson) if postJson['object'].get('cc'):
if authorized or \
('https://www.w3.org/ns/activitystreams#Public' in postJson['object']['to'] or \
'https://www.w3.org/ns/activitystreams#Public' in postJson['object']['cc']):
repliesJson['orderedItems'].append(postJson)
else:
if authorized or \
'https://www.w3.org/ns/activitystreams#Public' in postJson['object']['to']:
repliesJson['orderedItems'].append(postJson)
# send the replies json # send the replies json
self._set_headers('application/json') self._set_headers('application/json')
self.wfile.write(json.dumps(repliesJson).encode('utf-8')) self.wfile.write(json.dumps(repliesJson).encode('utf-8'))

View File

@ -640,18 +640,17 @@ def populateReplies(baseDir :str,httpPrefix :str,domain :str, \
"""Updates the list of replies for a post on this domain if """Updates the list of replies for a post on this domain if
a reply to it arrives a reply to it arrives
""" """
replyTo=None
if not messageJson.get('id'): if not messageJson.get('id'):
return False return False
if messageJson.get('inReplyTo'): if not messageJson.get('object'):
replyTo=messageJson['inReplyTo']
else:
if messageJson.get('object'):
if isinstance(messageJson['object'], dict):
if messageJson['object'].get('inReplyTo'):
replyTo=messageJson['object']['inReplyTo']
if not replyTo:
return False return False
if not isinstance(messageJson['object'], dict):
return False
if not messageJson['object'].get('inReplyTo'):
return False
if not messageJson['object'].get('to'):
return False
replyTo=messageJson['object']['inReplyTo']
if debug: if debug:
print('DEBUG: post contains a reply') print('DEBUG: post contains a reply')
# is this a reply to a post on this domain? # is this a reply to a post on this domain?