(pds string, token string, query string, since *time.Time, until *time.Time)
| 1614 | } |
| 1615 | |
| 1616 | func PostSearch(pds string, token string, query string, since *time.Time, until *time.Time) ([]Post, error) { |
| 1617 | url := pds + "/xrpc/app.bsky.feed.searchPosts?sort=top&q=" + url.QueryEscape(query) |
| 1618 | if since != nil { |
| 1619 | url += "&since=" + since.Format(time.RFC3339) |
| 1620 | } |
| 1621 | if until != nil { |
| 1622 | url += "&until=" + until.Format(time.RFC3339) |
| 1623 | } |
| 1624 | |
| 1625 | resp, err := SendRequest(&token, http.MethodGet, url, nil) |
| 1626 | if err != nil { |
| 1627 | return nil, err |
| 1628 | } |
| 1629 | defer resp.Body.Close() |
| 1630 | |
| 1631 | // // Print the response body |
| 1632 | // bodyBytes, _ := io.ReadAll(resp.Body) |
| 1633 | // bodyString := string(bodyBytes) |
| 1634 | // fmt.Println("Response Body:", bodyString) |
| 1635 | |
| 1636 | if resp.StatusCode != http.StatusOK { |
| 1637 | bodyBytes, _ := io.ReadAll(resp.Body) |
| 1638 | bodyString := string(bodyBytes) |
| 1639 | fmt.Println("Response Status:", resp.StatusCode) |
| 1640 | fmt.Println("Response Body:", bodyString) |
| 1641 | return nil, errors.New("failed to fetch search results") |
| 1642 | } |
| 1643 | |
| 1644 | posts := PostSearchResult{} |
| 1645 | if err := json.NewDecoder(resp.Body).Decode(&posts); err != nil { |
| 1646 | return nil, err |
| 1647 | } |
| 1648 | return posts.Posts, nil |
| 1649 | } |
| 1650 | |
| 1651 | // thank you https://docs.bsky.app/blog/create-post#replies |
| 1652 | func GetReplyRefs(pds string, token string, parentURI string) (*ReplySubject, error) { |
nothing calls this directly
no test coverage detected