Skip to content

Commit

Permalink
Update atproto
Browse files Browse the repository at this point in the history
  • Loading branch information
mnogu committed Aug 25, 2024
1 parent 164daee commit f9bee1b
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 11 deletions.
2 changes: 1 addition & 1 deletion atproto
Submodule atproto updated 250 files
19 changes: 15 additions & 4 deletions chitose/app/bsky/embed/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def to_dict(self) -> dict[str, typing.Any]:
class View(chitose.Object):
""""""

def __init__(self, record: typing.Union[chitose.app.bsky.embed.record.ViewRecord, chitose.app.bsky.embed.record.ViewNotFound, chitose.app.bsky.embed.record.ViewBlocked, chitose.app.bsky.feed.defs.GeneratorView, chitose.app.bsky.graph.defs.ListView, chitose.app.bsky.labeler.defs.LabelerView, chitose.app.bsky.graph.defs.StarterPackViewBasic]) -> None:
def __init__(self, record: typing.Union[chitose.app.bsky.embed.record.ViewRecord, chitose.app.bsky.embed.record.ViewNotFound, chitose.app.bsky.embed.record.ViewBlocked, chitose.app.bsky.embed.record.ViewDetached, chitose.app.bsky.feed.defs.GeneratorView, chitose.app.bsky.graph.defs.ListView, chitose.app.bsky.labeler.defs.LabelerView, chitose.app.bsky.graph.defs.StarterPackViewBasic]) -> None:
self.record = record

def to_dict(self) -> dict[str, typing.Any]:
Expand All @@ -39,7 +39,7 @@ class ViewRecord(chitose.Object):
:param value: The record data itself.
"""

def __init__(self, uri: str, cid: str, author: chitose.app.bsky.actor.defs.ProfileViewBasic, value: typing.Any, indexed_at: str, labels: typing.Optional[list[chitose.com.atproto.label.defs.Label]]=None, reply_count: typing.Optional[int]=None, repost_count: typing.Optional[int]=None, like_count: typing.Optional[int]=None, embeds: typing.Optional[list[typing.Union[chitose.app.bsky.embed.images.View, chitose.app.bsky.embed.external.View, chitose.app.bsky.embed.record.View, chitose.app.bsky.embed.record_with_media.View]]]=None) -> None:
def __init__(self, uri: str, cid: str, author: chitose.app.bsky.actor.defs.ProfileViewBasic, value: typing.Any, indexed_at: str, labels: typing.Optional[list[chitose.com.atproto.label.defs.Label]]=None, reply_count: typing.Optional[int]=None, repost_count: typing.Optional[int]=None, like_count: typing.Optional[int]=None, quote_count: typing.Optional[int]=None, embeds: typing.Optional[list[typing.Union[chitose.app.bsky.embed.images.View, chitose.app.bsky.embed.external.View, chitose.app.bsky.embed.record.View, chitose.app.bsky.embed.record_with_media.View]]]=None) -> None:
self.uri = uri
self.cid = cid
self.author = author
Expand All @@ -49,10 +49,11 @@ def __init__(self, uri: str, cid: str, author: chitose.app.bsky.actor.defs.Profi
self.reply_count = reply_count
self.repost_count = repost_count
self.like_count = like_count
self.quote_count = quote_count
self.embeds = embeds

def to_dict(self) -> dict[str, typing.Any]:
return {'uri': self.uri, 'cid': self.cid, 'author': self.author, 'value': self.value, 'indexedAt': self.indexed_at, 'labels': self.labels, 'replyCount': self.reply_count, 'repostCount': self.repost_count, 'likeCount': self.like_count, 'embeds': self.embeds, '$type': 'app.bsky.embed.record#viewRecord'}
return {'uri': self.uri, 'cid': self.cid, 'author': self.author, 'value': self.value, 'indexedAt': self.indexed_at, 'labels': self.labels, 'replyCount': self.reply_count, 'repostCount': self.repost_count, 'likeCount': self.like_count, 'quoteCount': self.quote_count, 'embeds': self.embeds, '$type': 'app.bsky.embed.record#viewRecord'}

class ViewNotFound(chitose.Object):
""""""
Expand All @@ -73,4 +74,14 @@ def __init__(self, uri: str, blocked: bool, author: chitose.app.bsky.feed.defs.B
self.author = author

def to_dict(self) -> dict[str, typing.Any]:
return {'uri': self.uri, 'blocked': self.blocked, 'author': self.author, '$type': 'app.bsky.embed.record#viewBlocked'}
return {'uri': self.uri, 'blocked': self.blocked, 'author': self.author, '$type': 'app.bsky.embed.record#viewBlocked'}

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

def __init__(self, uri: str, detached: bool) -> None:
self.uri = uri
self.detached = detached

def to_dict(self) -> dict[str, typing.Any]:
return {'uri': self.uri, 'detached': self.detached, '$type': 'app.bsky.embed.record#viewDetached'}
11 changes: 11 additions & 0 deletions chitose/app/bsky/feed/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .get_list_feed import _get_list_feed
from .get_post_thread import _get_post_thread
from .get_posts import _get_posts
from .get_quotes import _get_quotes
from .get_reposted_by import _get_reposted_by
from .get_suggested_feeds import _get_suggested_feeds
from .get_timeline import _get_timeline
Expand Down Expand Up @@ -141,6 +142,16 @@ def get_feed(self, feed: str, limit: typing.Optional[int]=None, cursor: typing.O
"""Get a hydrated feed from an actor's selected feed generator. Implemented by App View."""
return _get_feed(self.call, feed, limit, cursor)

def get_quotes(self, uri: str, cid: typing.Optional[str]=None, limit: typing.Optional[int]=None, cursor: typing.Optional[str]=None) -> bytes:
"""Get a list of quotes for a given post.
:param uri: Reference (AT-URI) of post record
:param cid: If supplied, filters to quotes of specific version (by CID) of the post record.
"""
return _get_quotes(self.call, uri, cid, limit, cursor)

def get_feed_skeleton(self, feed: str, limit: typing.Optional[int]=None, cursor: typing.Optional[str]=None) -> bytes:
"""Get a skeleton of a feed provided by a feed generator. Auth is optional, depending on provider requirements, and provides the DID of the requester. Implemented by Feed Generator Service.
Expand Down
10 changes: 6 additions & 4 deletions chitose/app/bsky/feed/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class PostView(chitose.Object):
""""""

def __init__(self, uri: str, cid: str, author: chitose.app.bsky.actor.defs.ProfileViewBasic, record: typing.Any, indexed_at: str, embed: typing.Optional[typing.Union[chitose.app.bsky.embed.images.View, chitose.app.bsky.embed.external.View, chitose.app.bsky.embed.record.View, chitose.app.bsky.embed.record_with_media.View]]=None, reply_count: typing.Optional[int]=None, repost_count: typing.Optional[int]=None, like_count: typing.Optional[int]=None, viewer: typing.Optional[chitose.app.bsky.feed.defs.ViewerState]=None, labels: typing.Optional[list[chitose.com.atproto.label.defs.Label]]=None, threadgate: typing.Optional[chitose.app.bsky.feed.defs.ThreadgateView]=None) -> None:
def __init__(self, uri: str, cid: str, author: chitose.app.bsky.actor.defs.ProfileViewBasic, record: typing.Any, indexed_at: str, embed: typing.Optional[typing.Union[chitose.app.bsky.embed.images.View, chitose.app.bsky.embed.external.View, chitose.app.bsky.embed.record.View, chitose.app.bsky.embed.record_with_media.View]]=None, reply_count: typing.Optional[int]=None, repost_count: typing.Optional[int]=None, like_count: typing.Optional[int]=None, quote_count: typing.Optional[int]=None, viewer: typing.Optional[chitose.app.bsky.feed.defs.ViewerState]=None, labels: typing.Optional[list[chitose.com.atproto.label.defs.Label]]=None, threadgate: typing.Optional[chitose.app.bsky.feed.defs.ThreadgateView]=None) -> None:
self.uri = uri
self.cid = cid
self.author = author
Expand All @@ -26,24 +26,26 @@ def __init__(self, uri: str, cid: str, author: chitose.app.bsky.actor.defs.Profi
self.reply_count = reply_count
self.repost_count = repost_count
self.like_count = like_count
self.quote_count = quote_count
self.viewer = viewer
self.labels = labels
self.threadgate = threadgate

def to_dict(self) -> dict[str, typing.Any]:
return {'uri': self.uri, 'cid': self.cid, 'author': self.author, 'record': self.record, 'indexedAt': self.indexed_at, 'embed': self.embed, 'replyCount': self.reply_count, 'repostCount': self.repost_count, 'likeCount': self.like_count, 'viewer': self.viewer, 'labels': self.labels, 'threadgate': self.threadgate, '$type': 'app.bsky.feed.defs#postView'}
return {'uri': self.uri, 'cid': self.cid, 'author': self.author, 'record': self.record, 'indexedAt': self.indexed_at, 'embed': self.embed, 'replyCount': self.reply_count, 'repostCount': self.repost_count, 'likeCount': self.like_count, 'quoteCount': self.quote_count, 'viewer': self.viewer, 'labels': self.labels, 'threadgate': self.threadgate, '$type': 'app.bsky.feed.defs#postView'}

class ViewerState(chitose.Object):
"""Metadata about the requesting account's relationship with the subject content. Only has meaningful content for authed requests."""

def __init__(self, repost: typing.Optional[str]=None, like: typing.Optional[str]=None, thread_muted: typing.Optional[bool]=None, reply_disabled: typing.Optional[bool]=None) -> None:
def __init__(self, repost: typing.Optional[str]=None, like: typing.Optional[str]=None, thread_muted: typing.Optional[bool]=None, reply_disabled: typing.Optional[bool]=None, embedding_disabled: typing.Optional[bool]=None) -> None:
self.repost = repost
self.like = like
self.thread_muted = thread_muted
self.reply_disabled = reply_disabled
self.embedding_disabled = embedding_disabled

def to_dict(self) -> dict[str, typing.Any]:
return {'repost': self.repost, 'like': self.like, 'threadMuted': self.thread_muted, 'replyDisabled': self.reply_disabled, '$type': 'app.bsky.feed.defs#viewerState'}
return {'repost': self.repost, 'like': self.like, 'threadMuted': self.thread_muted, 'replyDisabled': self.reply_disabled, 'embeddingDisabled': self.embedding_disabled, '$type': 'app.bsky.feed.defs#viewerState'}

class FeedViewPost(chitose.Object):
"""
Expand Down
15 changes: 15 additions & 0 deletions chitose/app/bsky/feed/get_quotes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# GENERATED CODE - DO NOT MODIFY
""""""
from __future__ import annotations
import chitose
import typing

def _get_quotes(call: chitose.xrpc.XrpcCall, uri: str, cid: typing.Optional[str]=None, limit: typing.Optional[int]=None, cursor: typing.Optional[str]=None) -> bytes:
"""Get a list of quotes for a given post.
:param uri: Reference (AT-URI) of post record
:param cid: If supplied, filters to quotes of specific version (by CID) of the post record.
"""
return call('app.bsky.feed.getQuotes', [('uri', uri), ('cid', cid), ('limit', limit), ('cursor', cursor)], None, {})
30 changes: 30 additions & 0 deletions chitose/app/bsky/feed/postgate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# GENERATED CODE - DO NOT MODIFY
""""""
from __future__ import annotations
import chitose
import chitose.app.bsky.feed.postgate
import typing

class Postgate(chitose.Record):
"""
:param post: Reference (AT-URI) to the post record.
:param detached_embedding_uris: List of AT-URIs embedding this post that the author has detached from.
"""

def __init__(self, created_at: str, post: str, detached_embedding_uris: typing.Optional[list[str]]=None, embedding_rules: typing.Optional[list[chitose.app.bsky.feed.postgate.DisableRule]]=None) -> None:
self.created_at = created_at
self.post = post
self.detached_embedding_uris = detached_embedding_uris
self.embedding_rules = embedding_rules

def to_dict(self) -> dict[str, typing.Any]:
return {'createdAt': self.created_at, 'post': self.post, 'detachedEmbeddingUris': self.detached_embedding_uris, 'embeddingRules': self.embedding_rules, '$type': 'app.bsky.feed.postgate'}

class DisableRule(chitose.Object):
"""Disables embedding of this post."""

def to_dict(self) -> dict[str, typing.Any]:
return {'$type': 'app.bsky.feed.postgate#disableRule'}
7 changes: 5 additions & 2 deletions chitose/app/bsky/feed/threadgate.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ class Threadgate(chitose.Record):
:param post: Reference (AT-URI) to the post record.
:param hidden_replies: List of hidden reply URIs.
"""

def __init__(self, post: str, created_at: str, allow: typing.Optional[list[typing.Union[chitose.app.bsky.feed.threadgate.MentionRule, chitose.app.bsky.feed.threadgate.FollowingRule, chitose.app.bsky.feed.threadgate.ListRule]]]=None) -> None:
def __init__(self, post: str, created_at: str, allow: typing.Optional[list[typing.Union[chitose.app.bsky.feed.threadgate.MentionRule, chitose.app.bsky.feed.threadgate.FollowingRule, chitose.app.bsky.feed.threadgate.ListRule]]]=None, hidden_replies: typing.Optional[list[str]]=None) -> None:
self.post = post
self.created_at = created_at
self.allow = allow
self.hidden_replies = hidden_replies

def to_dict(self) -> dict[str, typing.Any]:
return {'post': self.post, 'createdAt': self.created_at, 'allow': self.allow, '$type': 'app.bsky.feed.threadgate'}
return {'post': self.post, 'createdAt': self.created_at, 'allow': self.allow, 'hiddenReplies': self.hidden_replies, '$type': 'app.bsky.feed.threadgate'}

class MentionRule(chitose.Object):
"""Allow replies from actors mentioned in your post."""
Expand Down
16 changes: 16 additions & 0 deletions docs/source/chitose.app.bsky.feed.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ chitose.app.bsky.feed.get\_posts module
:undoc-members:
:show-inheritance:

chitose.app.bsky.feed.get\_quotes module
----------------------------------------

.. automodule:: chitose.app.bsky.feed.get_quotes
:members:
:undoc-members:
:show-inheritance:

chitose.app.bsky.feed.get\_reposted\_by module
----------------------------------------------

Expand Down Expand Up @@ -156,6 +164,14 @@ chitose.app.bsky.feed.post module
:undoc-members:
:show-inheritance:

chitose.app.bsky.feed.postgate module
-------------------------------------

.. automodule:: chitose.app.bsky.feed.postgate
:members:
:undoc-members:
:show-inheritance:

chitose.app.bsky.feed.repost module
-----------------------------------

Expand Down

0 comments on commit f9bee1b

Please sign in to comment.