thank you https://docs.bsky.app/blog/create-post#replies
(pds string, token string, parentURI string)
| 1650 | |
| 1651 | // thank you https://docs.bsky.app/blog/create-post#replies |
| 1652 | func GetReplyRefs(pds string, token string, parentURI string) (*ReplySubject, error) { |
| 1653 | // Get the parent post |
| 1654 | parentThread, err := GetPost(pds, token, parentURI, 0, 1) |
| 1655 | if err != nil { |
| 1656 | return nil, fmt.Errorf("failed to fetch parent post: %w", err) |
| 1657 | } |
| 1658 | |
| 1659 | // If parent has a reply reference, fetch the root post |
| 1660 | var rootURI string |
| 1661 | var rootCID string |
| 1662 | |
| 1663 | if parentThread.Thread.Post.Record.Reply != nil { |
| 1664 | // Get the root post |
| 1665 | rootURI = parentThread.Thread.Post.Record.Reply.Root.URI |
| 1666 | rootThread, err := GetPost(pds, token, rootURI, 0, 1) |
| 1667 | if err != nil { |
| 1668 | return nil, fmt.Errorf("failed to fetch root post: %w", err) |
| 1669 | } |
| 1670 | rootCID = rootThread.Thread.Post.CID |
| 1671 | } else { |
| 1672 | // If parent has no reply reference, it's a top-level post, so it's also the root |
| 1673 | rootURI = parentThread.Thread.Post.URI |
| 1674 | rootCID = parentThread.Thread.Post.CID |
| 1675 | } |
| 1676 | |
| 1677 | return &ReplySubject{ |
| 1678 | Root: Subject{ |
| 1679 | URI: rootURI, |
| 1680 | CID: rootCID, |
| 1681 | }, |
| 1682 | Parent: Subject{ |
| 1683 | URI: parentThread.Thread.Post.URI, |
| 1684 | CID: parentThread.Thread.Post.CID, |
| 1685 | }, |
| 1686 | }, nil |
| 1687 | } |
| 1688 | |
| 1689 | func GetRecordWithUri(pds string, uri string) (*RecordResponse, error) { |
| 1690 | collection, repo, rkey := GetURIComponents(uri) |
no test coverage detected