kopia lustrzana https://github.com/snarfed/bridgy-fed
replace copy ids with originals in Protocol.load
honestly not sure if this is necessary yet, and it's moderately expensive, two serial datastore queries with an IN filter. we'll see.pull/691/head
rodzic
d7a51916ad
commit
9e1acf1cf7
|
@ -951,6 +951,9 @@ class Object(StringIdModel):
|
|||
+ [as1.get_object(inner_obj, f).get('id') for f in fields]
|
||||
+ [inner_obj.get('id')]
|
||||
+ [m.get('url') for m in mention_tags])
|
||||
if not ids:
|
||||
return
|
||||
|
||||
origs = (User.get_for_copies(ids)
|
||||
+ Object.query(Object.copies.uri.IN(ids)).fetch())
|
||||
|
||||
|
|
|
@ -1120,6 +1120,8 @@ class Protocol:
|
|||
if not fetched:
|
||||
return None
|
||||
|
||||
obj.replace_copies_with_originals()
|
||||
|
||||
if obj.new is False:
|
||||
obj.changed = obj.activity_changed(orig_as1)
|
||||
|
||||
|
|
|
@ -287,6 +287,32 @@ class ProtocolTest(TestCase):
|
|||
with self.assertRaises(AssertionError):
|
||||
Fake.load('nope', local=False, remote=False)
|
||||
|
||||
def test_load_replace_copies_with_originals(self):
|
||||
follow = {
|
||||
'objectType': 'activity',
|
||||
'verb': 'follow',
|
||||
'actor': 'fake:alice',
|
||||
'object': 'fake:bob',
|
||||
}
|
||||
Fake.fetchable = {
|
||||
'fake:follow': follow,
|
||||
}
|
||||
|
||||
# no matching copy users
|
||||
obj = Fake.load('fake:follow', remote=True)
|
||||
self.assert_equals(follow, obj.our_as1)
|
||||
|
||||
# matching copy user
|
||||
self.make_user('other:bob', cls=OtherFake,
|
||||
copies=[Target(uri='fake:bob', protocol='fake')])
|
||||
|
||||
obj = Fake.load('fake:follow', remote=True)
|
||||
self.assert_equals({
|
||||
**follow,
|
||||
'id': 'fake:follow',
|
||||
'object': {'id': 'other:bob'},
|
||||
}, obj.our_as1)
|
||||
|
||||
def test_actor_key(self):
|
||||
user = self.make_user(id='fake:a', cls=Fake)
|
||||
a_key = user.key
|
||||
|
|
Ładowanie…
Reference in New Issue