forked from indymedia/epicyon
Preferred name becomes display name - less ambiguous
parent
8a581ababd
commit
f695039e5a
|
@ -445,7 +445,7 @@ def sendAnnounceViaServer(baseDir: str,session, \
|
||||||
postToBox='outbox'
|
postToBox='outbox'
|
||||||
|
|
||||||
# get the actor inbox for the To handle
|
# 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, \
|
getPersonBox(baseDir,session,wfRequest,personCache, \
|
||||||
projectVersion,httpPrefix,fromDomain,postToBox)
|
projectVersion,httpPrefix,fromDomain,postToBox)
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ def sendAvailabilityViaServer(baseDir: str,session, \
|
||||||
postToBox='outbox'
|
postToBox='outbox'
|
||||||
|
|
||||||
# get the actor inbox for the To handle
|
# 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, \
|
getPersonBox(baseDir,session,wfRequest,personCache, \
|
||||||
projectVersion,httpPrefix,domain,postToBox)
|
projectVersion,httpPrefix,domain,postToBox)
|
||||||
|
|
||||||
|
|
|
@ -180,7 +180,7 @@ def sendBlockViaServer(baseDir: str,session, \
|
||||||
postToBox='outbox'
|
postToBox='outbox'
|
||||||
|
|
||||||
# get the actor inbox for the To handle
|
# 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, \
|
getPersonBox(baseDir,session,wfRequest,personCache, \
|
||||||
projectVersion,httpPrefix,fromDomain,postToBox)
|
projectVersion,httpPrefix,fromDomain,postToBox)
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ def sendUndoBlockViaServer(baseDir: str,session, \
|
||||||
postToBox='outbox'
|
postToBox='outbox'
|
||||||
|
|
||||||
# get the actor inbox for the To handle
|
# 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, \
|
getPersonBox(baseDir,session,wfRequest,personCache, \
|
||||||
projectVersion,httpPrefix,fromDomain,postToBox)
|
projectVersion,httpPrefix,fromDomain,postToBox)
|
||||||
|
|
||||||
|
|
|
@ -2168,9 +2168,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if len(actorJson['skills'].items())!=len(newSkills.items()):
|
if len(actorJson['skills'].items())!=len(newSkills.items()):
|
||||||
actorChanged=True
|
actorChanged=True
|
||||||
actorJson['skills']=newSkills
|
actorJson['skills']=newSkills
|
||||||
if fields.get('preferredNickname'):
|
if fields.get('displayNickname'):
|
||||||
if fields['preferredNickname']!=actorJson['preferredUsername']:
|
if fields['displayNickname']!=actorJson['name']:
|
||||||
actorJson['preferredUsername']=fields['preferredNickname']
|
actorJson['name']=fields['displayNickname']
|
||||||
actorChanged=True
|
actorChanged=True
|
||||||
if fields.get('bio'):
|
if fields.get('bio'):
|
||||||
if fields['bio']!=actorJson['summary']:
|
if fields['bio']!=actorJson['summary']:
|
||||||
|
|
|
@ -125,7 +125,7 @@ def sendDeleteViaServer(baseDir: str,session, \
|
||||||
postToBox='outbox'
|
postToBox='outbox'
|
||||||
|
|
||||||
# get the actor inbox for the To handle
|
# 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, \
|
getPersonBox(baseDir,session,wfRequest,personCache, \
|
||||||
projectVersion,httpPrefix,fromDomain,postToBox)
|
projectVersion,httpPrefix,fromDomain,postToBox)
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ __status__ = "Production"
|
||||||
from person import createPerson
|
from person import createPerson
|
||||||
from person import createSharedInbox
|
from person import createSharedInbox
|
||||||
from person import createCapabilitiesInbox
|
from person import createCapabilitiesInbox
|
||||||
from person import setPreferredNickname
|
from person import setDisplayNickname
|
||||||
from person import setBio
|
from person import setBio
|
||||||
from person import setProfileImage
|
from person import setProfileImage
|
||||||
from person import removeAccount
|
from person import removeAccount
|
||||||
|
|
|
@ -558,7 +558,7 @@ def sendFollowRequestViaServer(baseDir: str,session, \
|
||||||
postToBox='outbox'
|
postToBox='outbox'
|
||||||
|
|
||||||
# get the actor inbox for the To handle
|
# 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, \
|
getPersonBox(baseDir,session,wfRequest,personCache, \
|
||||||
projectVersion,httpPrefix,fromDomain,postToBox)
|
projectVersion,httpPrefix,fromDomain,postToBox)
|
||||||
|
|
||||||
|
@ -642,7 +642,7 @@ def sendUnfollowRequestViaServer(baseDir: str,session, \
|
||||||
postToBox='outbox'
|
postToBox='outbox'
|
||||||
|
|
||||||
# get the actor inbox for the To handle
|
# 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, \
|
getPersonBox(baseDir,session,wfRequest,personCache, \
|
||||||
projectVersion,httpPrefix,fromDomain,postToBox)
|
projectVersion,httpPrefix,fromDomain,postToBox)
|
||||||
|
|
||||||
|
|
2
inbox.py
2
inbox.py
|
@ -573,7 +573,7 @@ def personReceiveUpdate(baseDir: str, \
|
||||||
domain: str,port: int, \
|
domain: str,port: int, \
|
||||||
updateNickname: str,updateDomain: str,updatePort: int, \
|
updateNickname: str,updateDomain: str,updatePort: int, \
|
||||||
personJson: {},personCache: {},debug: bool) -> bool:
|
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:
|
if debug:
|
||||||
print('DEBUG: receiving actor update for '+personJson['url'])
|
print('DEBUG: receiving actor update for '+personJson['url'])
|
||||||
|
|
4
like.py
4
like.py
|
@ -357,7 +357,7 @@ def sendLikeViaServer(baseDir: str,session, \
|
||||||
postToBox='outbox'
|
postToBox='outbox'
|
||||||
|
|
||||||
# get the actor inbox for the To handle
|
# 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, \
|
getPersonBox(baseDir,session,wfRequest,personCache, \
|
||||||
projectVersion,httpPrefix,fromDomain,postToBox)
|
projectVersion,httpPrefix,fromDomain,postToBox)
|
||||||
|
|
||||||
|
@ -435,7 +435,7 @@ def sendUndoLikeViaServer(baseDir: str,session, \
|
||||||
postToBox='outbox'
|
postToBox='outbox'
|
||||||
|
|
||||||
# get the actor inbox for the To handle
|
# 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, \
|
getPersonBox(baseDir,session,wfRequest,personCache, \
|
||||||
projectVersion,httpPrefix,fromDomain,postToBox)
|
projectVersion,httpPrefix,fromDomain,postToBox)
|
||||||
|
|
||||||
|
|
10
person.py
10
person.py
|
@ -179,7 +179,7 @@ def createPersonBase(baseDir: str,nickname: str,domain: str,port: int, \
|
||||||
'manuallyApprovesFollowers': False,
|
'manuallyApprovesFollowers': False,
|
||||||
'name': nickname,
|
'name': nickname,
|
||||||
'outbox': httpPrefix+'://'+domain+'/users/'+nickname+'/outbox',
|
'outbox': httpPrefix+'://'+domain+'/users/'+nickname+'/outbox',
|
||||||
'preferredUsername': ''+nickname,
|
'preferredUsername': nickname,
|
||||||
'summary': '',
|
'summary': '',
|
||||||
'publicKey': {
|
'publicKey': {
|
||||||
'id': httpPrefix+'://'+domain+'/users/'+nickname+'#main-key',
|
'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, \
|
return createInbox(baseDir,nickname,domain,port,httpPrefix, \
|
||||||
noOfItems,headerOnly,ocapAlways,pageNumber)
|
noOfItems,headerOnly,ocapAlways,pageNumber)
|
||||||
|
|
||||||
def setPreferredNickname(baseDir: str,nickname: str, domain: str, \
|
def setDisplayNickname(baseDir: str,nickname: str, domain: str, \
|
||||||
preferredName: str) -> bool:
|
displayName: str) -> bool:
|
||||||
if len(preferredName)>32:
|
if len(displayName)>32:
|
||||||
return False
|
return False
|
||||||
handle=nickname.lower()+'@'+domain.lower()
|
handle=nickname.lower()+'@'+domain.lower()
|
||||||
filename=baseDir+'/accounts/'+handle.lower()+'.json'
|
filename=baseDir+'/accounts/'+handle.lower()+'.json'
|
||||||
|
@ -456,7 +456,7 @@ def setPreferredNickname(baseDir: str,nickname: str, domain: str, \
|
||||||
personJson=commentjson.load(fp)
|
personJson=commentjson.load(fp)
|
||||||
if not personJson:
|
if not personJson:
|
||||||
return False
|
return False
|
||||||
personJson['preferredUsername']=preferredName
|
personJson['name']=displayName
|
||||||
with open(filename, 'w') as fp:
|
with open(filename, 'w') as fp:
|
||||||
commentjson.dump(personJson, fp, indent=4, sort_keys=False)
|
commentjson.dump(personJson, fp, indent=4, sort_keys=False)
|
||||||
return True
|
return True
|
||||||
|
|
16
posts.py
16
posts.py
|
@ -188,13 +188,13 @@ def getPersonBox(baseDir: str,session,wfRequest: {},personCache: {}, \
|
||||||
if personJson.get('icon'):
|
if personJson.get('icon'):
|
||||||
if personJson['icon'].get('url'):
|
if personJson['icon'].get('url'):
|
||||||
avatarUrl=personJson['icon']['url']
|
avatarUrl=personJson['icon']['url']
|
||||||
preferredName=None
|
displayName=None
|
||||||
if personJson.get('preferredUsername'):
|
if personJson.get('name'):
|
||||||
preferredName=personJson['preferredUsername']
|
displayName=personJson['name']
|
||||||
|
|
||||||
storePersonInCache(baseDir,personUrl,personJson,personCache)
|
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, \
|
def getPosts(session,outboxUrl: str,maxPosts: int, \
|
||||||
maxMentions: int, \
|
maxMentions: int, \
|
||||||
|
@ -964,7 +964,7 @@ def sendPost(projectVersion: str, \
|
||||||
postToBox='outbox'
|
postToBox='outbox'
|
||||||
|
|
||||||
# get the actor inbox for the To handle
|
# 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, \
|
getPersonBox(baseDir,session,wfRequest,personCache, \
|
||||||
projectVersion,httpPrefix,domain,postToBox)
|
projectVersion,httpPrefix,domain,postToBox)
|
||||||
|
|
||||||
|
@ -1060,7 +1060,7 @@ def sendPostViaServer(projectVersion: str, \
|
||||||
postToBox='outbox'
|
postToBox='outbox'
|
||||||
|
|
||||||
# get the actor inbox for the To handle
|
# 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, \
|
getPersonBox(baseDir,session,wfRequest,personCache, \
|
||||||
projectVersion,httpPrefix,fromDomain,postToBox)
|
projectVersion,httpPrefix,fromDomain,postToBox)
|
||||||
|
|
||||||
|
@ -1192,7 +1192,7 @@ def sendSignedJson(postJsonObject: {},session,baseDir: str, \
|
||||||
postToBox='outbox'
|
postToBox='outbox'
|
||||||
|
|
||||||
# get the actor inbox/outbox/capabilities for the To handle
|
# 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, \
|
getPersonBox(baseDir,session,wfRequest,personCache, \
|
||||||
projectVersion,httpPrefix,domain,postToBox)
|
projectVersion,httpPrefix,domain,postToBox)
|
||||||
|
|
||||||
|
@ -1820,7 +1820,7 @@ def getPublicPostsOfPerson(baseDir: str,nickname: str,domain: str, \
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
personUrl,pubKeyId,pubKey,personId,shaedInbox,capabilityAcquisition,avatarUrl,preferredName= \
|
personUrl,pubKeyId,pubKey,personId,shaedInbox,capabilityAcquisition,avatarUrl,displayName= \
|
||||||
getPersonBox(baseDir,session,wfRequest,personCache, \
|
getPersonBox(baseDir,session,wfRequest,personCache, \
|
||||||
projectVersion,httpPrefix,domain,'outbox')
|
projectVersion,httpPrefix,domain,'outbox')
|
||||||
wfResult = json.dumps(wfRequest, indent=4, sort_keys=True)
|
wfResult = json.dumps(wfRequest, indent=4, sort_keys=True)
|
||||||
|
|
2
roles.py
2
roles.py
|
@ -257,7 +257,7 @@ def sendRoleViaServer(baseDir: str,session, \
|
||||||
postToBox='outbox'
|
postToBox='outbox'
|
||||||
|
|
||||||
# get the actor inbox for the To handle
|
# 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, \
|
getPersonBox(baseDir,session,wfRequest,personCache, \
|
||||||
projectVersion,httpPrefix,delegatorDomain,postToBox)
|
projectVersion,httpPrefix,delegatorDomain,postToBox)
|
||||||
|
|
||||||
|
|
|
@ -329,7 +329,7 @@ def sendShareViaServer(baseDir,session, \
|
||||||
postToBox='outbox'
|
postToBox='outbox'
|
||||||
|
|
||||||
# get the actor inbox for the To handle
|
# 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, \
|
getPersonBox(baseDir,session,wfRequest,personCache, \
|
||||||
projectVersion,httpPrefix,fromDomain,postToBox)
|
projectVersion,httpPrefix,fromDomain,postToBox)
|
||||||
|
|
||||||
|
@ -415,7 +415,7 @@ def sendUndoShareViaServer(baseDir: str,session, \
|
||||||
postToBox='outbox'
|
postToBox='outbox'
|
||||||
|
|
||||||
# get the actor inbox for the To handle
|
# 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, \
|
getPersonBox(baseDir,session,wfRequest,personCache, \
|
||||||
projectVersion,httpPrefix,fromDomain,postToBox)
|
projectVersion,httpPrefix,fromDomain,postToBox)
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,7 @@ def sendSkillViaServer(baseDir: str,session,nickname: str,password: str,
|
||||||
postToBox='outbox'
|
postToBox='outbox'
|
||||||
|
|
||||||
# get the actor inbox for the To handle
|
# 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, \
|
getPersonBox(baseDir,session,wfRequest,personCache, \
|
||||||
projectVersion,httpPrefix,domain,postToBox)
|
projectVersion,httpPrefix,domain,postToBox)
|
||||||
|
|
||||||
|
|
4
tests.py
4
tests.py
|
@ -46,7 +46,7 @@ from follow import unfollowerOfPerson
|
||||||
from follow import getFollowersOfPerson
|
from follow import getFollowersOfPerson
|
||||||
from follow import sendFollowRequest
|
from follow import sendFollowRequest
|
||||||
from person import createPerson
|
from person import createPerson
|
||||||
from person import setPreferredNickname
|
from person import setDisplayNickname
|
||||||
from person import setBio
|
from person import setBio
|
||||||
from skills import setSkillLevel
|
from skills import setSkillLevel
|
||||||
from roles import setRole
|
from roles import setRole
|
||||||
|
@ -967,7 +967,7 @@ def testCreatePerson():
|
||||||
assert os.path.isfile(baseDir+'/accounts/passwords')
|
assert os.path.isfile(baseDir+'/accounts/passwords')
|
||||||
deleteAllPosts(baseDir,nickname,domain,'inbox')
|
deleteAllPosts(baseDir,nickname,domain,'inbox')
|
||||||
deleteAllPosts(baseDir,nickname,domain,'outbox')
|
deleteAllPosts(baseDir,nickname,domain,'outbox')
|
||||||
setPreferredNickname(baseDir,nickname,domain,'badger')
|
setDisplayNickname(baseDir,nickname,domain,'badger')
|
||||||
setBio(baseDir,nickname,domain,'Randomly roaming in your backyard')
|
setBio(baseDir,nickname,domain,'Randomly roaming in your backyard')
|
||||||
archivePostsForPerson(nickname,domain,baseDir,'inbox',None,4)
|
archivePostsForPerson(nickname,domain,baseDir,'inbox',None,4)
|
||||||
archivePostsForPerson(nickname,domain,baseDir,'outbox',None,4)
|
archivePostsForPerson(nickname,domain,baseDir,'outbox',None,4)
|
||||||
|
|
8
utils.py
8
utils.py
|
@ -61,16 +61,16 @@ def urlPermitted(url: str, federationList: [],capability: str):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def getPreferredName(actor: str,personCache: {}) -> str:
|
def getDisplayName(actor: str,personCache: {}) -> str:
|
||||||
"""Returns the preferred name for the given actor
|
"""Returns the display name for the given actor
|
||||||
"""
|
"""
|
||||||
if '/statuses/' in actor:
|
if '/statuses/' in actor:
|
||||||
actor=actor.split('/statuses/')[0]
|
actor=actor.split('/statuses/')[0]
|
||||||
if not personCache.get(actor):
|
if not personCache.get(actor):
|
||||||
return None
|
return None
|
||||||
if personCache[actor].get('actor'):
|
if personCache[actor].get('actor'):
|
||||||
if personCache[actor]['actor'].get('preferredUsername'):
|
if personCache[actor]['actor'].get('name'):
|
||||||
return personCache[actor]['actor']['preferredUsername']
|
return personCache[actor]['actor']['name']
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def getNicknameFromActor(actor: str) -> str:
|
def getNicknameFromActor(actor: str) -> str:
|
||||||
|
|
|
@ -20,7 +20,7 @@ from utils import getDomainFromActor
|
||||||
from utils import locatePost
|
from utils import locatePost
|
||||||
from utils import noOfAccounts
|
from utils import noOfAccounts
|
||||||
from utils import isPublicPost
|
from utils import isPublicPost
|
||||||
from utils import getPreferredName
|
from utils import getDisplayName
|
||||||
from follow import isFollowingActor
|
from follow import isFollowingActor
|
||||||
from webfinger import webfingerHandle
|
from webfinger import webfingerHandle
|
||||||
from posts import getPersonBox
|
from posts import getPersonBox
|
||||||
|
@ -291,13 +291,13 @@ def htmlEditProfile(baseDir: str,path: str,domain: str,port: int) -> str:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
isBot=''
|
isBot=''
|
||||||
preferredNickname=nickname
|
displayNickname=nickname
|
||||||
bioStr=''
|
bioStr=''
|
||||||
manuallyApprovesFollowers=''
|
manuallyApprovesFollowers=''
|
||||||
with open(actorFilename, 'r') as fp:
|
with open(actorFilename, 'r') as fp:
|
||||||
actorJson=commentjson.load(fp)
|
actorJson=commentjson.load(fp)
|
||||||
if actorJson.get('preferredUsername'):
|
if actorJson.get('name'):
|
||||||
preferredNickname=actorJson['preferredUsername']
|
displayNickname=actorJson['name']
|
||||||
if actorJson.get('summary'):
|
if actorJson.get('summary'):
|
||||||
bioStr=actorJson['summary'].replace('<p>','').replace('</p>','')
|
bioStr=actorJson['summary'].replace('<p>','').replace('</p>','')
|
||||||
if actorJson.get('manuallyApprovesFollowers'):
|
if actorJson.get('manuallyApprovesFollowers'):
|
||||||
|
@ -367,7 +367,7 @@ def htmlEditProfile(baseDir: str,path: str,domain: str,port: int) -> str:
|
||||||
' <a href="'+pathOriginal+'"><button class="cancelbtn">Cancel</button></a>' \
|
' <a href="'+pathOriginal+'"><button class="cancelbtn">Cancel</button></a>' \
|
||||||
' </div>'+ \
|
' </div>'+ \
|
||||||
' <div class="container">' \
|
' <div class="container">' \
|
||||||
' <input type="text" placeholder="Preferred name" name="preferredNickname" value="'+preferredNickname+'">' \
|
' <input type="text" placeholder="name" name="displayNickname" value="'+displayNickname+'">' \
|
||||||
' <textarea id="message" name="bio" placeholder="Your bio..." style="height:200px">'+bioStr+'</textarea>' \
|
' <textarea id="message" name="bio" placeholder="Your bio..." style="height:200px">'+bioStr+'</textarea>' \
|
||||||
' </div>' \
|
' </div>' \
|
||||||
' <div class="container">' \
|
' <div class="container">' \
|
||||||
|
@ -810,7 +810,7 @@ def htmlProfile(projectVersion: str, \
|
||||||
nickname=profileJson['name']
|
nickname=profileJson['name']
|
||||||
if not nickname:
|
if not nickname:
|
||||||
return ""
|
return ""
|
||||||
preferredName=profileJson['preferredUsername']
|
displayName=profileJson['name']
|
||||||
domain,port=getDomainFromActor(profileJson['id'])
|
domain,port=getDomainFromActor(profileJson['id'])
|
||||||
if not domain:
|
if not domain:
|
||||||
return ""
|
return ""
|
||||||
|
@ -886,7 +886,7 @@ def htmlProfile(projectVersion: str, \
|
||||||
' <div class="hero-image">' \
|
' <div class="hero-image">' \
|
||||||
' <div class="hero-text">'+ \
|
' <div class="hero-text">'+ \
|
||||||
' <img src="'+profileJson['icon']['url']+'" alt="'+nickname+'@'+domainFull+'">' \
|
' <img src="'+profileJson['icon']['url']+'" alt="'+nickname+'@'+domainFull+'">' \
|
||||||
' <h1>'+preferredName+'</h1>' \
|
' <h1>'+displayName+'</h1>' \
|
||||||
' <p><b>@'+nickname+'@'+domainFull+'</b></p>' \
|
' <p><b>@'+nickname+'@'+domainFull+'</b></p>' \
|
||||||
' <p>'+profileDescription+'</p>'+ \
|
' <p>'+profileDescription+'</p>'+ \
|
||||||
loginButton+ \
|
loginButton+ \
|
||||||
|
@ -959,13 +959,13 @@ def individualFollowAsHtml(baseDir: str,session,wfRequest: {}, \
|
||||||
if not avatarUrl:
|
if not avatarUrl:
|
||||||
avatarUrl=followUrl+'/avatar.png'
|
avatarUrl=followUrl+'/avatar.png'
|
||||||
if domain not in followUrl:
|
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, \
|
getPersonBox(baseDir,session,wfRequest,personCache, \
|
||||||
projectVersion,httpPrefix,domain,'outbox')
|
projectVersion,httpPrefix,domain,'outbox')
|
||||||
if avatarUrl2:
|
if avatarUrl2:
|
||||||
avatarUrl=avatarUrl2
|
avatarUrl=avatarUrl2
|
||||||
if preferredName:
|
if displayName:
|
||||||
titleStr=preferredName+' '+titleStr
|
titleStr=displayName+' '+titleStr
|
||||||
|
|
||||||
buttonsStr=''
|
buttonsStr=''
|
||||||
if authorized:
|
if authorized:
|
||||||
|
@ -1129,9 +1129,9 @@ def individualPostAsHtml(baseDir: str, \
|
||||||
if postJsonObject.get('id'):
|
if postJsonObject.get('id'):
|
||||||
messageId=postJsonObject['id'].replace('/activity','')
|
messageId=postJsonObject['id'].replace('/activity','')
|
||||||
|
|
||||||
preferredName=getPreferredName(postJsonObject['actor'],personCache)
|
displayName=getDisplayName(postJsonObject['actor'],personCache)
|
||||||
if preferredName:
|
if displayName:
|
||||||
titleStr+='<a href="'+messageId+'">'+preferredName+'</a>'
|
titleStr+='<a href="'+messageId+'">'+displayName+'</a>'
|
||||||
else:
|
else:
|
||||||
titleStr+='<a href="'+messageId+'">@'+actorNickname+'@'+actorDomain+'</a>'
|
titleStr+='<a href="'+messageId+'">@'+actorNickname+'@'+actorDomain+'</a>'
|
||||||
|
|
||||||
|
@ -1139,9 +1139,9 @@ def individualPostAsHtml(baseDir: str, \
|
||||||
if postJsonObject['object'].get('attributedTo'):
|
if postJsonObject['object'].get('attributedTo'):
|
||||||
announceNickname=getNicknameFromActor(postJsonObject['object']['attributedTo'])
|
announceNickname=getNicknameFromActor(postJsonObject['object']['attributedTo'])
|
||||||
announceDomain,announcePort=getDomainFromActor(postJsonObject['object']['attributedTo'])
|
announceDomain,announcePort=getDomainFromActor(postJsonObject['object']['attributedTo'])
|
||||||
announcePreferredName=getPreferredName(postJsonObject['object']['attributedTo'],personCache)
|
announceDisplayName=getDisplayName(postJsonObject['object']['attributedTo'],personCache)
|
||||||
if announcePreferredName:
|
if announceDisplayName:
|
||||||
titleStr+=' <img src="/icons/repeat_inactive.png" class="announceOrReply"/> <a href="'+postJsonObject['object']['id']+'">'+announcePreferredName+'</a>'
|
titleStr+=' <img src="/icons/repeat_inactive.png" class="announceOrReply"/> <a href="'+postJsonObject['object']['id']+'">'+announceDisplayName+'</a>'
|
||||||
else:
|
else:
|
||||||
titleStr+=' <img src="/icons/repeat_inactive.png" class="announceOrReply"/> <a href="'+postJsonObject['object']['id']+'">@'+announceNickname+'@'+announceDomain+'</a>'
|
titleStr+=' <img src="/icons/repeat_inactive.png" class="announceOrReply"/> <a href="'+postJsonObject['object']['id']+'">@'+announceNickname+'@'+announceDomain+'</a>'
|
||||||
else:
|
else:
|
||||||
|
@ -1155,9 +1155,9 @@ def individualPostAsHtml(baseDir: str, \
|
||||||
replyNickname=getNicknameFromActor(postJsonObject['object']['inReplyTo'])
|
replyNickname=getNicknameFromActor(postJsonObject['object']['inReplyTo'])
|
||||||
replyDomain,replyPort=getDomainFromActor(postJsonObject['object']['inReplyTo'])
|
replyDomain,replyPort=getDomainFromActor(postJsonObject['object']['inReplyTo'])
|
||||||
if replyNickname and replyDomain:
|
if replyNickname and replyDomain:
|
||||||
replyPreferredName=getPreferredName(postJsonObject['object']['inReplyTo'],personCache)
|
replyDisplayName=getDisplayName(postJsonObject['object']['inReplyTo'],personCache)
|
||||||
if replyPreferredName:
|
if replyDisplayName:
|
||||||
titleStr+=' <img src="/icons/reply.png" class="announceOrReply"/> <a href="'+postJsonObject['object']['inReplyTo']+'">'+replyPreferredName+'</a>'
|
titleStr+=' <img src="/icons/reply.png" class="announceOrReply"/> <a href="'+postJsonObject['object']['inReplyTo']+'">'+replyDisplayName+'</a>'
|
||||||
else:
|
else:
|
||||||
titleStr+=' <img src="/icons/reply.png" class="announceOrReply"/> <a href="'+postJsonObject['object']['inReplyTo']+'">@'+replyNickname+'@'+replyDomain+'</a>'
|
titleStr+=' <img src="/icons/reply.png" class="announceOrReply"/> <a href="'+postJsonObject['object']['inReplyTo']+'">@'+replyNickname+'@'+replyDomain+'</a>'
|
||||||
else:
|
else:
|
||||||
|
@ -1203,13 +1203,13 @@ def individualPostAsHtml(baseDir: str, \
|
||||||
fullDomain=domain+':'+str(port)
|
fullDomain=domain+':'+str(port)
|
||||||
|
|
||||||
if fullDomain not in postJsonObject['actor']:
|
if fullDomain not in postJsonObject['actor']:
|
||||||
inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl2,preferredName = \
|
inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl2,displayName = \
|
||||||
getPersonBox(baseDir,session,wfRequest,personCache, \
|
getPersonBox(baseDir,session,wfRequest,personCache, \
|
||||||
projectVersion,httpPrefix,domain,'outbox')
|
projectVersion,httpPrefix,domain,'outbox')
|
||||||
if avatarUrl2:
|
if avatarUrl2:
|
||||||
avatarUrl=avatarUrl2
|
avatarUrl=avatarUrl2
|
||||||
if preferredName:
|
if displayName:
|
||||||
titleStr=preferredName+' '+titleStr
|
titleStr=displayName+' '+titleStr
|
||||||
|
|
||||||
avatarDropdown= \
|
avatarDropdown= \
|
||||||
' <a href="'+postJsonObject['actor']+'">' \
|
' <a href="'+postJsonObject['actor']+'">' \
|
||||||
|
@ -1778,9 +1778,9 @@ def htmlProfileAfterSearch(baseDir: str,path: str,httpPrefix: str, \
|
||||||
avatarUrl=profileJson['icon']['url']
|
avatarUrl=profileJson['icon']['url']
|
||||||
if not avatarUrl:
|
if not avatarUrl:
|
||||||
avatarUrl=getPersonAvatarUrl(baseDir,personUrl,personCache)
|
avatarUrl=getPersonAvatarUrl(baseDir,personUrl,personCache)
|
||||||
preferredName=searchNickname
|
displayName=searchNickname
|
||||||
if profileJson.get('preferredUsername'):
|
if profileJson.get('displayUsername'):
|
||||||
preferredName=profileJson['preferredUsername']
|
displayName=profileJson['name']
|
||||||
profileDescription=''
|
profileDescription=''
|
||||||
if profileJson.get('summary'):
|
if profileJson.get('summary'):
|
||||||
profileDescription=profileJson['summary']
|
profileDescription=profileJson['summary']
|
||||||
|
@ -1807,7 +1807,7 @@ def htmlProfileAfterSearch(baseDir: str,path: str,httpPrefix: str, \
|
||||||
' <div class="hero-image">' \
|
' <div class="hero-image">' \
|
||||||
' <div class="hero-text">' \
|
' <div class="hero-text">' \
|
||||||
' <img src="'+avatarUrl+'" alt="'+searchNickname+'@'+searchDomainFull+'">' \
|
' <img src="'+avatarUrl+'" alt="'+searchNickname+'@'+searchDomainFull+'">' \
|
||||||
' <h1>'+preferredName+'</h1>' \
|
' <h1>'+displayName+'</h1>' \
|
||||||
' <p><b>@'+searchNickname+'@'+searchDomainFull+'</b></p>' \
|
' <p><b>@'+searchNickname+'@'+searchDomainFull+'</b></p>' \
|
||||||
' <p>'+profileDescription+'</p>'+ \
|
' <p>'+profileDescription+'</p>'+ \
|
||||||
' </div>' \
|
' </div>' \
|
||||||
|
|
Loading…
Reference in New Issue