From 2b2dfafc18645b6bcf1f03c6849879e9d371b12e Mon Sep 17 00:00:00 2001 From: Ryan Barrett Date: Sun, 15 Jan 2023 10:07:04 -0800 Subject: [PATCH] bluesky: app.bsky.graph.getFollowers, handle no user --- tests/test_xrpc_graph.py | 4 ++++ xrpc_graph.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_xrpc_graph.py b/tests/test_xrpc_graph.py index 5fe95fc..51f5df9 100644 --- a/tests/test_xrpc_graph.py +++ b/tests/test_xrpc_graph.py @@ -45,6 +45,10 @@ OTHER_FOLLOW_AS2['actor'].update({ @patch('requests.get') class XrpcGraphTest(testutil.TestCase): + def test_getProfile_no_user(self, _): + resp = self.client.get('/xrpc/app.bsky.graph.getFollowers') + self.assertEqual(400, resp.status_code) + def test_getFollowers_not_domain(self, mock_get): resp = self.client.get('/xrpc/app.bsky.graph.getFollowers', query_string={'user': 'not a domain'}) diff --git a/xrpc_graph.py b/xrpc_graph.py index 2448ecd..fb63813 100644 --- a/xrpc_graph.py +++ b/xrpc_graph.py @@ -22,7 +22,7 @@ def get_followers(query_prop, output_field, user=None, limit=50, before=None): dict, XRPC method output """ # TODO: what is user? - if not re.match(util.DOMAIN_RE, user): + if not user or not re.match(util.DOMAIN_RE, user): raise ValueError(f'{user} is not a domain') followers = []