stop clearing Object data properties

...so that we have original data preserved when we override it in our_as1. fixes #721
pull/741/head
Ryan Barrett 2023-11-28 06:39:20 -08:00
rodzic 785030a084
commit 62ca4022fb
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
5 zmienionych plików z 1 dodań i 26 usunięć

Wyświetl plik

@ -761,8 +761,6 @@ class Object(StringIdModel):
obj = Object(id=id)
obj.new = True
if set(props.keys()) & set(('our_as1', 'as2', 'mf2', 'raw')):
obj.clear()
obj.populate(**{
k: v for k, v in props.items()
if v and not isinstance(getattr(Object, k), ndb.ComputedProperty)
@ -799,19 +797,6 @@ class Object(StringIdModel):
with self.lock:
getattr(self, prop).remove(val)
def clear(self):
"""Clears all data properties.
TODO: remove?
"""
for prop in 'our_as1', 'as2', 'mf2', 'raw':
val = getattr(self, prop, None)
# TODO: delete entirely?
# if val:
# logger.warning(f'Wiping out existing {prop}: {json_dumps(val, indent=2)}')
with self.lock:
setattr(self, prop, None)
def activity_changed(self, other_as1):
"""Returns True if this activity is meaningfully changed from ``other_as1``.

Wyświetl plik

@ -1128,7 +1128,6 @@ class Protocol:
return obj
if obj:
obj.clear()
obj.new = False
else:
obj = Object(id=id)

Wyświetl plik

@ -1192,7 +1192,6 @@ class ActivityPubTest(TestCase):
self.assertEqual(401, resp.status_code, resp.get_data(as_text=True))
# valid signature, Object has our_as1 instead of as2
self.key_id_obj.clear()
self.key_id_obj.our_as1 = as2.to_as1(actor_as2)
self.key_id_obj.put()
resp = self.client.post('/ap/sharedInbox', data=body, headers=headers)

Wyświetl plik

@ -620,14 +620,6 @@ class ObjectTest(TestCase):
self.assertNotIn('id', obj.as1['actor'])
self.assertEqual(['c', 'd'], obj.as1['object'])
def test_clear(self):
ab = {'a': 'b'}
obj = Object(our_as1=ab, as2=ab, mf2=ab)
obj.clear()
self.assertIsNone(obj.our_as1)
self.assertIsNone(obj.as2)
self.assertIsNone(obj.mf2)
def test_validate_id(self):
# DID repo ids
Object(id='at://did:plc:123/app.bsky.feed.post/abc').put()

Wyświetl plik

@ -643,7 +643,7 @@ class WebTest(TestCase):
source_protocol='web',
type='comment',
labels=[],
ignore=['our_as1'],
ignore=['our_as1', 'mf2'],
)
self.assert_object('https://user.com/reply#bridgy-fed-create',
source_protocol='web',