From 5b7f8de8d696cf664ccf22078b1101f62365da0e Mon Sep 17 00:00:00 2001 From: Ryan Barrett Date: Sat, 8 Jun 2024 16:40:19 -0700 Subject: [PATCH] ATProto.send: handle delete when we have Object but not contents fixes https://console.cloud.google.com/errors/detail/COjSuYPS0qLvmAE;time=P30D?project=bridgy-federated --- atproto.py | 4 ++-- tests/test_atproto.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/atproto.py b/atproto.py index 4f8c2e7..939c3a5 100644 --- a/atproto.py +++ b/atproto.py @@ -420,9 +420,9 @@ class ATProto(User, Protocol): if type in ('post', 'update', 'delete'): obj_as1 = as1.get_object(obj.as1) base_obj = PROTOCOLS[obj.source_protocol].load(obj_as1['id']) - if not base_obj: + if not base_obj or not (base_obj.as1 or base_obj.raw): if type == 'delete': - logger.info("Can't delete, we don't have original object {obj_as1['id']}") + logger.info(f"Can't delete, we don't have original object {obj_as1['id']}") return False base_obj = obj diff --git a/tests/test_atproto.py b/tests/test_atproto.py index 8c369a5..dae3529 100644 --- a/tests/test_atproto.py +++ b/tests/test_atproto.py @@ -69,9 +69,9 @@ class ATProtoTest(TestCase): arroba.util.now = lambda **kwargs: NOW def make_user_and_repo(self): - self.user = self.make_user(id='fake:user', cls=Fake, - copies=[Target(uri='did:plc:user', - protocol='atproto')]) + self.user = self.make_user( + id='fake:user', cls=Fake, + copies=[Target(uri='did:plc:user', protocol='atproto')]) did_doc = copy.deepcopy(DID_DOC) did_doc['service'][0]['serviceEndpoint'] = ATProto.PDS_URL