kopia lustrzana https://github.com/snarfed/bridgy-fed
bluesky: misc minor XPRC error handling
rodzic
a66fe4bdc2
commit
c1148ee3de
|
@ -48,6 +48,10 @@ class XrpcActorTest(testutil.TestCase):
|
|||
},
|
||||
}, resp.json)
|
||||
|
||||
def test_getProfile_unset(self, _):
|
||||
resp = self.client.get('/xrpc/app.bsky.actor.getProfile')
|
||||
self.assertEqual(400, resp.status_code)
|
||||
|
||||
def test_getProfile_not_domain(self, _):
|
||||
resp = self.client.get('/xrpc/app.bsky.actor.getProfile',
|
||||
query_string={'actor': 'not a domain'})
|
||||
|
|
|
@ -100,6 +100,10 @@ class XrpcFeedTest(testutil.TestCase):
|
|||
'feed': [POST_BSKY, REPLY_BSKY, REPOST_BSKY],
|
||||
}, resp.json)
|
||||
|
||||
def test_getAuthorFeed_unset(self, _):
|
||||
resp = self.client.get('/xrpc/app.bsky.feed.getAuthorFeed')
|
||||
self.assertEqual(400, resp.status_code)
|
||||
|
||||
def test_getAuthorFeed_not_domain(self, _):
|
||||
resp = self.client.get('/xrpc/app.bsky.feed.getAuthorFeed',
|
||||
query_string={'author': 'not a domain'})
|
||||
|
@ -127,6 +131,10 @@ class XrpcFeedTest(testutil.TestCase):
|
|||
self.assertEqual(200, resp.status_code, resp.get_data(as_text=True))
|
||||
self.assert_equals(POST_THREAD_BSKY, resp.json)
|
||||
|
||||
def test_getPostThread_unset(self, mock_get):
|
||||
mock_get.return_value = requests_response(status=500)
|
||||
resp = self.client.get('/xrpc/app.bsky.feed.getPostThread')
|
||||
self.assertEqual(400, resp.status_code)
|
||||
|
||||
def test_getPostThread_fetch_fails(self, mock_get):
|
||||
mock_get.return_value = requests_response(status=500)
|
||||
|
|
|
@ -19,7 +19,7 @@ def getProfile(input, actor=None):
|
|||
"""
|
||||
# TODO: actor is either handle or DID
|
||||
# see actorWhereClause in atproto/packages/pds/src/db/util.ts
|
||||
if not re.match(util.DOMAIN_RE, actor):
|
||||
if not actor or not re.match(util.DOMAIN_RE, actor):
|
||||
raise ValueError(f'{actor} is not a domain')
|
||||
|
||||
url = f'https://{actor}/'
|
||||
|
|
|
@ -18,7 +18,7 @@ def getAuthorFeed(input, author=None, limit=None, before=None):
|
|||
"""
|
||||
lexicons/app/bsky/feed/getAuthorFeed.json, feedViewPost.json
|
||||
"""
|
||||
if not re.match(util.DOMAIN_RE, author):
|
||||
if not author or not re.match(util.DOMAIN_RE, author):
|
||||
raise ValueError(f'{author} is not a domain')
|
||||
|
||||
url = f'https://{author}/'
|
||||
|
@ -54,6 +54,9 @@ def getPostThread(input, uri=None, depth=None):
|
|||
"""
|
||||
lexicons/app/bsky/feed/getPostThread.json
|
||||
"""
|
||||
if not uri:
|
||||
raise ValueError('Missing uri')
|
||||
|
||||
mf2 = util.fetch_mf2(uri, gateway=True)
|
||||
logger.info(f'Got mf2: {json.dumps(mf2, indent=2)}')
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue