diff --git a/atproto b/atproto index 75b7848..c5d36d5 160000 --- a/atproto +++ b/atproto @@ -1 +1 @@ -Subproject commit 75b784894057e57a35a92327fe9524fd169f1c02 +Subproject commit c5d36d5ba2a2c2a5c4f366a5621c06a5608e361e diff --git a/chitose/chat/bsky/convo/defs.py b/chitose/chat/bsky/convo/defs.py index 48fbcb2..0e9193a 100644 --- a/chitose/chat/bsky/convo/defs.py +++ b/chitose/chat/bsky/convo/defs.py @@ -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 diff --git a/chitose/com/atproto/admin/defs.py b/chitose/com/atproto/admin/defs.py index fad75b8..60c296c 100644 --- a/chitose/com/atproto/admin/defs.py +++ b/chitose/com/atproto/admin/defs.py @@ -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 @@ -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): """""" diff --git a/chitose/com/atproto/sync/__init__.py b/chitose/com/atproto/sync/__init__.py index 849b127..efc2227 100644 --- a/chitose/com/atproto/sync/__init__.py +++ b/chitose/com/atproto/sync/__init__.py @@ -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 @@ -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. diff --git a/chitose/com/atproto/sync/get_repo_status.py b/chitose/com/atproto/sync/get_repo_status.py new file mode 100644 index 0000000..956381f --- /dev/null +++ b/chitose/com/atproto/sync/get_repo_status.py @@ -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, {}) \ No newline at end of file diff --git a/chitose/com/atproto/sync/list_repos.py b/chitose/com/atproto/sync/list_repos.py index 5e5bd28..f770467 100644 --- a/chitose/com/atproto/sync/list_repos.py +++ b/chitose/com/atproto/sync/list_repos.py @@ -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'} \ No newline at end of file + return {'did': self.did, 'head': self.head, 'rev': self.rev, 'active': self.active, 'status': self.status, '$type': 'com.atproto.sync.listRepos#repo'} \ No newline at end of file diff --git a/chitose/com/atproto/sync/subscribe_repos.py b/chitose/com/atproto/sync/subscribe_repos.py index 88a9042..4a67ba3 100644 --- a/chitose/com/atproto/sync/subscribe_repos.py +++ b/chitose/com/atproto/sync/subscribe_repos.py @@ -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 @@ -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 @@ -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 diff --git a/chitose/tools/ozone/moderation/defs.py b/chitose/tools/ozone/moderation/defs.py index b95dd92..53a71a8 100644 --- a/chitose/tools/ozone/moderation/defs.py +++ b/chitose/tools/ozone/moderation/defs.py @@ -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 @@ -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 @@ -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): """""" diff --git a/docs/source/chitose.com.atproto.sync.rst b/docs/source/chitose.com.atproto.sync.rst index a82a62a..ef69959 100644 --- a/docs/source/chitose.com.atproto.sync.rst +++ b/docs/source/chitose.com.atproto.sync.rst @@ -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 -------------------------------------------