Skip to content

Commit

Permalink
Update atproto
Browse files Browse the repository at this point in the history
  • Loading branch information
mnogu committed Jun 2, 2024
1 parent 23772ff commit 6b7aa4a
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 16 deletions.
2 changes: 1 addition & 1 deletion atproto
Submodule atproto updated 205 files
2 changes: 1 addition & 1 deletion chitose/chat/bsky/convo/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class MessageView(chitose.Object):
:param facets: Annotations of text (mentions, URLs, hashtags, etc)
"""

def __init__(self, id: str, rev: str, text: str, sender: chitose.chat.bsky.convo.defs.MessageViewSender, sent_at: str, facets: typing.Optional[list[chitose.app.bsky.richtext.facet.Facet]]=None, embed: typing.Optional[chitose.app.bsky.embed.record.Record]=None) -> None:
def __init__(self, id: str, rev: str, text: str, sender: chitose.chat.bsky.convo.defs.MessageViewSender, sent_at: str, facets: typing.Optional[list[chitose.app.bsky.richtext.facet.Facet]]=None, embed: typing.Optional[chitose.app.bsky.embed.record.View]=None) -> None:
self.id = id
self.rev = rev
self.text = text
Expand Down
5 changes: 3 additions & 2 deletions chitose/com/atproto/admin/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def to_dict(self) -> dict[str, typing.Any]:
class AccountView(chitose.Object):
""""""

def __init__(self, did: str, handle: str, indexed_at: str, email: typing.Optional[str]=None, related_records: typing.Optional[list[typing.Any]]=None, invited_by: typing.Optional[chitose.com.atproto.server.defs.InviteCode]=None, invites: typing.Optional[list[chitose.com.atproto.server.defs.InviteCode]]=None, invites_disabled: typing.Optional[bool]=None, email_confirmed_at: typing.Optional[str]=None, invite_note: typing.Optional[str]=None) -> None:
def __init__(self, did: str, handle: str, indexed_at: str, email: typing.Optional[str]=None, related_records: typing.Optional[list[typing.Any]]=None, invited_by: typing.Optional[chitose.com.atproto.server.defs.InviteCode]=None, invites: typing.Optional[list[chitose.com.atproto.server.defs.InviteCode]]=None, invites_disabled: typing.Optional[bool]=None, email_confirmed_at: typing.Optional[str]=None, invite_note: typing.Optional[str]=None, deactivated_at: typing.Optional[str]=None) -> None:
self.did = did
self.handle = handle
self.indexed_at = indexed_at
Expand All @@ -29,9 +29,10 @@ def __init__(self, did: str, handle: str, indexed_at: str, email: typing.Optiona
self.invites_disabled = invites_disabled
self.email_confirmed_at = email_confirmed_at
self.invite_note = invite_note
self.deactivated_at = deactivated_at

def to_dict(self) -> dict[str, typing.Any]:
return {'did': self.did, 'handle': self.handle, 'indexedAt': self.indexed_at, 'email': self.email, 'relatedRecords': self.related_records, 'invitedBy': self.invited_by, 'invites': self.invites, 'invitesDisabled': self.invites_disabled, 'emailConfirmedAt': self.email_confirmed_at, 'inviteNote': self.invite_note, '$type': 'com.atproto.admin.defs#accountView'}
return {'did': self.did, 'handle': self.handle, 'indexedAt': self.indexed_at, 'email': self.email, 'relatedRecords': self.related_records, 'invitedBy': self.invited_by, 'invites': self.invites, 'invitesDisabled': self.invites_disabled, 'emailConfirmedAt': self.email_confirmed_at, 'inviteNote': self.invite_note, 'deactivatedAt': self.deactivated_at, '$type': 'com.atproto.admin.defs#accountView'}

class RepoRef(chitose.Object):
""""""
Expand Down
9 changes: 9 additions & 0 deletions chitose/com/atproto/sync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .get_latest_commit import _get_latest_commit
from .get_record import _get_record
from .get_repo import _get_repo
from .get_repo_status import _get_repo_status
from .list_blobs import _list_blobs
from .list_repos import _list_repos
from .notify_of_update import _notify_of_update
Expand Down Expand Up @@ -94,6 +95,14 @@ def subscribe_repos(self, handler: chitose.xrpc.XrpcHandler, cursor: typing.Opti
"""
_subscribe_repos(self.subscribe, handler, cursor)

def get_repo_status(self, did: str) -> bytes:
"""Get the hosting status for a repository, on this server. Expected to be implemented by PDS and Relay.
:param did: The DID of the repo.
"""
return _get_repo_status(self.call, did)

def get_record(self, did: str, collection: str, rkey: str, commit: typing.Optional[str]=None) -> bytes:
"""Get data blocks needed to prove the existence or non-existence of record in the current version of repo. Does not require auth.
Expand Down
12 changes: 12 additions & 0 deletions chitose/com/atproto/sync/get_repo_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# GENERATED CODE - DO NOT MODIFY
""""""
from __future__ import annotations
import chitose

def _get_repo_status(call: chitose.xrpc.XrpcCall, did: str) -> bytes:
"""Get the hosting status for a repository, on this server. Expected to be implemented by PDS and Relay.
:param did: The DID of the repo.
"""
return call('com.atproto.sync.getRepoStatus', [('did', did)], None, {})
8 changes: 6 additions & 2 deletions chitose/com/atproto/sync/list_repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ class Repo(chitose.Object):
:param head: Current repo commit CID
:param status: If active=false, this optional field indicates a possible reason for why the account is not active. If active=false and no status is supplied, then the host makes no claim for why the repository is no longer being hosted.
"""

def __init__(self, did: str, head: str, rev: str) -> None:
def __init__(self, did: str, head: str, rev: str, active: typing.Optional[bool]=None, status: typing.Optional[typing.Literal['takendown', 'suspended', 'deactivated']]=None) -> None:
self.did = did
self.head = head
self.rev = rev
self.active = active
self.status = status

def to_dict(self) -> dict[str, typing.Any]:
return {'did': self.did, 'head': self.head, 'rev': self.rev, '$type': 'com.atproto.sync.listRepos#repo'}
return {'did': self.did, 'head': self.head, 'rev': self.rev, 'active': self.active, 'status': self.status, '$type': 'com.atproto.sync.listRepos#repo'}
36 changes: 30 additions & 6 deletions chitose/com/atproto/sync/subscribe_repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,42 @@ def to_dict(self) -> dict[str, typing.Any]:
return {'seq': self.seq, 'rebase': self.rebase, 'tooBig': self.too_big, 'repo': self.repo, 'commit': self.commit, 'rev': self.rev, 'since': self.since, 'blocks': self.blocks, 'ops': self.ops, 'blobs': self.blobs, 'time': self.time, 'prev': self.prev, '$type': 'com.atproto.sync.subscribeRepos#commit'}

class Identity(chitose.Object):
"""Represents a change to an account's identity. Could be an updated handle, signing key, or pds hosting endpoint. Serves as a prod to all downstream services to refresh their identity cache."""
"""Represents a change to an account's identity. Could be an updated handle, signing key, or pds hosting endpoint. Serves as a prod to all downstream services to refresh their identity cache.
def __init__(self, seq: int, did: str, time: str) -> None:
:param handle: The current handle for the account, or 'handle.invalid' if validation fails. This field is optional, might have been validated or passed-through from an upstream source. Semantics and behaviors for PDS vs Relay may evolve in the future; see atproto specs for more details.
"""

def __init__(self, seq: int, did: str, time: str, handle: typing.Optional[str]=None) -> None:
self.seq = seq
self.did = did
self.time = time
self.handle = handle

def to_dict(self) -> dict[str, typing.Any]:
return {'seq': self.seq, 'did': self.did, 'time': self.time, 'handle': self.handle, '$type': 'com.atproto.sync.subscribeRepos#identity'}

class Account(chitose.Object):
"""Represents a change to an account's status on a host (eg, PDS or Relay). The semantics of this event are that the status is at the host which emitted the event, not necessarily that at the currently active PDS. Eg, a Relay takedown would emit a takedown with active=false, even if the PDS is still active.
:param active: Indicates that the account has a repository which can be fetched from the host that emitted this event.
:param status: If active=false, this optional field indicates a reason for why the account is not active.
"""

def __init__(self, seq: int, did: str, time: str, active: bool, status: typing.Optional[typing.Literal['takendown', 'suspended', 'deleted', 'deactivated']]=None) -> None:
self.seq = seq
self.did = did
self.time = time
self.active = active
self.status = status

def to_dict(self) -> dict[str, typing.Any]:
return {'seq': self.seq, 'did': self.did, 'time': self.time, '$type': 'com.atproto.sync.subscribeRepos#identity'}
return {'seq': self.seq, 'did': self.did, 'time': self.time, 'active': self.active, 'status': self.status, '$type': 'com.atproto.sync.subscribeRepos#account'}

class Handle(chitose.Object):
"""Represents an update of the account's handle, or transition to/from invalid state. NOTE: Will be deprecated in favor of #identity."""
"""DEPRECATED -- Use #identity event instead"""

def __init__(self, seq: int, did: str, handle: str, time: str) -> None:
self.seq = seq
Expand All @@ -79,7 +103,7 @@ def to_dict(self) -> dict[str, typing.Any]:
return {'seq': self.seq, 'did': self.did, 'handle': self.handle, 'time': self.time, '$type': 'com.atproto.sync.subscribeRepos#handle'}

class Migrate(chitose.Object):
"""Represents an account moving from one PDS instance to another. NOTE: not implemented; account migration uses #identity instead"""
"""DEPRECATED -- Use #account event instead"""

def __init__(self, seq: int, did: str, migrate_to: str, time: str) -> None:
self.seq = seq
Expand All @@ -91,7 +115,7 @@ def to_dict(self) -> dict[str, typing.Any]:
return {'seq': self.seq, 'did': self.did, 'migrateTo': self.migrate_to, 'time': self.time, '$type': 'com.atproto.sync.subscribeRepos#migrate'}

class Tombstone(chitose.Object):
"""Indicates that an account has been deleted. NOTE: may be deprecated in favor of #identity or a future #account event"""
"""DEPRECATED -- Use #account event instead"""

def __init__(self, seq: int, did: str, time: str) -> None:
self.seq = seq
Expand Down
10 changes: 6 additions & 4 deletions chitose/tools/ozone/moderation/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def to_dict(self) -> dict[str, typing.Any]:
class RepoView(chitose.Object):
""""""

def __init__(self, did: str, handle: str, related_records: list[typing.Any], indexed_at: str, moderation: chitose.tools.ozone.moderation.defs.Moderation, email: typing.Optional[str]=None, invited_by: typing.Optional[chitose.com.atproto.server.defs.InviteCode]=None, invites_disabled: typing.Optional[bool]=None, invite_note: typing.Optional[str]=None) -> None:
def __init__(self, did: str, handle: str, related_records: list[typing.Any], indexed_at: str, moderation: chitose.tools.ozone.moderation.defs.Moderation, email: typing.Optional[str]=None, invited_by: typing.Optional[chitose.com.atproto.server.defs.InviteCode]=None, invites_disabled: typing.Optional[bool]=None, invite_note: typing.Optional[str]=None, deactivated_at: typing.Optional[str]=None) -> None:
self.did = did
self.handle = handle
self.related_records = related_records
Expand All @@ -296,14 +296,15 @@ def __init__(self, did: str, handle: str, related_records: list[typing.Any], ind
self.invited_by = invited_by
self.invites_disabled = invites_disabled
self.invite_note = invite_note
self.deactivated_at = deactivated_at

def to_dict(self) -> dict[str, typing.Any]:
return {'did': self.did, 'handle': self.handle, 'relatedRecords': self.related_records, 'indexedAt': self.indexed_at, 'moderation': self.moderation, 'email': self.email, 'invitedBy': self.invited_by, 'invitesDisabled': self.invites_disabled, 'inviteNote': self.invite_note, '$type': 'tools.ozone.moderation.defs#repoView'}
return {'did': self.did, 'handle': self.handle, 'relatedRecords': self.related_records, 'indexedAt': self.indexed_at, 'moderation': self.moderation, 'email': self.email, 'invitedBy': self.invited_by, 'invitesDisabled': self.invites_disabled, 'inviteNote': self.invite_note, 'deactivatedAt': self.deactivated_at, '$type': 'tools.ozone.moderation.defs#repoView'}

class RepoViewDetail(chitose.Object):
""""""

def __init__(self, did: str, handle: str, related_records: list[typing.Any], indexed_at: str, moderation: chitose.tools.ozone.moderation.defs.ModerationDetail, email: typing.Optional[str]=None, labels: typing.Optional[list[chitose.com.atproto.label.defs.Label]]=None, invited_by: typing.Optional[chitose.com.atproto.server.defs.InviteCode]=None, invites: typing.Optional[list[chitose.com.atproto.server.defs.InviteCode]]=None, invites_disabled: typing.Optional[bool]=None, invite_note: typing.Optional[str]=None, email_confirmed_at: typing.Optional[str]=None) -> None:
def __init__(self, did: str, handle: str, related_records: list[typing.Any], indexed_at: str, moderation: chitose.tools.ozone.moderation.defs.ModerationDetail, email: typing.Optional[str]=None, labels: typing.Optional[list[chitose.com.atproto.label.defs.Label]]=None, invited_by: typing.Optional[chitose.com.atproto.server.defs.InviteCode]=None, invites: typing.Optional[list[chitose.com.atproto.server.defs.InviteCode]]=None, invites_disabled: typing.Optional[bool]=None, invite_note: typing.Optional[str]=None, email_confirmed_at: typing.Optional[str]=None, deactivated_at: typing.Optional[str]=None) -> None:
self.did = did
self.handle = handle
self.related_records = related_records
Expand All @@ -316,9 +317,10 @@ def __init__(self, did: str, handle: str, related_records: list[typing.Any], ind
self.invites_disabled = invites_disabled
self.invite_note = invite_note
self.email_confirmed_at = email_confirmed_at
self.deactivated_at = deactivated_at

def to_dict(self) -> dict[str, typing.Any]:
return {'did': self.did, 'handle': self.handle, 'relatedRecords': self.related_records, 'indexedAt': self.indexed_at, 'moderation': self.moderation, 'email': self.email, 'labels': self.labels, 'invitedBy': self.invited_by, 'invites': self.invites, 'invitesDisabled': self.invites_disabled, 'inviteNote': self.invite_note, 'emailConfirmedAt': self.email_confirmed_at, '$type': 'tools.ozone.moderation.defs#repoViewDetail'}
return {'did': self.did, 'handle': self.handle, 'relatedRecords': self.related_records, 'indexedAt': self.indexed_at, 'moderation': self.moderation, 'email': self.email, 'labels': self.labels, 'invitedBy': self.invited_by, 'invites': self.invites, 'invitesDisabled': self.invites_disabled, 'inviteNote': self.invite_note, 'emailConfirmedAt': self.email_confirmed_at, 'deactivatedAt': self.deactivated_at, '$type': 'tools.ozone.moderation.defs#repoViewDetail'}

class RepoViewNotFound(chitose.Object):
""""""
Expand Down
8 changes: 8 additions & 0 deletions docs/source/chitose.com.atproto.sync.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ chitose.com.atproto.sync.get\_repo module
:undoc-members:
:show-inheritance:

chitose.com.atproto.sync.get\_repo\_status module
-------------------------------------------------

.. automodule:: chitose.com.atproto.sync.get_repo_status
:members:
:undoc-members:
:show-inheritance:

chitose.com.atproto.sync.list\_blobs module
-------------------------------------------

Expand Down

0 comments on commit 6b7aa4a

Please sign in to comment.