diff --git a/cli/cmd/publish.go b/cli/cmd/publish.go index 5a2b266..e522438 100644 --- a/cli/cmd/publish.go +++ b/cli/cmd/publish.go @@ -69,12 +69,22 @@ func publishBookRecords(session atproto.Session, books []store.Book, storePath s var failed []string + // TODO: + // call ListBookRecords and build an index: + // existing, err := atproto.ListBookRecords(session) + // + // then, build a map[string]book of olWorkId and isbn13 values already on the pds + // **Loop over unpublished books** — for each, build a `BookRecord` from the store book (`OLWorkID`, `ISBN` → `ISBN13`, `DateAdded` → `CreatedAt`) for i, book := range books { if book.ATURI != "" { continue } + // TODO: add a guard for book already indexed + // if existingIndex[book.OLWorkID] || existingIndex[book.ISBN] {continue} + } + record := atproto.BookRecord{ OLWorkID: book.OLWorkID, ISBN13: book.ISBN, diff --git a/cli/internal/atproto/records.go b/cli/internal/atproto/records.go index e8ac20b..6b2e429 100644 --- a/cli/internal/atproto/records.go +++ b/cli/internal/atproto/records.go @@ -7,6 +7,20 @@ import ( "net/http" ) +// TODO: +// type ListRecordsResponse struct { +// Records []struct { +// URI string `json:"uri"` +// CID string `json:"cid"` +// Value BookRecord `json:"value"` +// } `json:"records"` +// Cursor string `json:"cursor"` +// } +// +// TODO: +// function to fetch existing book records from PDS, paginated via cursor +// func ListBookRecords(session Session) (ListRecordsResponse, error) + type BookRecord struct { OLWorkID string `json:"olWorkId,omitempty"` ISBN13 string `json:"isbn13,omitempty"`