Skip to content

Commit

Permalink
some more lexicon updates
Browse files Browse the repository at this point in the history
  • Loading branch information
whyrusleeping committed Apr 20, 2023
1 parent 0ea3242 commit 7945d7b
Show file tree
Hide file tree
Showing 15 changed files with 295 additions and 25 deletions.
2 changes: 2 additions & 0 deletions api/atproto/admindefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ type AdminDefs_RecordViewDetail struct {
Blobs []*AdminDefs_BlobView `json:"blobs" cborgen:"blobs"`
Cid string `json:"cid" cborgen:"cid"`
IndexedAt string `json:"indexedAt" cborgen:"indexedAt"`
Labels []*LabelDefs_Label `json:"labels,omitempty" cborgen:"labels,omitempty"`
Moderation *AdminDefs_ModerationDetail `json:"moderation" cborgen:"moderation"`
Repo *AdminDefs_RepoView `json:"repo" cborgen:"repo"`
Uri string `json:"uri" cborgen:"uri"`
Expand Down Expand Up @@ -229,6 +230,7 @@ type AdminDefs_RepoViewDetail struct {
IndexedAt string `json:"indexedAt" cborgen:"indexedAt"`
InvitedBy *ServerDefs_InviteCode `json:"invitedBy,omitempty" cborgen:"invitedBy,omitempty"`
Invites []*ServerDefs_InviteCode `json:"invites,omitempty" cborgen:"invites,omitempty"`
Labels []*LabelDefs_Label `json:"labels,omitempty" cborgen:"labels,omitempty"`
Moderation *AdminDefs_ModerationDetail `json:"moderation" cborgen:"moderation"`
RelatedRecords []*util.LexiconTypeDecoder `json:"relatedRecords" cborgen:"relatedRecords"`
}
Expand Down
25 changes: 25 additions & 0 deletions api/atproto/adminupdateAccountEmail.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package atproto

import (
"context"

"github.com/bluesky-social/indigo/xrpc"
)

// schema: com.atproto.admin.updateAccountEmail

func init() {
}

type AdminUpdateAccountEmail_Input struct {
Account string `json:"account" cborgen:"account"`
Email string `json:"email" cborgen:"email"`
}

func AdminUpdateAccountEmail(ctx context.Context, c *xrpc.Client, input *AdminUpdateAccountEmail_Input) error {
if err := c.Do(ctx, xrpc.Procedure, "application/json", "com.atproto.admin.updateAccountEmail", nil, input, nil); err != nil {
return err
}

return nil
}
25 changes: 25 additions & 0 deletions api/atproto/adminupdateAccountHandle.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package atproto

import (
"context"

"github.com/bluesky-social/indigo/xrpc"
)

// schema: com.atproto.admin.updateAccountHandle

func init() {
}

type AdminUpdateAccountHandle_Input struct {
Did string `json:"did" cborgen:"did"`
Handle string `json:"handle" cborgen:"handle"`
}

func AdminUpdateAccountHandle(ctx context.Context, c *xrpc.Client, input *AdminUpdateAccountHandle_Input) error {
if err := c.Do(ctx, xrpc.Procedure, "application/json", "com.atproto.admin.updateAccountHandle", nil, input, nil); err != nil {
return err
}

return nil
}
9 changes: 8 additions & 1 deletion api/atproto/labeldefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,11 @@ package atproto
func init() {
}

type LabelDefs_Label interface{}
type LabelDefs_Label struct {
Cid *string `json:"cid,omitempty" cborgen:"cid,omitempty"`
Cts string `json:"cts" cborgen:"cts"`
Neg *bool `json:"neg,omitempty" cborgen:"neg,omitempty"`
Src string `json:"src" cborgen:"src"`
Uri string `json:"uri" cborgen:"uri"`
Val string `json:"val" cborgen:"val"`
}
31 changes: 31 additions & 0 deletions api/atproto/servercreateAppPassword.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package atproto

import (
"context"

"github.com/bluesky-social/indigo/xrpc"
)

// schema: com.atproto.server.createAppPassword

func init() {
}

type ServerCreateAppPassword_AppPassword struct {
CreatedAt string `json:"createdAt" cborgen:"createdAt"`
Name string `json:"name" cborgen:"name"`
Password string `json:"password" cborgen:"password"`
}

type ServerCreateAppPassword_Input struct {
Name string `json:"name" cborgen:"name"`
}

func ServerCreateAppPassword(ctx context.Context, c *xrpc.Client, input *ServerCreateAppPassword_Input) (*ServerCreateAppPassword_AppPassword, error) {
var out ServerCreateAppPassword_AppPassword
if err := c.Do(ctx, xrpc.Procedure, "application/json", "com.atproto.server.createAppPassword", nil, input, &out); err != nil {
return nil, err
}

return &out, nil
}
13 changes: 9 additions & 4 deletions api/atproto/servercreateInviteCodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@ import (
func init() {
}

type ServerCreateInviteCodes_AccountCodes struct {
Account string `json:"account" cborgen:"account"`
Codes []string `json:"codes" cborgen:"codes"`
}

type ServerCreateInviteCodes_Input struct {
CodeCount int64 `json:"codeCount" cborgen:"codeCount"`
ForAccount *string `json:"forAccount,omitempty" cborgen:"forAccount,omitempty"`
UseCount int64 `json:"useCount" cborgen:"useCount"`
CodeCount int64 `json:"codeCount" cborgen:"codeCount"`
ForAccounts []string `json:"forAccounts,omitempty" cborgen:"forAccounts,omitempty"`
UseCount int64 `json:"useCount" cborgen:"useCount"`
}

type ServerCreateInviteCodes_Output struct {
Codes []string `json:"codes" cborgen:"codes"`
Codes []*ServerCreateInviteCodes_AccountCodes `json:"codes" cborgen:"codes"`
}

func ServerCreateInviteCodes(ctx context.Context, c *xrpc.Client, input *ServerCreateInviteCodes_Input) (*ServerCreateInviteCodes_Output, error) {
Expand Down
30 changes: 30 additions & 0 deletions api/atproto/serverlistAppPasswords.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package atproto

import (
"context"

"github.com/bluesky-social/indigo/xrpc"
)

// schema: com.atproto.server.listAppPasswords

func init() {
}

type ServerListAppPasswords_AppPassword struct {
CreatedAt string `json:"createdAt" cborgen:"createdAt"`
Name string `json:"name" cborgen:"name"`
}

type ServerListAppPasswords_Output struct {
Passwords []*ServerListAppPasswords_AppPassword `json:"passwords" cborgen:"passwords"`
}

func ServerListAppPasswords(ctx context.Context, c *xrpc.Client) (*ServerListAppPasswords_Output, error) {
var out ServerListAppPasswords_Output
if err := c.Do(ctx, xrpc.Query, "", "com.atproto.server.listAppPasswords", nil, nil, &out); err != nil {
return nil, err
}

return &out, nil
}
24 changes: 24 additions & 0 deletions api/atproto/serverrevokeAppPassword.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package atproto

import (
"context"

"github.com/bluesky-social/indigo/xrpc"
)

// schema: com.atproto.server.revokeAppPassword

func init() {
}

type ServerRevokeAppPassword_Input struct {
Name string `json:"name" cborgen:"name"`
}

func ServerRevokeAppPassword(ctx context.Context, c *xrpc.Client, input *ServerRevokeAppPassword_Input) error {
if err := c.Do(ctx, xrpc.Procedure, "application/json", "com.atproto.server.revokeAppPassword", nil, input, nil); err != nil {
return err
}

return nil
}
8 changes: 6 additions & 2 deletions api/bsky/notificationgetUnreadCount.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ type NotificationGetUnreadCount_Output struct {
Count int64 `json:"count" cborgen:"count"`
}

func NotificationGetUnreadCount(ctx context.Context, c *xrpc.Client) (*NotificationGetUnreadCount_Output, error) {
func NotificationGetUnreadCount(ctx context.Context, c *xrpc.Client, seenAt string) (*NotificationGetUnreadCount_Output, error) {
var out NotificationGetUnreadCount_Output
if err := c.Do(ctx, xrpc.Query, "", "app.bsky.notification.getUnreadCount", nil, nil, &out); err != nil {

params := map[string]interface{}{
"seenAt": seenAt,
}
if err := c.Do(ctx, xrpc.Query, "", "app.bsky.notification.getUnreadCount", params, nil, &out); err != nil {
return nil, err
}

Expand Down
3 changes: 2 additions & 1 deletion api/bsky/notificationlistNotifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ type NotificationListNotifications_Output struct {
Notifications []*NotificationListNotifications_Notification `json:"notifications" cborgen:"notifications"`
}

func NotificationListNotifications(ctx context.Context, c *xrpc.Client, cursor string, limit int64) (*NotificationListNotifications_Output, error) {
func NotificationListNotifications(ctx context.Context, c *xrpc.Client, cursor string, limit int64, seenAt string) (*NotificationListNotifications_Output, error) {
var out NotificationListNotifications_Output

params := map[string]interface{}{
"cursor": cursor,
"limit": limit,
"seenAt": seenAt,
}
if err := c.Do(ctx, xrpc.Query, "", "app.bsky.notification.listNotifications", params, nil, &out); err != nil {
return nil, err
Expand Down
18 changes: 10 additions & 8 deletions cmd/gosky/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ var getNotificationsCmd = &cli.Command{
return err
}

notifs, err := appbsky.NotificationListNotifications(ctx, xrpcc, "", 50)
notifs, err := appbsky.NotificationListNotifications(ctx, xrpcc, "", 50, "")
if err != nil {
return err
}
Expand Down Expand Up @@ -1059,9 +1059,9 @@ var createInviteCmd = &cli.Command{
for d := range feeder {
did := d
resp, err := comatproto.ServerCreateInviteCodes(context.TODO(), xrpcc, &comatproto.ServerCreateInviteCodes_Input{
UseCount: int64(count),
ForAccount: &did,
CodeCount: int64(num),
UseCount: int64(count),
ForAccounts: []string{did},
CodeCount: int64(num),
})
if err != nil {
log.Error(err)
Expand Down Expand Up @@ -1093,16 +1093,18 @@ var createInviteCmd = &cli.Command{

xrpcc.AdminToken = &adminKey
resp, err := comatproto.ServerCreateInviteCodes(context.TODO(), xrpcc, &comatproto.ServerCreateInviteCodes_Input{
UseCount: int64(count),
ForAccount: usrdid,
CodeCount: int64(num),
UseCount: int64(count),
ForAccounts: []string{*usrdid},
CodeCount: int64(num),
})
if err != nil {
return fmt.Errorf("creating codes: %w", err)
}

for _, c := range resp.Codes {
fmt.Println(c)
for _, cc := range c.Codes {
fmt.Println(cc)
}
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions fakedata/generators.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ func GenLikesRepostsReplies(xrpcc *xrpc.Client, acc *AccountContext, fracLike, f
func BrowseAccount(xrpcc *xrpc.Client, acc *AccountContext) error {
// fetch notifications
maxNotif := 50
resp, err := appbsky.NotificationListNotifications(context.TODO(), xrpcc, "", int64(maxNotif))
resp, err := appbsky.NotificationListNotifications(context.TODO(), xrpcc, "", int64(maxNotif), "")
if err != nil {
return err
}
Expand Down Expand Up @@ -452,6 +452,6 @@ func BrowseAccount(xrpcc *xrpc.Client, acc *AccountContext) error {
t2(len(timelineResp.Feed))

// notification count for good measure
_, err = appbsky.NotificationGetUnreadCount(context.TODO(), xrpcc)
_, err = appbsky.NotificationGetUnreadCount(context.TODO(), xrpcc, "")
return err
}
29 changes: 27 additions & 2 deletions pds/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,14 @@ func (s *Server) handleAppBskyGraphUnmuteActor(ctx context.Context, input *appbs
panic("not yet implemented")
}

func (s *Server) handleAppBskyNotificationGetUnreadCount(ctx context.Context) (*appbskytypes.NotificationGetUnreadCount_Output, error) {
func (s *Server) handleAppBskyNotificationGetUnreadCount(ctx context.Context, seenAt string) (*appbskytypes.NotificationGetUnreadCount_Output, error) {
u, err := s.getUser(ctx)
if err != nil {
return nil, err
}

// TODO: use seenAt

count, err := s.notifman.GetCount(ctx, u.ID)
if err != nil {
return nil, fmt.Errorf("notification getCount: %w", err)
Expand All @@ -241,12 +243,15 @@ func (s *Server) handleAppBskyNotificationGetUnreadCount(ctx context.Context) (*
}, nil
}

func (s *Server) handleAppBskyNotificationListNotifications(ctx context.Context, cursor string, limit int) (*appbskytypes.NotificationListNotifications_Output, error) {
func (s *Server) handleAppBskyNotificationListNotifications(ctx context.Context, cursor string, limit int, seenAt string) (*appbskytypes.NotificationListNotifications_Output, error) {
u, err := s.getUser(ctx)
if err != nil {
return nil, err
}

// TODO: use seenAt
_ = seenAt

notifs, err := s.notifman.GetNotifications(ctx, u.ID)
if err != nil {
return nil, err
Expand Down Expand Up @@ -728,3 +733,23 @@ func (s *Server) handleComAtprotoServerGetAccountInviteCodes(ctx context.Context
func (s *Server) handleComAtprotoSyncListRepos(ctx context.Context, cursor string, limit int) (*comatprototypes.SyncListRepos_Output, error) {
panic("nyi")
}

func (s *Server) handleComAtprotoAdminUpdateAccountEmail(ctx context.Context, body *comatprototypes.AdminUpdateAccountEmail_Input) error {
panic("nyi")
}

func (s *Server) handleComAtprotoAdminUpdateAccountHandle(ctx context.Context, body *comatprototypes.AdminUpdateAccountHandle_Input) error {
panic("nyi")
}

func (s *Server) handleComAtprotoServerCreateAppPassword(ctx context.Context, body *comatprototypes.ServerCreateAppPassword_Input) (*comatprototypes.ServerCreateAppPassword_AppPassword, error) {
panic("nyi")
}

func (s *Server) handleComAtprotoServerListAppPasswords(ctx context.Context) (*comatprototypes.ServerListAppPasswords_Output, error) {
panic("nyi")
}

func (s *Server) handleComAtprotoServerRevokeAppPassword(ctx context.Context, body *comatprototypes.ServerRevokeAppPassword_Input) error {
panic("nyi")
}
Loading

0 comments on commit 7945d7b

Please sign in to comment.