main
Bob Mottram 2020-12-18 10:43:19 +00:00
parent ab5a871a22
commit a15b2be343
2 changed files with 28 additions and 16 deletions

View File

@ -4548,8 +4548,8 @@ class PubServer(BaseHTTPRequestHandler):
'id': actorJson['id'] + '#updates/' + pubNumber, 'id': actorJson['id'] + '#updates/' + pubNumber,
'type': 'Update', 'type': 'Update',
'actor': actorJson['id'], 'actor': actorJson['id'],
'cc': [pubStr], 'to': [pubStr],
'to': [actorJson['id'] + '/followers'], 'cc': [actorJson['id'] + '/followers'],
'object': actorJson 'object': actorJson
} }
print('Sending actor update: ' + str(updateActorJson)) print('Sending actor update: ' + str(updateActorJson))

View File

@ -1174,7 +1174,7 @@ def postIsAddressedToFollowers(baseDir: str,
postJsonObject: {}) -> bool: postJsonObject: {}) -> bool:
"""Returns true if the given post is addressed to followers of the nickname """Returns true if the given post is addressed to followers of the nickname
""" """
domain = getFullDomain(domain, port) domainFull = getFullDomain(domain, port)
if not postJsonObject.get('object'): if not postJsonObject.get('object'):
return False return False
@ -1192,7 +1192,7 @@ def postIsAddressedToFollowers(baseDir: str,
if postJsonObject.get('cc'): if postJsonObject.get('cc'):
ccList = postJsonObject['cc'] ccList = postJsonObject['cc']
followersUrl = httpPrefix + '://' + domain + '/users/' + \ followersUrl = httpPrefix + '://' + domainFull + '/users/' + \
nickname + '/followers' nickname + '/followers'
# does the followers url exist in 'to' or 'cc' lists? # does the followers url exist in 'to' or 'cc' lists?
@ -2353,6 +2353,26 @@ def hasSharedInbox(session, httpPrefix: str, domain: str) -> bool:
return False return False
def sendingProfileUpdate(postJsonObject: {}) -> bool:
"""Returns true if the given json is a profile update
"""
if postJsonObject['type'] != 'Update':
return False
if not postJsonObject.get('object'):
return False
if not isinstance(postJsonObject['object'], dict):
return False
if not postJsonObject['object'].get('type'):
return False
activityType = postJsonObject['object']['type']
if activityType == 'Person' or \
activityType == 'Application' or \
activityType == 'Group' or \
activityType == 'Service':
return True
return False
def sendToFollowers(session, baseDir: str, def sendToFollowers(session, baseDir: str,
nickname: str, nickname: str,
domain: str, domain: str,
@ -2438,18 +2458,10 @@ def sendToFollowers(session, baseDir: str,
toNickname = 'inbox' toNickname = 'inbox'
if toNickname != 'inbox' and postJsonObject.get('type'): if toNickname != 'inbox' and postJsonObject.get('type'):
if postJsonObject['type'] == 'Update': if sendingProfileUpdate(postJsonObject):
if postJsonObject.get('object'): print('Sending profile update to ' +
if isinstance(postJsonObject['object'], dict): 'shared inbox of ' + toDomain)
if postJsonObject['object'].get('type'): toNickname = 'inbox'
typ = postJsonObject['object']['type']
if typ == 'Person' or \
typ == 'Application' or \
typ == 'Group' or \
typ == 'Service':
print('Sending profile update to ' +
'shared inbox of ' + toDomain)
toNickname = 'inbox'
if debug: if debug:
print('DEBUG: Sending from ' + nickname + '@' + domain + print('DEBUG: Sending from ' + nickname + '@' + domain +