diff --git a/announce.py b/announce.py index 3214a5cd..19a62ce7 100644 --- a/announce.py +++ b/announce.py @@ -280,7 +280,7 @@ def sendAnnounceViaServer(session,fromNickname: str,password: str, postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ getPersonBox(session,wfRequest,personCache,postToBox) if not inboxUrl: diff --git a/availability.py b/availability.py index 6bee702a..a20f21a4 100644 --- a/availability.py +++ b/availability.py @@ -107,7 +107,7 @@ def sendAvailabilityViaServer(session,nickname: str,password: str, postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ getPersonBox(session,wfRequest,personCache,postToBox) if not inboxUrl: diff --git a/blocking.py b/blocking.py index bd7e8f99..c6632af0 100644 --- a/blocking.py +++ b/blocking.py @@ -95,7 +95,7 @@ def sendBlockViaServer(session,fromNickname: str,password: str, postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ getPersonBox(session,wfRequest,personCache,postToBox) if not inboxUrl: @@ -167,7 +167,7 @@ def sendUndoBlockViaServer(session,fromNickname: str,password: str, postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ getPersonBox(session,wfRequest,personCache,postToBox) if not inboxUrl: diff --git a/delete.py b/delete.py index 10208129..2f55a2ea 100644 --- a/delete.py +++ b/delete.py @@ -116,7 +116,7 @@ def sendDeleteViaServer(session,fromNickname: str,password: str, postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ getPersonBox(session,wfRequest,personCache,postToBox) if not inboxUrl: diff --git a/follow.py b/follow.py index e7dca64b..90134352 100644 --- a/follow.py +++ b/follow.py @@ -513,7 +513,7 @@ def sendFollowRequestViaServer(session,fromNickname: str,password: str, postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ getPersonBox(session,wfRequest,personCache,postToBox) if not inboxUrl: @@ -588,7 +588,7 @@ def sendUnfollowRequestViaServer(session,fromNickname: str,password: str, postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ getPersonBox(session,wfRequest,personCache,postToBox) if not inboxUrl: diff --git a/like.py b/like.py index 5298b001..d0fe1170 100644 --- a/like.py +++ b/like.py @@ -312,7 +312,7 @@ def sendLikeViaServer(session,fromNickname: str,password: str, postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ getPersonBox(session,wfRequest,personCache,postToBox) if not inboxUrl: @@ -383,7 +383,7 @@ def sendUndoLikeViaServer(session,fromNickname: str,password: str, postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ getPersonBox(session,wfRequest,personCache,postToBox) if not inboxUrl: diff --git a/posts.py b/posts.py index 58ba83b1..993288b5 100644 --- a/posts.py +++ b/posts.py @@ -118,12 +118,12 @@ def getPersonBox(session,wfRequest: {},personCache: {}, \ asHeader = {'Accept': 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'} personUrl = getUserUrl(wfRequest) if not personUrl: - return None,None,None,None,None,None + return None,None,None,None,None,None,None personJson = getPersonFromCache(personUrl,personCache) if not personJson: personJson = getJson(session,personUrl,asHeader,None) if not personJson: - return None,None,None,None,None,None + return None,None,None,None,None,None,None boxJson=None if not personJson.get(boxName): if personJson.get('endpoints'): @@ -133,7 +133,7 @@ def getPersonBox(session,wfRequest: {},personCache: {}, \ boxJson=personJson[boxName] if not boxJson: - return None,None,None,None,None,None + return None,None,None,None,None,None,None personId=None if personJson.get('id'): @@ -155,14 +155,17 @@ def getPersonBox(session,wfRequest: {},personCache: {}, \ capabilityAcquisition=None if personJson.get('capabilityAcquisitionEndpoint'): capabilityAcquisition=personJson['capabilityAcquisitionEndpoint'] - avaratUrl=None + avatarUrl=None if personJson.get('icon'): if personJson['icon'].get('url'): - avaratUrl=personJson['icon']['url'] + avatarUrl=personJson['icon']['url'] + preferredName=None + if personJson.get('preferredUsername'): + preferredName=personJson['preferredUsername'] storePersonInCache(personUrl,personJson,personCache) - return boxJson,pubKeyId,pubKey,personId,sharedInbox,capabilityAcquisition,avatarUrl + return boxJson,pubKeyId,pubKey,personId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName def getPosts(session,outboxUrl: str,maxPosts: int, \ maxMentions: int, \ @@ -660,7 +663,7 @@ def sendPost(session,baseDir: str,nickname: str, domain: str, port: int, \ postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,toPersonId,sharedInbox,capabilityAcquisition,avatarUrl = \ + inboxUrl,pubKeyId,pubKey,toPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ getPersonBox(session,wfRequest,personCache,postToBox) # If there are more than one followers on the target domain @@ -747,7 +750,7 @@ def sendPostViaServer(session,fromNickname: str,password: str, \ postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ getPersonBox(session,wfRequest,personCache,postToBox) if not inboxUrl: @@ -873,7 +876,7 @@ def sendSignedJson(postJsonObject: {},session,baseDir: str, \ postToBox='outbox' # get the actor inbox/outbox/capabilities for the To handle - inboxUrl,pubKeyId,pubKey,toPersonId,sharedInboxUrl,capabilityAcquisition,avatarUrl = \ + inboxUrl,pubKeyId,pubKey,toPersonId,sharedInboxUrl,capabilityAcquisition,avatarUrl,preferredName = \ getPersonBox(session,wfRequest,personCache,postToBox) if nickname=='capabilities': @@ -1323,7 +1326,7 @@ def getPublicPostsOfPerson(nickname: str,domain: str, \ if not wfRequest: sys.exit() - personUrl,pubKeyId,pubKey,personId,shaedInbox,capabilityAcquisition,avatarUrl= \ + personUrl,pubKeyId,pubKey,personId,shaedInbox,capabilityAcquisition,avatarUrl,preferredName= \ getPersonBox(session,wfRequest,personCache,'outbox') wfResult = json.dumps(wfRequest, indent=4, sort_keys=True) diff --git a/roles.py b/roles.py index 30000731..8505862a 100644 --- a/roles.py +++ b/roles.py @@ -187,7 +187,7 @@ def sendRoleViaServer(session,delegatorNickname: str,password: str, postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ getPersonBox(session,wfRequest,personCache,postToBox) if not inboxUrl: diff --git a/skills.py b/skills.py index 9d8be959..fe55a510 100644 --- a/skills.py +++ b/skills.py @@ -118,7 +118,7 @@ def sendSkillViaServer(session,nickname: str,password: str, postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ getPersonBox(session,wfRequest,personCache,postToBox) if not inboxUrl: diff --git a/webinterface.py b/webinterface.py index 17ebe70f..1263cbf2 100644 --- a/webinterface.py +++ b/webinterface.py @@ -338,10 +338,12 @@ def individualFollowAsHtml(session,wfRequest: {}, \ titleStr='@'+nickname+'@'+domain avatarUrl=followUrl+'/avatar.png' if domain not in followUrl: - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl2 = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl2,preferredName = \ getPersonBox(session,wfRequest,personCache,'outbox') if avatarUrl2: avatarUrl=avatarUrl2 + if preferredName: + titleStr=preferredName+' '+titleStr return \ '<div class="container">\n' \ '<a href="'+followUrl+'">' \ @@ -394,10 +396,12 @@ def individualPostAsHtml(session,wfRequest: {},personCache: {}, \ avatarUrl=postJsonObject['actor']+'/avatar.png' if domain not in postJsonObject['actor']: - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl2 = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl2,preferredName = \ getPersonBox(session,wfRequest,personCache,'outbox') if avatarUrl2: avatarUrl=avatarUrl2 + if preferredName: + titleStr=preferredName+' '+titleStr return \ '<div class="'+containerClass+'">\n' \