From 709e06b8db18cffbca14d29a72428f6467b11c83 Mon Sep 17 00:00:00 2001 From: Ryan Barrett Date: Wed, 5 Feb 2025 08:29:54 -0800 Subject: [PATCH] DMs bug fix: handle args to commands that don't take them fixes https://console.cloud.google.com/errors/detail/CMz90p7Rtq_IcA;time=P1D;locations=global?project=bridgy-federated --- dms.py | 2 +- tests/test_dms.py | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/dms.py b/dms.py index 5e21ec81..d029db8f 100644 --- a/dms.py +++ b/dms.py @@ -85,7 +85,7 @@ def reply(text, type=None): # dispatch! kwargs = {} - if cmd_arg: + if arg and cmd_arg: kwargs['arg'] = cmd_arg if arg == 'handle': kwargs['to_user'] = to_user diff --git a/tests/test_dms.py b/tests/test_dms.py index 281c3221..b1248b99 100644 --- a/tests/test_dms.py +++ b/tests/test_dms.py @@ -463,18 +463,21 @@ def test_receive_help_strip_mention_of_bot(self): self.assert_replied(OtherFake, alice, '?', "

Hi! I'm a friendly bot") def test_receive_did_atproto(self): - self.make_user(id='bsky.brid.gy', cls=Web) - alice = self.make_user(id='efake:alice', cls=ExplicitFake, - enabled_protocols=['atproto'], obj_as1={'x': 'y'}, - copies=[Target(protocol='atproto', uri='did:abc:123')]) - obj = Object(our_as1={ - **DM_BASE, - 'to': ['bsky.brid.gy'], - 'content': 'did', - }) - self.assertEqual(('OK', 200), receive(from_user=alice, obj=obj)) - self.assert_replied(ATProto, alice, '?', - 'Your DID is did:abc:123') + for content in 'did', 'did foo': + ExplicitFake.sent = [] + with self.subTest(content=content): + self.make_user(id='bsky.brid.gy', cls=Web) + alice = self.make_user(id='efake:alice', cls=ExplicitFake, + enabled_protocols=['atproto'], obj_as1={'x': 'y'}, + copies=[Target(protocol='atproto', uri='did:abc:123')]) + obj = Object(our_as1={ + **DM_BASE, + 'to': ['bsky.brid.gy'], + 'content': 'did', + }) + self.assertEqual(('OK', 200), receive(from_user=alice, obj=obj)) + self.assert_replied(ATProto, alice, '?', + 'Your DID is did:abc:123') def test_receive_block(self): alice, bob = self.make_alice_bob()