Skip to content

Commit

Permalink
Update atproto
Browse files Browse the repository at this point in the history
  • Loading branch information
mnogu committed Aug 12, 2023
1 parent 0452002 commit bfc5323
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 20 deletions.
2 changes: 1 addition & 1 deletion atproto
Submodule atproto updated 212 files
6 changes: 4 additions & 2 deletions chitose/app/bsky/actor/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
""""""
from __future__ import annotations
import chitose
import chitose.com.atproto.label.defs
import typing

class Profile(chitose.Record):
""""""

def __init__(self, display_name: typing.Optional[str]=None, description: typing.Optional[str]=None, avatar: typing.Optional[chitose.Blob]=None, banner: typing.Optional[chitose.Blob]=None) -> None:
def __init__(self, display_name: typing.Optional[str]=None, description: typing.Optional[str]=None, avatar: typing.Optional[chitose.Blob]=None, banner: typing.Optional[chitose.Blob]=None, labels: typing.Optional[chitose.com.atproto.label.defs.SelfLabels]=None) -> None:
self.display_name = display_name
self.description = description
self.avatar = avatar
self.banner = banner
self.labels = labels

def to_dict(self) -> dict[str, typing.Any]:
return {'displayName': self.display_name, 'description': self.description, 'avatar': self.avatar, 'banner': self.banner, '$type': 'app.bsky.actor.profile'}
return {'displayName': self.display_name, 'description': self.description, 'avatar': self.avatar, 'banner': self.banner, 'labels': self.labels, '$type': 'app.bsky.actor.profile'}
11 changes: 7 additions & 4 deletions chitose/app/bsky/embed/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,20 @@ def to_dict(self) -> dict[str, typing.Any]:
class ViewNotFound(chitose.Object):
""""""

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

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

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

def __init__(self, uri: str) -> None:
def __init__(self, uri: str, blocked: bool, author: chitose.app.bsky.feed.defs.BlockedAuthor) -> None:
self.uri = uri
self.blocked = blocked
self.author = author

def to_dict(self) -> dict[str, typing.Any]:
return {'uri': self.uri, '$type': 'app.bsky.embed.record#viewBlocked'}
return {'uri': self.uri, 'blocked': self.blocked, 'author': self.author, '$type': 'app.bsky.embed.record#viewBlocked'}
4 changes: 2 additions & 2 deletions chitose/app/bsky/feed/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def get_feed_generator(self, feed: str) -> bytes:
"""Get information about a specific feed offered by a feed generator, such as its online status"""
return _get_feed_generator(self.call, feed)

def get_author_feed(self, actor: str, limit: typing.Optional[int]=None, cursor: typing.Optional[str]=None) -> bytes:
def get_author_feed(self, actor: str, limit: typing.Optional[int]=None, cursor: typing.Optional[str]=None, filter: typing.Optional[typing.Literal['posts_with_replies', 'posts_no_replies', 'posts_with_media']]=None) -> bytes:
"""A view of an actor's feed."""
return _get_author_feed(self.call, actor, limit, cursor)
return _get_author_feed(self.call, actor, limit, cursor, filter)

def get_likes(self, uri: str, cid: typing.Optional[str]=None, limit: typing.Optional[int]=None, cursor: typing.Optional[str]=None) -> bytes:
""""""
Expand Down
15 changes: 13 additions & 2 deletions chitose/app/bsky/feed/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,23 @@ def to_dict(self) -> dict[str, typing.Any]:
class BlockedPost(chitose.Object):
""""""

def __init__(self, uri: str, blocked: bool) -> None:
def __init__(self, uri: str, blocked: bool, author: chitose.app.bsky.feed.defs.BlockedAuthor) -> None:
self.uri = uri
self.blocked = blocked
self.author = author

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

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

def __init__(self, did: str, viewer: typing.Optional[chitose.app.bsky.actor.defs.ViewerState]=None) -> None:
self.did = did
self.viewer = viewer

def to_dict(self) -> dict[str, typing.Any]:
return {'uri': self.uri, 'blocked': self.blocked, '$type': 'app.bsky.feed.defs#blockedPost'}
return {'did': self.did, 'viewer': self.viewer, '$type': 'app.bsky.feed.defs#blockedAuthor'}

class GeneratorView(chitose.Object):
""""""
Expand Down
6 changes: 4 additions & 2 deletions chitose/app/bsky/feed/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
from __future__ import annotations
import chitose
import chitose.app.bsky.richtext.facet
import chitose.com.atproto.label.defs
import typing

class Generator(chitose.Record):
""""""

def __init__(self, did: str, display_name: str, created_at: str, description: typing.Optional[str]=None, description_facets: typing.Optional[list[chitose.app.bsky.richtext.facet.Facet]]=None, avatar: typing.Optional[chitose.Blob]=None) -> None:
def __init__(self, did: str, display_name: str, created_at: str, description: typing.Optional[str]=None, description_facets: typing.Optional[list[chitose.app.bsky.richtext.facet.Facet]]=None, avatar: typing.Optional[chitose.Blob]=None, labels: typing.Optional[chitose.com.atproto.label.defs.SelfLabels]=None) -> None:
self.did = did
self.display_name = display_name
self.created_at = created_at
self.description = description
self.description_facets = description_facets
self.avatar = avatar
self.labels = labels

def to_dict(self) -> dict[str, typing.Any]:
return {'did': self.did, 'displayName': self.display_name, 'createdAt': self.created_at, 'description': self.description, 'descriptionFacets': self.description_facets, 'avatar': self.avatar, '$type': 'app.bsky.feed.generator'}
return {'did': self.did, 'displayName': self.display_name, 'createdAt': self.created_at, 'description': self.description, 'descriptionFacets': self.description_facets, 'avatar': self.avatar, 'labels': self.labels, '$type': 'app.bsky.feed.generator'}
4 changes: 2 additions & 2 deletions chitose/app/bsky/feed/get_author_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
import chitose
import typing

def _get_author_feed(call: chitose.xrpc.XrpcCall, actor: str, limit: typing.Optional[int]=None, cursor: typing.Optional[str]=None) -> bytes:
def _get_author_feed(call: chitose.xrpc.XrpcCall, actor: str, limit: typing.Optional[int]=None, cursor: typing.Optional[str]=None, filter: typing.Optional[typing.Literal['posts_with_replies', 'posts_no_replies', 'posts_with_media']]=None) -> bytes:
"""A view of an actor's feed."""
return call('app.bsky.feed.getAuthorFeed', [('actor', actor), ('limit', limit), ('cursor', cursor)], None, {})
return call('app.bsky.feed.getAuthorFeed', [('actor', actor), ('limit', limit), ('cursor', cursor), ('filter', filter)], None, {})
6 changes: 4 additions & 2 deletions chitose/app/bsky/feed/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import chitose.app.bsky.embed.record_with_media
import chitose.app.bsky.feed.post
import chitose.app.bsky.richtext.facet
import chitose.com.atproto.label.defs
import chitose.com.atproto.repo.strong_ref
import typing

Expand All @@ -18,17 +19,18 @@ class Post(chitose.Record):
:param entities: Deprecated: replaced by app.bsky.richtext.facet.
"""

def __init__(self, text: str, created_at: str, entities: typing.Optional[list[chitose.app.bsky.feed.post.Entity]]=None, facets: typing.Optional[list[chitose.app.bsky.richtext.facet.Facet]]=None, reply: typing.Optional[chitose.app.bsky.feed.post.ReplyRef]=None, embed: typing.Optional[typing.Union[chitose.app.bsky.embed.images.Images, chitose.app.bsky.embed.external.External, chitose.app.bsky.embed.record.Record, chitose.app.bsky.embed.record_with_media.RecordWithMedia]]=None, langs: typing.Optional[list[str]]=None) -> None:
def __init__(self, text: str, created_at: str, entities: typing.Optional[list[chitose.app.bsky.feed.post.Entity]]=None, facets: typing.Optional[list[chitose.app.bsky.richtext.facet.Facet]]=None, reply: typing.Optional[chitose.app.bsky.feed.post.ReplyRef]=None, embed: typing.Optional[typing.Union[chitose.app.bsky.embed.images.Images, chitose.app.bsky.embed.external.External, chitose.app.bsky.embed.record.Record, chitose.app.bsky.embed.record_with_media.RecordWithMedia]]=None, langs: typing.Optional[list[str]]=None, labels: typing.Optional[chitose.com.atproto.label.defs.SelfLabels]=None) -> None:
self.text = text
self.created_at = created_at
self.entities = entities
self.facets = facets
self.reply = reply
self.embed = embed
self.langs = langs
self.labels = labels

def to_dict(self) -> dict[str, typing.Any]:
return {'text': self.text, 'createdAt': self.created_at, 'entities': self.entities, 'facets': self.facets, 'reply': self.reply, 'embed': self.embed, 'langs': self.langs, '$type': 'app.bsky.feed.post'}
return {'text': self.text, 'createdAt': self.created_at, 'entities': self.entities, 'facets': self.facets, 'reply': self.reply, 'embed': self.embed, 'langs': self.langs, 'labels': self.labels, '$type': 'app.bsky.feed.post'}

class ReplyRef(chitose.Object):
""""""
Expand Down
6 changes: 4 additions & 2 deletions chitose/app/bsky/graph/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
import chitose
import chitose.app.bsky.graph.defs
import chitose.app.bsky.richtext.facet
import chitose.com.atproto.label.defs
import typing

class List(chitose.Record):
""""""

def __init__(self, purpose: chitose.app.bsky.graph.defs.ListPurpose, name: str, created_at: str, description: typing.Optional[str]=None, description_facets: typing.Optional[list[chitose.app.bsky.richtext.facet.Facet]]=None, avatar: typing.Optional[chitose.Blob]=None) -> None:
def __init__(self, purpose: chitose.app.bsky.graph.defs.ListPurpose, name: str, created_at: str, description: typing.Optional[str]=None, description_facets: typing.Optional[list[chitose.app.bsky.richtext.facet.Facet]]=None, avatar: typing.Optional[chitose.Blob]=None, labels: typing.Optional[chitose.com.atproto.label.defs.SelfLabels]=None) -> None:
self.purpose = purpose
self.name = name
self.created_at = created_at
self.description = description
self.description_facets = description_facets
self.avatar = avatar
self.labels = labels

def to_dict(self) -> dict[str, typing.Any]:
return {'purpose': self.purpose, 'name': self.name, 'createdAt': self.created_at, 'description': self.description, 'descriptionFacets': self.description_facets, 'avatar': self.avatar, '$type': 'app.bsky.graph.list'}
return {'purpose': self.purpose, 'name': self.name, 'createdAt': self.created_at, 'description': self.description, 'descriptionFacets': self.description_facets, 'avatar': self.avatar, 'labels': self.labels, '$type': 'app.bsky.graph.list'}
25 changes: 24 additions & 1 deletion chitose/com/atproto/label/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
""""""
from __future__ import annotations
import chitose
import chitose.com.atproto.label.defs
import typing

class Label(chitose.Object):
Expand Down Expand Up @@ -30,4 +31,26 @@ def __init__(self, src: str, uri: str, val: str, cts: str, cid: typing.Optional[
self.neg = neg

def to_dict(self) -> dict[str, typing.Any]:
return {'src': self.src, 'uri': self.uri, 'val': self.val, 'cts': self.cts, 'cid': self.cid, 'neg': self.neg, '$type': 'com.atproto.label.defs#label'}
return {'src': self.src, 'uri': self.uri, 'val': self.val, 'cts': self.cts, 'cid': self.cid, 'neg': self.neg, '$type': 'com.atproto.label.defs#label'}

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

def __init__(self, values: list[chitose.com.atproto.label.defs.SelfLabel]) -> None:
self.values = values

def to_dict(self) -> dict[str, typing.Any]:
return {'values': self.values, '$type': 'com.atproto.label.defs#selfLabels'}

class SelfLabel(chitose.Object):
"""
:param val: the short string name of the value or type of this label
"""

def __init__(self, val: str) -> None:
self.val = val

def to_dict(self) -> dict[str, typing.Any]:
return {'val': self.val, '$type': 'com.atproto.label.defs#selfLabel'}

0 comments on commit bfc5323

Please sign in to comment.