diff --git a/announce.py b/announce.py index 5d8d35d7..56e935b5 100644 --- a/announce.py +++ b/announce.py @@ -445,7 +445,7 @@ def sendAnnounceViaServer(baseDir: str,session, \ postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,displayName = \ getPersonBox(baseDir,session,wfRequest,personCache, \ projectVersion,httpPrefix,fromDomain,postToBox) diff --git a/availability.py b/availability.py index 045b40f8..f915f169 100644 --- a/availability.py +++ b/availability.py @@ -111,7 +111,7 @@ def sendAvailabilityViaServer(baseDir: str,session, \ postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,displayName = \ getPersonBox(baseDir,session,wfRequest,personCache, \ projectVersion,httpPrefix,domain,postToBox) diff --git a/blocking.py b/blocking.py index cffd80c5..89312ff2 100644 --- a/blocking.py +++ b/blocking.py @@ -180,7 +180,7 @@ def sendBlockViaServer(baseDir: str,session, \ postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,displayName = \ getPersonBox(baseDir,session,wfRequest,personCache, \ projectVersion,httpPrefix,fromDomain,postToBox) @@ -258,7 +258,7 @@ def sendUndoBlockViaServer(baseDir: str,session, \ postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,displayName = \ getPersonBox(baseDir,session,wfRequest,personCache, \ projectVersion,httpPrefix,fromDomain,postToBox) diff --git a/daemon.py b/daemon.py index cdbd643f..a8f44758 100644 --- a/daemon.py +++ b/daemon.py @@ -2168,9 +2168,9 @@ class PubServer(BaseHTTPRequestHandler): if len(actorJson['skills'].items())!=len(newSkills.items()): actorChanged=True actorJson['skills']=newSkills - if fields.get('preferredNickname'): - if fields['preferredNickname']!=actorJson['preferredUsername']: - actorJson['preferredUsername']=fields['preferredNickname'] + if fields.get('displayNickname'): + if fields['displayNickname']!=actorJson['name']: + actorJson['name']=fields['displayNickname'] actorChanged=True if fields.get('bio'): if fields['bio']!=actorJson['summary']: diff --git a/delete.py b/delete.py index 503c62ce..bfddabce 100644 --- a/delete.py +++ b/delete.py @@ -125,7 +125,7 @@ def sendDeleteViaServer(baseDir: str,session, \ postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,displayName = \ getPersonBox(baseDir,session,wfRequest,personCache, \ projectVersion,httpPrefix,fromDomain,postToBox) diff --git a/epicyon.py b/epicyon.py index 5e0876f2..5a6f4036 100644 --- a/epicyon.py +++ b/epicyon.py @@ -9,7 +9,7 @@ __status__ = "Production" from person import createPerson from person import createSharedInbox from person import createCapabilitiesInbox -from person import setPreferredNickname +from person import setDisplayNickname from person import setBio from person import setProfileImage from person import removeAccount diff --git a/follow.py b/follow.py index b6f92cfc..4289427b 100644 --- a/follow.py +++ b/follow.py @@ -558,7 +558,7 @@ def sendFollowRequestViaServer(baseDir: str,session, \ postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,displayName = \ getPersonBox(baseDir,session,wfRequest,personCache, \ projectVersion,httpPrefix,fromDomain,postToBox) @@ -642,7 +642,7 @@ def sendUnfollowRequestViaServer(baseDir: str,session, \ postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,displayName = \ getPersonBox(baseDir,session,wfRequest,personCache, \ projectVersion,httpPrefix,fromDomain,postToBox) diff --git a/inbox.py b/inbox.py index 06112ae0..04ef66b4 100644 --- a/inbox.py +++ b/inbox.py @@ -573,7 +573,7 @@ def personReceiveUpdate(baseDir: str, \ domain: str,port: int, \ updateNickname: str,updateDomain: str,updatePort: int, \ personJson: {},personCache: {},debug: bool) -> bool: - """Changes an actor. eg: avatar or preferred name change + """Changes an actor. eg: avatar or display name change """ if debug: print('DEBUG: receiving actor update for '+personJson['url']) diff --git a/like.py b/like.py index 7e7f463b..f560dfc1 100644 --- a/like.py +++ b/like.py @@ -357,7 +357,7 @@ def sendLikeViaServer(baseDir: str,session, \ postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,displayName = \ getPersonBox(baseDir,session,wfRequest,personCache, \ projectVersion,httpPrefix,fromDomain,postToBox) @@ -435,7 +435,7 @@ def sendUndoLikeViaServer(baseDir: str,session, \ postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,displayName = \ getPersonBox(baseDir,session,wfRequest,personCache, \ projectVersion,httpPrefix,fromDomain,postToBox) diff --git a/person.py b/person.py index 7e0b0d5d..af2c728c 100644 --- a/person.py +++ b/person.py @@ -179,7 +179,7 @@ def createPersonBase(baseDir: str,nickname: str,domain: str,port: int, \ 'manuallyApprovesFollowers': False, 'name': nickname, 'outbox': httpPrefix+'://'+domain+'/users/'+nickname+'/outbox', - 'preferredUsername': ''+nickname, + 'preferredUsername': nickname, 'summary': '', 'publicKey': { 'id': httpPrefix+'://'+domain+'/users/'+nickname+'#main-key', @@ -443,9 +443,9 @@ def personInboxJson(baseDir: str,domain: str,port: int,path: str, \ return createInbox(baseDir,nickname,domain,port,httpPrefix, \ noOfItems,headerOnly,ocapAlways,pageNumber) -def setPreferredNickname(baseDir: str,nickname: str, domain: str, \ - preferredName: str) -> bool: - if len(preferredName)>32: +def setDisplayNickname(baseDir: str,nickname: str, domain: str, \ + displayName: str) -> bool: + if len(displayName)>32: return False handle=nickname.lower()+'@'+domain.lower() filename=baseDir+'/accounts/'+handle.lower()+'.json' @@ -456,7 +456,7 @@ def setPreferredNickname(baseDir: str,nickname: str, domain: str, \ personJson=commentjson.load(fp) if not personJson: return False - personJson['preferredUsername']=preferredName + personJson['name']=displayName with open(filename, 'w') as fp: commentjson.dump(personJson, fp, indent=4, sort_keys=False) return True diff --git a/posts.py b/posts.py index 3f320db8..7d2102e0 100644 --- a/posts.py +++ b/posts.py @@ -188,13 +188,13 @@ def getPersonBox(baseDir: str,session,wfRequest: {},personCache: {}, \ if personJson.get('icon'): if personJson['icon'].get('url'): avatarUrl=personJson['icon']['url'] - preferredName=None - if personJson.get('preferredUsername'): - preferredName=personJson['preferredUsername'] + displayName=None + if personJson.get('name'): + displayName=personJson['name'] storePersonInCache(baseDir,personUrl,personJson,personCache) - return boxJson,pubKeyId,pubKey,personId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName + return boxJson,pubKeyId,pubKey,personId,sharedInbox,capabilityAcquisition,avatarUrl,displayName def getPosts(session,outboxUrl: str,maxPosts: int, \ maxMentions: int, \ @@ -964,7 +964,7 @@ def sendPost(projectVersion: str, \ postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,toPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ + inboxUrl,pubKeyId,pubKey,toPersonId,sharedInbox,capabilityAcquisition,avatarUrl,displayName = \ getPersonBox(baseDir,session,wfRequest,personCache, \ projectVersion,httpPrefix,domain,postToBox) @@ -1060,7 +1060,7 @@ def sendPostViaServer(projectVersion: str, \ postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,displayName = \ getPersonBox(baseDir,session,wfRequest,personCache, \ projectVersion,httpPrefix,fromDomain,postToBox) @@ -1192,7 +1192,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,preferredName = \ + inboxUrl,pubKeyId,pubKey,toPersonId,sharedInboxUrl,capabilityAcquisition,avatarUrl,displayName = \ getPersonBox(baseDir,session,wfRequest,personCache, \ projectVersion,httpPrefix,domain,postToBox) @@ -1820,7 +1820,7 @@ def getPublicPostsOfPerson(baseDir: str,nickname: str,domain: str, \ if not wfRequest: sys.exit() - personUrl,pubKeyId,pubKey,personId,shaedInbox,capabilityAcquisition,avatarUrl,preferredName= \ + personUrl,pubKeyId,pubKey,personId,shaedInbox,capabilityAcquisition,avatarUrl,displayName= \ getPersonBox(baseDir,session,wfRequest,personCache, \ projectVersion,httpPrefix,domain,'outbox') wfResult = json.dumps(wfRequest, indent=4, sort_keys=True) diff --git a/roles.py b/roles.py index ba6215bd..afbe370f 100644 --- a/roles.py +++ b/roles.py @@ -257,7 +257,7 @@ def sendRoleViaServer(baseDir: str,session, \ postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,displayName = \ getPersonBox(baseDir,session,wfRequest,personCache, \ projectVersion,httpPrefix,delegatorDomain,postToBox) diff --git a/shares.py b/shares.py index 5d3f3040..a60f0e12 100644 --- a/shares.py +++ b/shares.py @@ -329,7 +329,7 @@ def sendShareViaServer(baseDir,session, \ postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,displayName = \ getPersonBox(baseDir,session,wfRequest,personCache, \ projectVersion,httpPrefix,fromDomain,postToBox) @@ -415,7 +415,7 @@ def sendUndoShareViaServer(baseDir: str,session, \ postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,displayName = \ getPersonBox(baseDir,session,wfRequest,personCache, \ projectVersion,httpPrefix,fromDomain,postToBox) diff --git a/skills.py b/skills.py index b40b40ba..1dc0a6cb 100644 --- a/skills.py +++ b/skills.py @@ -131,7 +131,7 @@ def sendSkillViaServer(baseDir: str,session,nickname: str,password: str, postToBox='outbox' # get the actor inbox for the To handle - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,displayName = \ getPersonBox(baseDir,session,wfRequest,personCache, \ projectVersion,httpPrefix,domain,postToBox) diff --git a/tests.py b/tests.py index a468bd0e..6b09ea90 100644 --- a/tests.py +++ b/tests.py @@ -46,7 +46,7 @@ from follow import unfollowerOfPerson from follow import getFollowersOfPerson from follow import sendFollowRequest from person import createPerson -from person import setPreferredNickname +from person import setDisplayNickname from person import setBio from skills import setSkillLevel from roles import setRole @@ -967,7 +967,7 @@ def testCreatePerson(): assert os.path.isfile(baseDir+'/accounts/passwords') deleteAllPosts(baseDir,nickname,domain,'inbox') deleteAllPosts(baseDir,nickname,domain,'outbox') - setPreferredNickname(baseDir,nickname,domain,'badger') + setDisplayNickname(baseDir,nickname,domain,'badger') setBio(baseDir,nickname,domain,'Randomly roaming in your backyard') archivePostsForPerson(nickname,domain,baseDir,'inbox',None,4) archivePostsForPerson(nickname,domain,baseDir,'outbox',None,4) diff --git a/utils.py b/utils.py index 38ddeddb..a9814151 100644 --- a/utils.py +++ b/utils.py @@ -61,16 +61,16 @@ def urlPermitted(url: str, federationList: [],capability: str): return True return False -def getPreferredName(actor: str,personCache: {}) -> str: - """Returns the preferred name for the given actor +def getDisplayName(actor: str,personCache: {}) -> str: + """Returns the display name for the given actor """ if '/statuses/' in actor: actor=actor.split('/statuses/')[0] if not personCache.get(actor): return None if personCache[actor].get('actor'): - if personCache[actor]['actor'].get('preferredUsername'): - return personCache[actor]['actor']['preferredUsername'] + if personCache[actor]['actor'].get('name'): + return personCache[actor]['actor']['name'] return None def getNicknameFromActor(actor: str) -> str: diff --git a/webinterface.py b/webinterface.py index ca983a25..dabaef88 100644 --- a/webinterface.py +++ b/webinterface.py @@ -20,7 +20,7 @@ from utils import getDomainFromActor from utils import locatePost from utils import noOfAccounts from utils import isPublicPost -from utils import getPreferredName +from utils import getDisplayName from follow import isFollowingActor from webfinger import webfingerHandle from posts import getPersonBox @@ -291,13 +291,13 @@ def htmlEditProfile(baseDir: str,path: str,domain: str,port: int) -> str: return '' isBot='' - preferredNickname=nickname + displayNickname=nickname bioStr='' manuallyApprovesFollowers='' with open(actorFilename, 'r') as fp: actorJson=commentjson.load(fp) - if actorJson.get('preferredUsername'): - preferredNickname=actorJson['preferredUsername'] + if actorJson.get('name'): + displayNickname=actorJson['name'] if actorJson.get('summary'): bioStr=actorJson['summary'].replace('
','').replace('
','') if actorJson.get('manuallyApprovesFollowers'): @@ -367,7 +367,7 @@ def htmlEditProfile(baseDir: str,path: str,domain: str,port: int) -> str: ' ' \ ' '+ \ '@'+nickname+'@'+domainFull+'
' \ ''+profileDescription+'
'+ \ loginButton+ \ @@ -959,13 +959,13 @@ def individualFollowAsHtml(baseDir: str,session,wfRequest: {}, \ if not avatarUrl: avatarUrl=followUrl+'/avatar.png' if domain not in followUrl: - inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl2,preferredName = \ + inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl2,displayName = \ getPersonBox(baseDir,session,wfRequest,personCache, \ projectVersion,httpPrefix,domain,'outbox') if avatarUrl2: avatarUrl=avatarUrl2 - if preferredName: - titleStr=preferredName+' '+titleStr + if displayName: + titleStr=displayName+' '+titleStr buttonsStr='' if authorized: @@ -1129,9 +1129,9 @@ def individualPostAsHtml(baseDir: str, \ if postJsonObject.get('id'): messageId=postJsonObject['id'].replace('/activity','') - preferredName=getPreferredName(postJsonObject['actor'],personCache) - if preferredName: - titleStr+=''+preferredName+'' + displayName=getDisplayName(postJsonObject['actor'],personCache) + if displayName: + titleStr+=''+displayName+'' else: titleStr+='@'+actorNickname+'@'+actorDomain+'' @@ -1139,9 +1139,9 @@ def individualPostAsHtml(baseDir: str, \ if postJsonObject['object'].get('attributedTo'): announceNickname=getNicknameFromActor(postJsonObject['object']['attributedTo']) announceDomain,announcePort=getDomainFromActor(postJsonObject['object']['attributedTo']) - announcePreferredName=getPreferredName(postJsonObject['object']['attributedTo'],personCache) - if announcePreferredName: - titleStr+='@'+searchNickname+'@'+searchDomainFull+'
' \ ''+profileDescription+'
'+ \ '