Skip to content

Commit

Permalink
Object.as1 from bluesky: granary now sets actor/author
Browse files Browse the repository at this point in the history
  • Loading branch information
snarfed committed Oct 24, 2023
1 parent 422a240 commit 611bc94
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,6 @@ def as1(self):
# 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

Expand All @@ -599,7 +597,7 @@ def as1(self):

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))
Expand All @@ -621,15 +619,6 @@ def as1(self):
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
Expand Down

0 comments on commit 611bc94

Please sign in to comment.