MCPcopy Index your code
hub / github.com/Preloading/TwitterAPIBridge / GetUsersInfoRaw

Function GetUsersInfoRaw

bluesky/blueskyapi.go:572–621  ·  view source on GitHub ↗

TODO: Combine this with GetUsersInfo... somehow

(pds string, token string, items []string, ignoreCache bool)

Source from the content-addressed store, hash-verified

570
571// TODO: Combine this with GetUsersInfo... somehow
572func GetUsersInfoRaw(pds string, token string, items []string, ignoreCache bool) ([]*User, error) {
573 var results []*User
574 missing := items // hack
575
576 // Parallel fetching for chunks of up to 25 at a time
577 var wg sync.WaitGroup
578 var mu sync.Mutex
579 for i := 0; i < len(missing); i += 25 {
580 end := i + 25
581 if end > len(missing) {
582 end = len(missing)
583 }
584 chunk := missing[i:end]
585
586 wg.Add(1)
587 go func(c []string) {
588 defer wg.Done()
589
590 url := pds + "/xrpc/app.bsky.actor.getProfiles" + "?actors=" + strings.Join(c, "&actors=")
591 resp, err := SendRequest(&token, http.MethodGet, url, nil)
592 if err != nil {
593 fmt.Println(err)
594 return
595 }
596 defer resp.Body.Close()
597 if resp.StatusCode != http.StatusOK {
598 bodyBytes, _ := io.ReadAll(resp.Body)
599 fmt.Println("Response Status:", resp.StatusCode)
600 fmt.Println("Response Body:", string(bodyBytes))
601 return
602 }
603
604 var authors struct {
605 Profiles []User `json:"profiles"`
606 }
607 if err := json.NewDecoder(resp.Body).Decode(&authors); err != nil {
608 return
609 }
610
611 mu.Lock()
612 for _, author := range authors.Profiles {
613 results = append(results, &author)
614 }
615 mu.Unlock()
616 }(chunk)
617 }
618
619 wg.Wait()
620 return results, nil
621}
622
623// https://docs.bsky.app/docs/api/app-bsky-graph-get-relationships
624func GetRelationships(pds string, token string, source string, others []string) (*RelationshipsRes, error) {

Callers

nothing calls this directly

Calls 1

SendRequestFunction · 0.85

Tested by

no test coverage detected