kopia lustrzana https://github.com/snarfed/bridgy-fed
stop clearing Object data properties
...so that we have original data preserved when we override it in our_as1. fixes #721pull/741/head
rodzic
785030a084
commit
62ca4022fb
15
models.py
15
models.py
|
@ -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``.
|
||||
|
||||
|
|
|
@ -1128,7 +1128,6 @@ class Protocol:
|
|||
return obj
|
||||
|
||||
if obj:
|
||||
obj.clear()
|
||||
obj.new = False
|
||||
else:
|
||||
obj = Object(id=id)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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',
|
||||
|
|
Ładowanie…
Reference in New Issue