Store cached actors to file

master
Bob Mottram 2019-08-20 10:16:03 +01:00
parent 0030b9fcf8
commit 8bd42b9d59
15 changed files with 105 additions and 64 deletions

View File

@ -393,7 +393,8 @@ def undoRepeatPost(session,baseDir: str,federationList: [], \
personCache,cachedWebfingers, \
debug)
def sendAnnounceViaServer(session,fromNickname: str,password: str,
def sendAnnounceViaServer(baseDir: str,session, \
fromNickname: str,password: str,
fromDomain: str,fromPort: int, \
httpPrefix: str,repeatObjectUrl: str, \
cachedWebfingers: {},personCache: {}, \
@ -445,7 +446,7 @@ def sendAnnounceViaServer(session,fromNickname: str,password: str,
# get the actor inbox for the To handle
inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \
getPersonBox(session,wfRequest,personCache, \
getPersonBox(baseDir,session,wfRequest,personCache, \
projectVersion,httpPrefix,fromDomain,postToBox)
if not inboxUrl:

View File

@ -68,7 +68,8 @@ def outboxAvailability(baseDir: str,nickname: str,messageJson: {},debug: bool) -
return setAvailability(baseDir,nickname,domain,status)
def sendAvailabilityViaServer(session,nickname: str,password: str,
def sendAvailabilityViaServer(baseDir: str,session, \
nickname: str,password: str, \
domain: str,port: int, \
httpPrefix: str, \
status: str, \
@ -111,7 +112,7 @@ def sendAvailabilityViaServer(session,nickname: str,password: str,
# get the actor inbox for the To handle
inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \
getPersonBox(session,wfRequest,personCache, \
getPersonBox(baseDir,session,wfRequest,personCache, \
projectVersion,httpPrefix,domain,postToBox)
if not inboxUrl:

View File

@ -136,7 +136,8 @@ def isBlocked(baseDir: str,nickname: str,domain: str, \
return True
return False
def sendBlockViaServer(session,fromNickname: str,password: str,
def sendBlockViaServer(baseDir: str,session, \
fromNickname: str,password: str, \
fromDomain: str,fromPort: int, \
httpPrefix: str,blockedUrl: str, \
cachedWebfingers: {},personCache: {}, \
@ -180,7 +181,7 @@ def sendBlockViaServer(session,fromNickname: str,password: str,
# get the actor inbox for the To handle
inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \
getPersonBox(session,wfRequest,personCache, \
getPersonBox(baseDir,session,wfRequest,personCache, \
projectVersion,httpPrefix,fromDomain,postToBox)
if not inboxUrl:
@ -209,7 +210,8 @@ def sendBlockViaServer(session,fromNickname: str,password: str,
return newBlockJson
def sendUndoBlockViaServer(session,fromNickname: str,password: str,
def sendUndoBlockViaServer(baseDir: str,session, \
fromNickname: str,password: str, \
fromDomain: str,fromPort: int, \
httpPrefix: str,blockedUrl: str, \
cachedWebfingers: {},personCache: {}, \
@ -257,7 +259,7 @@ def sendUndoBlockViaServer(session,fromNickname: str,password: str,
# get the actor inbox for the To handle
inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \
getPersonBox(session,wfRequest,personCache, \
getPersonBox(baseDir,session,wfRequest,personCache, \
projectVersion,httpPrefix,fromDomain,postToBox)
if not inboxUrl:

View File

@ -6,9 +6,11 @@ __maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
import os
import datetime
import commentjson
def storePersonInCache(personUrl: str,personJson: {},personCache: {}) -> None:
def storePersonInCache(baseDir: str,personUrl: str,personJson: {},personCache: {}) -> None:
"""Store an actor in the cache
"""
currTime=datetime.datetime.utcnow()
@ -16,6 +18,18 @@ def storePersonInCache(personUrl: str,personJson: {},personCache: {}) -> None:
"actor": personJson,
"timestamp": currTime.strftime("%Y-%m-%dT%H:%M:%SZ")
}
if not baseDir:
return
# store to file
if not os.path.isdir(baseDir+'/cache'):
os.mkdir(baseDir+'/cache')
if not os.path.isdir(baseDir+'/cache/actors'):
os.mkdir(baseDir+'/cache/actors')
cacheFilename=baseDir+'/cache/actors/'+personUrl.replace('/','#')+'.json'
if not os.path.isfile(cacheFilename):
with open(cacheFilename, 'w') as fp:
commentjson.dump(personJson, fp, indent=4, sort_keys=False)
def storeWebfingerInCache(handle: str,wf,cachedWebfingers: {}) -> None:
"""Store a webfinger endpoint in the cache

View File

@ -82,7 +82,8 @@ def createDelete(session,baseDir: str,federationList: [], \
return newDelete
def sendDeleteViaServer(session,fromNickname: str,password: str,
def sendDeleteViaServer(baseDir: str,session, \
fromNickname: str,password: str, \
fromDomain: str,fromPort: int, \
httpPrefix: str,deleteObjectUrl: str, \
cachedWebfingers: {},personCache: {}, \
@ -125,7 +126,7 @@ def sendDeleteViaServer(session,fromNickname: str,password: str,
# get the actor inbox for the To handle
inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \
getPersonBox(session,wfRequest,personCache, \
getPersonBox(baseDir,session,wfRequest,personCache, \
projectVersion,httpPrefix,fromDomain,postToBox)
if not inboxUrl:

View File

@ -295,7 +295,7 @@ if args.posts:
args.port=443
nickname=args.posts.split('@')[0]
domain=args.posts.split('@')[1]
getPublicPostsOfPerson(nickname,domain,False,True, \
getPublicPostsOfPerson(baseDir,nickname,domain,False,True, \
args.tor,args.port,httpPrefix,debug, \
__version__)
sys.exit()
@ -308,7 +308,7 @@ if args.postsraw:
args.port=443
nickname=args.postsraw.split('@')[0]
domain=args.postsraw.split('@')[1]
getPublicPostsOfPerson(nickname,domain,False,False, \
getPublicPostsOfPerson(baseDir,nickname,domain,False,False, \
args.tor,args.port,httpPrefix,debug, \
__version__)
sys.exit()
@ -543,7 +543,7 @@ if args.announce:
cachedWebfingers={}
print('Sending announce/repeat of '+args.announce)
sendAnnounceViaServer(session,args.nickname,args.password,
sendAnnounceViaServer(baseDir,session,args.nickname,args.password,
domain,port, \
httpPrefix,args.announce, \
cachedWebfingers,personCache, \
@ -587,7 +587,7 @@ if args.itemName:
cachedWebfingers={}
print('Sending shared item: '+args.itemName)
sendShareViaServer(session, \
sendShareViaServer(baseDir,session, \
args.nickname,args.password, \
domain,port, \
httpPrefix, \
@ -645,7 +645,8 @@ if args.like:
cachedWebfingers={}
print('Sending like of '+args.like)
sendLikeViaServer(session,args.nickname,args.password,
sendLikeViaServer(baseDir,session, \
args.nickname,args.password, \
domain,port, \
httpPrefix,args.like, \
cachedWebfingers,personCache, \
@ -669,7 +670,8 @@ if args.undolike:
cachedWebfingers={}
print('Sending undo like of '+args.undolike)
sendUndoLikeViaServer(session,args.nickname,args.password,
sendUndoLikeViaServer(baseDir,session, \
args.nickname,args.password, \
domain,port, \
httpPrefix,args.undolike, \
cachedWebfingers,personCache, \
@ -693,7 +695,8 @@ if args.delete:
cachedWebfingers={}
print('Sending delete request of '+args.delete)
sendDeleteViaServer(session,args.nickname,args.password,
sendDeleteViaServer(baseDir,session, \
args.nickname,args.password, \
domain,port, \
httpPrefix,args.delete, \
cachedWebfingers,personCache, \
@ -725,7 +728,8 @@ if args.follow:
if args.follow.startswith('https'):
followHttpPrefix='https'
sendFollowRequestViaServer(session,args.nickname,args.password, \
sendFollowRequestViaServer(baseDir,session, \
args.nickname,args.password, \
domain,port, \
followNickname,followDomain,followPort, \
httpPrefix, \
@ -759,7 +763,8 @@ if args.unfollow:
if args.follow.startswith('https'):
followHttpPrefix='https'
sendUnfollowRequestViaServer(session,args.nickname,args.password, \
sendUnfollowRequestViaServer(baseDir,session, \
args.nickname,args.password, \
domain,port, \
followNickname,followDomain,followPort, \
httpPrefix, \
@ -985,7 +990,8 @@ if args.skill:
cachedWebfingers={}
print('Sending '+args.skill+' skill level '+str(args.skillLevelPercent)+' for '+nickname)
sendSkillViaServer(session,nickname,args.password,
sendSkillViaServer(baseDir,session, \
nickname,args.password, \
domain,port, \
httpPrefix, \
args.skill,args.skillLevelPercent, \
@ -1010,7 +1016,7 @@ if args.availability:
cachedWebfingers={}
print('Sending availability status of '+nickname+' as '+args.availability)
sendAvailabilityViaServer(session,nickname,args.password,
sendAvailabilityViaServer(baseDir,session,nickname,args.password,
domain,port, \
httpPrefix, \
args.availability, \
@ -1055,7 +1061,7 @@ if args.block:
cachedWebfingers={}
print('Sending block of '+args.block)
sendBlockViaServer(session,nickname,args.password,
sendBlockViaServer(baseDir,session,nickname,args.password,
domain,port, \
httpPrefix,args.block, \
cachedWebfingers,personCache, \
@ -1091,7 +1097,8 @@ if args.delegate:
cachedWebfingers={}
print('Sending delegation for '+args.delegate+' with role '+args.role+' in project '+args.project)
sendRoleViaServer(session,nickname,args.password,
sendRoleViaServer(baseDir,session, \
nickname,args.password, \
domain,port, \
httpPrefix,args.delegate, \
args.project,args.role, \
@ -1124,7 +1131,8 @@ if args.undelegate:
cachedWebfingers={}
print('Sending delegation removal for '+args.undelegate+' from role '+args.role+' in project '+args.project)
sendRoleViaServer(session,nickname,args.password,
sendRoleViaServer(baseDir,session, \
nickname,args.password, \
domain,port, \
httpPrefix,args.delegate, \
args.project,None, \
@ -1159,7 +1167,7 @@ if args.unblock:
cachedWebfingers={}
print('Sending undo block of '+args.unblock)
sendUndoBlockViaServer(session,nickname,args.password,
sendUndoBlockViaServer(baseDir,session,nickname,args.password,
domain,port, \
httpPrefix,args.unblock, \
cachedWebfingers,personCache, \

View File

@ -508,7 +508,8 @@ def sendFollowRequest(session,baseDir: str, \
return newFollowJson
def sendFollowRequestViaServer(session,fromNickname: str,password: str,
def sendFollowRequestViaServer(baseDir: str,session, \
fromNickname: str,password: str, \
fromDomain: str,fromPort: int, \
followNickname: str,followDomain: str,followPort: int, \
httpPrefix: str, \
@ -558,7 +559,7 @@ def sendFollowRequestViaServer(session,fromNickname: str,password: str,
# get the actor inbox for the To handle
inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \
getPersonBox(session,wfRequest,personCache, \
getPersonBox(baseDir,session,wfRequest,personCache, \
projectVersion,httpPrefix,fromDomain,postToBox)
if not inboxUrl:
@ -587,7 +588,8 @@ def sendFollowRequestViaServer(session,fromNickname: str,password: str,
return newFollowJson
def sendUnfollowRequestViaServer(session,fromNickname: str,password: str,
def sendUnfollowRequestViaServer(baseDir: str,session, \
fromNickname: str,password: str, \
fromDomain: str,fromPort: int, \
followNickname: str,followDomain: str,followPort: int, \
httpPrefix: str, \
@ -641,7 +643,7 @@ def sendUnfollowRequestViaServer(session,fromNickname: str,password: str,
# get the actor inbox for the To handle
inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \
getPersonBox(session,wfRequest,personCache, \
getPersonBox(baseDir,session,wfRequest,personCache, \
projectVersion,httpPrefix,fromDomain,postToBox)
if not inboxUrl:

View File

@ -85,7 +85,8 @@ def validInboxFilenames(baseDir: str,nickname: str,domain: str, \
return False
return True
def getPersonPubKey(session,personUrl: str,personCache: {},debug: bool, \
def getPersonPubKey(baseDir: str,session,personUrl: str, \
personCache: {},debug: bool, \
projectVersion: str,httpPrefix: str,domain: str) -> str:
if not personUrl:
return None
@ -114,7 +115,7 @@ def getPersonPubKey(session,personUrl: str,personCache: {},debug: bool, \
if debug:
print('DEBUG: Public key not found for '+personUrl)
storePersonInCache(personUrl,personJson,personCache)
storePersonInCache(baseDir,personUrl,personJson,personCache)
return pubKey
def inboxMessageHasParams(messageJson: {}) -> bool:
@ -1168,7 +1169,8 @@ def runInboxQueue(projectVersion: str, \
continue
pubKey= \
getPersonPubKey(session,keyId,personCache,debug, \
getPersonPubKey(baseDir,session,keyId, \
personCache,debug, \
projectVersion,httpPrefix,domain)
if pubKey:
print('DEBUG: public key: '+str(pubKey))

10
like.py
View File

@ -310,7 +310,8 @@ def undoLikePost(session,baseDir: str,federationList: [], \
ccList,httpPrefix,objectUrl,clientToServer, \
sendThreads,postLog,personCache,cachedWebfingers,debug)
def sendLikeViaServer(session,fromNickname: str,password: str,
def sendLikeViaServer(baseDir: str,session, \
fromNickname: str,password: str,
fromDomain: str,fromPort: int, \
httpPrefix: str,likeUrl: str, \
cachedWebfingers: {},personCache: {}, \
@ -354,7 +355,7 @@ def sendLikeViaServer(session,fromNickname: str,password: str,
# get the actor inbox for the To handle
inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \
getPersonBox(session,wfRequest,personCache, \
getPersonBox(baseDir,session,wfRequest,personCache, \
projectVersion,httpPrefix,fromDomain,postToBox)
if not inboxUrl:
@ -383,7 +384,8 @@ def sendLikeViaServer(session,fromNickname: str,password: str,
return newLikeJson
def sendUndoLikeViaServer(session,fromNickname: str,password: str,
def sendUndoLikeViaServer(baseDir: str,session, \
fromNickname: str,password: str, \
fromDomain: str,fromPort: int, \
httpPrefix: str,likeUrl: str, \
cachedWebfingers: {},personCache: {}, \
@ -431,7 +433,7 @@ def sendUndoLikeViaServer(session,fromNickname: str,password: str,
# get the actor inbox for the To handle
inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \
getPersonBox(session,wfRequest,personCache, \
getPersonBox(baseDir,session,wfRequest,personCache, \
projectVersion,httpPrefix,fromDomain,postToBox)
if not inboxUrl:

View File

@ -139,7 +139,7 @@ def parseUserFeed(session,feedUrl: str,asHeader: {}, \
projectVersion,httpPrefix,domain):
yield item
def getPersonBox(session,wfRequest: {},personCache: {}, \
def getPersonBox(baseDir: str,session,wfRequest: {},personCache: {}, \
projectVersion: str,httpPrefix: str,domain: str, \
boxName='inbox') -> (str,str,str,str,str,str,str,str):
asHeader = {'Accept': 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'}
@ -191,7 +191,7 @@ def getPersonBox(session,wfRequest: {},personCache: {}, \
if personJson.get('preferredUsername'):
preferredName=personJson['preferredUsername']
storePersonInCache(personUrl,personJson,personCache)
storePersonInCache(baseDir,personUrl,personJson,personCache)
return boxJson,pubKeyId,pubKey,personId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName
@ -959,7 +959,7 @@ def sendPost(projectVersion: str, \
# get the actor inbox for the To handle
inboxUrl,pubKeyId,pubKey,toPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \
getPersonBox(session,wfRequest,personCache, \
getPersonBox(baseDir,session,wfRequest,personCache, \
projectVersion,httpPrefix,domain,postToBox)
# If there are more than one followers on the target domain
@ -1022,7 +1022,7 @@ def sendPost(projectVersion: str, \
return 0
def sendPostViaServer(projectVersion: str, \
baseDir,session,fromNickname: str,password: str, \
baseDir: str,session,fromNickname: str,password: str, \
fromDomain: str, fromPort: int, \
toNickname: str, toDomain: str, toPort: int, cc: str, \
httpPrefix: str, content: str, followersOnly: bool, \
@ -1055,7 +1055,7 @@ def sendPostViaServer(projectVersion: str, \
# get the actor inbox for the To handle
inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \
getPersonBox(session,wfRequest,personCache, \
getPersonBox(baseDir,session,wfRequest,personCache, \
projectVersion,httpPrefix,fromDomain,postToBox)
if not inboxUrl:
@ -1187,7 +1187,7 @@ def sendSignedJson(postJsonObject: {},session,baseDir: str, \
# get the actor inbox/outbox/capabilities for the To handle
inboxUrl,pubKeyId,pubKey,toPersonId,sharedInboxUrl,capabilityAcquisition,avatarUrl,preferredName = \
getPersonBox(session,wfRequest,personCache, \
getPersonBox(baseDir,session,wfRequest,personCache, \
projectVersion,httpPrefix,domain,postToBox)
if nickname=='capabilities':
@ -1769,7 +1769,7 @@ def archivePostsForPerson(httpPrefix: str,nickname: str,domain: str,baseDir: str
if noOfPosts <= maxPostsInBox:
break
def getPublicPostsOfPerson(nickname: str,domain: str, \
def getPublicPostsOfPerson(baseDir: str,nickname: str,domain: str, \
raw: bool,simple: bool,useTor: bool, \
port: int,httpPrefix: str, \
debug: bool,projectVersion: str) -> None:
@ -1793,7 +1793,7 @@ def getPublicPostsOfPerson(nickname: str,domain: str, \
sys.exit()
personUrl,pubKeyId,pubKey,personId,shaedInbox,capabilityAcquisition,avatarUrl,preferredName= \
getPersonBox(session,wfRequest,personCache, \
getPersonBox(baseDir,session,wfRequest,personCache, \
projectVersion,httpPrefix,domain,'outbox')
wfResult = json.dumps(wfRequest, indent=4, sort_keys=True)

View File

@ -203,7 +203,8 @@ def outboxDelegate(baseDir: str,authenticatedNickname: str,messageJson: {},debug
print(nickname+'@'+domain+' assigned to the role '+role+' within the project '+project)
return True
def sendRoleViaServer(session,delegatorNickname: str,password: str,
def sendRoleViaServer(baseDir: str,session, \
delegatorNickname: str,password: str, \
delegatorDomain: str,delegatorPort: int, \
httpPrefix: str,nickname: str, \
project: str,role: str, \
@ -257,7 +258,7 @@ def sendRoleViaServer(session,delegatorNickname: str,password: str,
# get the actor inbox for the To handle
inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \
getPersonBox(session,wfRequest,personCache, \
getPersonBox(baseDir,session,wfRequest,personCache, \
projectVersion,httpPrefix,delegatorDomain,postToBox)
if not inboxUrl:

View File

@ -267,7 +267,8 @@ def getSharesFeedForPerson(baseDir: str, \
shares['next']=httpPrefix+'://'+domain+'/users/'+nickname+'/shares?page='+str(lastPage)
return shares
def sendShareViaServer(session,fromNickname: str,password: str,
def sendShareViaServer(baseDir,session, \
fromNickname: str,password: str, \
fromDomain: str,fromPort: int, \
httpPrefix: str, \
displayName: str, \
@ -329,7 +330,7 @@ def sendShareViaServer(session,fromNickname: str,password: str,
# get the actor inbox for the To handle
inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \
getPersonBox(session,wfRequest,personCache, \
getPersonBox(baseDir,session,wfRequest,personCache, \
projectVersion,httpPrefix,fromDomain,postToBox)
if not inboxUrl:
@ -364,7 +365,8 @@ def sendShareViaServer(session,fromNickname: str,password: str,
return newShareJson
def sendUndoShareViaServer(session,fromNickname: str,password: str,
def sendUndoShareViaServer(baseDir: str,session, \
fromNickname: str,password: str, \
fromDomain: str,fromPort: int, \
httpPrefix: str, \
displayName: str, \
@ -414,7 +416,7 @@ def sendUndoShareViaServer(session,fromNickname: str,password: str,
# get the actor inbox for the To handle
inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \
getPersonBox(session,wfRequest,personCache, \
getPersonBox(baseDir,session,wfRequest,personCache, \
projectVersion,httpPrefix,fromDomain,postToBox)
if not inboxUrl:

View File

@ -85,7 +85,7 @@ def outboxSkills(baseDir: str,nickname: str,messageJson: {},debug: bool) -> bool
return setSkillLevel(baseDir,nickname,domain, \
skill,skillLevelPercent)
def sendSkillViaServer(session,nickname: str,password: str,
def sendSkillViaServer(baseDir: str,session,nickname: str,password: str,
domain: str,port: int, \
httpPrefix: str, \
skill: str,skillLevelPercent: int, \
@ -132,7 +132,7 @@ def sendSkillViaServer(session,nickname: str,password: str,
# get the actor inbox for the To handle
inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,preferredName = \
getPersonBox(session,wfRequest,personCache, \
getPersonBox(baseDir,session,wfRequest,personCache, \
projectVersion,httpPrefix,domain,postToBox)
if not inboxUrl:

View File

@ -146,7 +146,7 @@ def testCache():
personUrl="cat@cardboard.box"
personJson={ "id": 123456, "test": "This is a test" }
personCache={}
storePersonInCache(personUrl,personJson,personCache)
storePersonInCache(None,personUrl,personJson,personCache)
result=getPersonFromCache(personUrl,personCache)
assert result['id']==123456
assert result['test']=='This is a test'
@ -1190,7 +1190,8 @@ def testClientToServer():
assert validInboxFilenames(bobDir,'bob',bobDomain,aliceDomain,alicePort)
print('\n\nAlice follows Bob')
sendFollowRequestViaServer(sessionAlice,'alice',password, \
sendFollowRequestViaServer(aliceDir,sessionAlice, \
'alice',password, \
aliceDomain,alicePort, \
'bob',bobDomain,bobPort, \
httpPrefix, \
@ -1212,7 +1213,8 @@ def testClientToServer():
assert validInboxFilenames(bobDir,'bob',bobDomain,aliceDomain,alicePort)
print('\n\nBob follows Alice')
sendFollowRequestViaServer(sessionAlice,'bob','bobpass', \
sendFollowRequestViaServer(aliceDir,sessionAlice, \
'bob','bobpass', \
bobDomain,bobPort, \
'alice',aliceDomain,alicePort, \
httpPrefix, \
@ -1241,7 +1243,8 @@ def testClientToServer():
assert len([name for name in os.listdir(outboxPath) if os.path.isfile(os.path.join(outboxPath, name))])==1
print(str(len([name for name in os.listdir(inboxPath) if os.path.isfile(os.path.join(inboxPath, name))])))
assert len([name for name in os.listdir(inboxPath) if os.path.isfile(os.path.join(inboxPath, name))])==1
sendLikeViaServer(sessionBob,'bob','bobpass', \
sendLikeViaServer(bobDir,sessionBob, \
'bob','bobpass', \
bobDomain,bobPort, \
httpPrefix,outboxPostId, \
cachedWebfingers,personCache, \
@ -1261,7 +1264,7 @@ def testClientToServer():
assert len([name for name in os.listdir(outboxPath) if os.path.isfile(os.path.join(outboxPath, name))])==2
print(str(len([name for name in os.listdir(inboxPath) if os.path.isfile(os.path.join(inboxPath, name))])))
assert len([name for name in os.listdir(inboxPath) if os.path.isfile(os.path.join(inboxPath, name))])==1
sendAnnounceViaServer(sessionBob,'bob',password, \
sendAnnounceViaServer(bobDir,sessionBob,'bob',password, \
bobDomain,bobPort, \
httpPrefix,outboxPostId, \
cachedWebfingers, \
@ -1283,7 +1286,7 @@ def testClientToServer():
postsBefore = len([name for name in os.listdir(inboxPath) if os.path.isfile(os.path.join(inboxPath, name))])
print('\n\nAlice deletes her post: '+outboxPostId+' '+str(postsBefore))
password='alicepass'
sendDeleteViaServer(sessionAlice,'alice',password,
sendDeleteViaServer(aliceDir,sessionAlice,'alice',password,
aliceDomain,alicePort, \
httpPrefix,outboxPostId, \
cachedWebfingers,personCache, \
@ -1302,7 +1305,8 @@ def testClientToServer():
print('\n\nAlice unfollows Bob')
password='alicepass'
sendUnfollowRequestViaServer(sessionAlice,'alice',password, \
sendUnfollowRequestViaServer(baseDir,sessionAlice, \
'alice',password, \
aliceDomain,alicePort, \
'bob',bobDomain,bobPort, \
httpPrefix, \

View File

@ -738,7 +738,8 @@ def htmlProfileFollowing(baseDir: str,httpPrefix: str, \
profileStr=''
for item in followingJson['orderedItems']:
profileStr+= \
individualFollowAsHtml(session,wfRequest,personCache, \
individualFollowAsHtml(baseDir,session, \
wfRequest,personCache, \
domain,item,authorized,nickname, \
httpPrefix,projectVersion, \
buttons)
@ -935,7 +936,7 @@ def htmlProfile(projectVersion: str, \
profileStr=htmlHeader(profileStyle)+profileStr+htmlFooter()
return profileStr
def individualFollowAsHtml(session,wfRequest: {}, \
def individualFollowAsHtml(baseDir: str,session,wfRequest: {}, \
personCache: {},domain: str, \
followUrl: str, \
authorized: bool, \
@ -951,7 +952,7 @@ def individualFollowAsHtml(session,wfRequest: {}, \
avatarUrl=followUrl+'/avatar.png'
if domain not in followUrl:
inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl2,preferredName = \
getPersonBox(session,wfRequest,personCache, \
getPersonBox(baseDir,session,wfRequest,personCache, \
projectVersion,httpPrefix,domain,'outbox')
if avatarUrl2:
avatarUrl=avatarUrl2
@ -1104,7 +1105,7 @@ def individualPostAsHtml(baseDir: str, \
if fullDomain not in postJsonObject['actor']:
inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl2,preferredName = \
getPersonBox(session,wfRequest,personCache, \
getPersonBox(baseDir,session,wfRequest,personCache, \
projectVersion,httpPrefix,domain,'outbox')
if avatarUrl2:
avatarUrl=avatarUrl2