Object.as1 from bluesky: granary now sets actor/author

in snarfed/granary@eceb700c6c
pull/696/head
Ryan Barrett 2023-10-24 12:36:13 -07:00
rodzic 422a240183
commit 611bc94fc2
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
1 zmienionych plików z 1 dodań i 12 usunięć

Wyświetl plik

@ -589,8 +589,6 @@ class Object(StringIdModel):
# if bool(self.as2) + bool(self.bsky) + bool(self.mf2) > 1:
# logger.warning(f'{self.key} has multiple! {bool(self.as2)} {bool(self.bsky)} {bool(self.mf2)}')
owner = None
if self.our_as1:
obj = self.our_as1
@ -599,7 +597,7 @@ class Object(StringIdModel):
elif self.bsky:
owner, _, _ = parse_at_uri(self.key.id())
ATProto = PROTOCOLS['atproto']
ATProto = PROTOCOLS['atproto'] # TODO: circular import :( ???
handle = ATProto(id=owner).handle
obj = bluesky.to_as1(self.bsky, repo_did=owner, repo_handle=handle,
pds=ATProto.target_for(self))
@ -621,15 +619,6 @@ class Object(StringIdModel):
if self.key:
obj.setdefault('id', self.key.id())
# populate actor/author if necessary and available
type = obj.get('objectType')
field = ('actor' if type == 'activity'
else 'author' if type not in as1.ACTOR_TYPES
else None)
if field and owner:
# logger.debug(f'Replacing {field} {obj.get(field)} with {owner}')
obj[field] = owner
return obj
@ndb.ComputedProperty