diff --git a/daemon.py b/daemon.py index 762e0d9b0..b3a48c3f5 100644 --- a/daemon.py +++ b/daemon.py @@ -390,7 +390,10 @@ class PubServer(BaseHTTPRequestHandler): # get an individual post from the path /@nickname/statusnumber if '/@' in self.path: namedStatus=self.path.split('/@')[1] - if '/' in namedStatus: + if '/' not in namedStatus: + # show actor + nickname=namedStatus + else: postSections=namedStatus.split('/') if len(postSections)==2: nickname=postSections[0] diff --git a/epicyon.py b/epicyon.py index 0fa99c532..044b8ffa8 100644 --- a/epicyon.py +++ b/epicyon.py @@ -243,13 +243,17 @@ if args.testsnetwork: testClientToServer() sys.exit() +httpPrefix='https' +if args.http: + httpPrefix='http' + if args.posts: if '@' not in args.posts: print('Syntax: --posts nickname@domain') sys.exit() nickname=args.posts.split('@')[0] domain=args.posts.split('@')[1] - getPublicPostsOfPerson(nickname,domain,False,True) + getPublicPostsOfPerson(nickname,domain,False,True,args.tor,args.port,httpPrefix) sys.exit() if args.postsraw: @@ -258,7 +262,7 @@ if args.postsraw: sys.exit() nickname=args.postsraw.split('@')[0] domain=args.postsraw.split('@')[1] - getPublicPostsOfPerson(nickname,domain,True,False) + getPublicPostsOfPerson(nickname,domain,False,False,args.tor,args.port,httpPrefix) sys.exit() baseDir=args.baseDir @@ -284,10 +288,6 @@ nickname=None if args.nickname: nickname=nickname -httpPrefix='https' -if args.http: - httpPrefix='http' - federationList=[] if args.federationList: if len(args.federationList)==1: diff --git a/posts.py b/posts.py index e8c1ae109..fbf111224 100644 --- a/posts.py +++ b/posts.py @@ -1262,23 +1262,27 @@ def archivePostsForPerson(httpPrefix: str,nickname: str,domain: str,baseDir: str break def getPublicPostsOfPerson(nickname: str,domain: str, \ - raw: bool,simple: bool) -> None: + raw: bool,simple: bool,useTor: bool, \ + port: int,httpPrefix: str) -> None: """ This is really just for test purposes """ - useTor=True - port=443 + print("Test1") session = createSession(domain,port,useTor) personCache={} cachedWebfingers={} federationList=[] - httpPrefix='https' - handle=httpPrefix+"://"+domain+"/@"+nickname + domainFull=domain + if port!=80 and port!=443: + domainFull=domain+':'+str(port) + handle=httpPrefix+"://"+domainFull+"/@"+nickname + print("Test2 "+handle) wfRequest = \ webfingerHandle(session,handle,httpPrefix,cachedWebfingers) if not wfRequest: sys.exit() + print('Test3') personUrl,pubKeyId,pubKey,personId,shaedInbox,capabilityAcquisition= \ getPersonBox(session,wfRequest,personCache,'outbox') wfResult = json.dumps(wfRequest, indent=4, sort_keys=True) @@ -1286,6 +1290,7 @@ def getPublicPostsOfPerson(nickname: str,domain: str, \ maxMentions=10 maxEmoji=10 maxAttachments=5 + print('personUrl: '+personUrl) userPosts = getPosts(session,personUrl,30,maxMentions,maxEmoji, \ maxAttachments,federationList, \ personCache,raw,simple) diff --git a/session.py b/session.py index da3a98444..d9f3b3827 100644 --- a/session.py +++ b/session.py @@ -39,7 +39,10 @@ def getJson(session,url: str,headers: {},params: {}) -> {}: result=session.get(url, headers=sessionHeaders, params=sessionParams) return result.json() except: - pass + print('ERROR: getJson failed') + print('url: '+url) + print('headers: '+str(sessionHeaders)) + print('params: '+str(sessionParams)) return None def postJson(session,postJsonObject: {},federationList: [],inboxUrl: str,headers: {},capability: str) -> str: diff --git a/webfinger.py b/webfinger.py index 50c85418d..fe15340e1 100644 --- a/webfinger.py +++ b/webfinger.py @@ -35,13 +35,13 @@ def parseHandle(handle: str) -> (str,str): return nickname, domain - def webfingerHandle(session,handle: str,httpPrefix: str,cachedWebfingers: {}) -> {}: if not session: print('WARN: No session specified for webfingerHandle') return None - + nickname, domain = parseHandle(handle) + print('wfTest2 '+nickname+' '+domain) if not nickname: return None wfDomain=domain @@ -53,14 +53,13 @@ def webfingerHandle(session,handle: str,httpPrefix: str,cachedWebfingers: {}) -> url = '{}://{}/.well-known/webfinger'.format(httpPrefix,domain) par = {'resource': 'acct:{}'.format(nickname+'@'+wfDomain)} hdr = {'Accept': 'application/jrd+json'} - #print('webfinger url: '+url) - #print('webfinger par: '+str(par)) - #print('webfinger hdr: '+str(hdr)) try: result = getJson(session, url, hdr, par) except: + print("Unable to webfinger " + url) + print('headers: '+str(hdr)) + print('params: '+str(par)) return None - # print("Unable to webfinger " + url + ' ' + str(hdr) + ' ' + str(par)) storeWebfingerInCache(nickname+'@'+wfDomain,result,cachedWebfingers) return result