(pds string, token string, screen_name string, nocache bool)
| 442 | } |
| 443 | |
| 444 | func GetUserInfo(pds string, token string, screen_name string, nocache bool) (*bridge.TwitterUser, error) { |
| 445 | if !nocache { |
| 446 | if user, found := userCache.Get(screen_name); found { |
| 447 | return &user, nil |
| 448 | } |
| 449 | } |
| 450 | |
| 451 | url := pds + "/xrpc/app.bsky.actor.getProfile" + "?actor=" + screen_name |
| 452 | |
| 453 | resp, err := SendRequest(&token, http.MethodGet, url, nil) |
| 454 | if err != nil { |
| 455 | return nil, err |
| 456 | } |
| 457 | defer resp.Body.Close() |
| 458 | if resp.StatusCode != http.StatusOK { |
| 459 | bodyBytes, _ := io.ReadAll(resp.Body) |
| 460 | bodyString := string(bodyBytes) |
| 461 | fmt.Println("Response Status:", resp.StatusCode) |
| 462 | fmt.Println("Response Body:", bodyString) |
| 463 | return nil, errors.New(bodyString) // return response |
| 464 | } |
| 465 | |
| 466 | author := User{} |
| 467 | if err := json.NewDecoder(resp.Body).Decode(&author); err != nil { |
| 468 | return nil, err |
| 469 | } |
| 470 | |
| 471 | twitterUser := AuthorTTB(author) |
| 472 | |
| 473 | userCache.SetMultiple([]string{author.DID, author.Handle}, *twitterUser) |
| 474 | |
| 475 | return twitterUser, nil |
| 476 | } |
| 477 | |
| 478 | func GetUserInfoRaw(pds string, token string, screen_name string) (*User, error) { |
| 479 | url := pds + "/xrpc/app.bsky.actor.getProfile" + "?actor=" + screen_name |
nothing calls this directly
no test coverage detected