https://web.archive.org/web/20101115102530/http://apiwiki.twitter.com/w/page/22554748/Twitter-REST-API-Method%3a-statuses%C2%A0followers At the moment we are not doing pagination, so this will only return the first ~50 followers.
(c *fiber.Ctx)
| 418 | // https://web.archive.org/web/20101115102530/http://apiwiki.twitter.com/w/page/22554748/Twitter-REST-API-Method%3a-statuses%C2%A0followers |
| 419 | // At the moment we are not doing pagination, so this will only return the first ~50 followers. |
| 420 | func GetStatusesFollowers(c *fiber.Ctx) error { |
| 421 | // auth |
| 422 | _, pds, _, oauthToken, err := GetAuthFromReq(c) |
| 423 | if err != nil { |
| 424 | return MissingAuth(c, err) |
| 425 | } |
| 426 | |
| 427 | // lets go get our user data |
| 428 | |
| 429 | actor := c.FormValue("user_id") |
| 430 | if actor == "" { |
| 431 | actor = c.FormValue("screen_name") |
| 432 | if actor == "" { |
| 433 | return ReturnError(c, "No user was specified", 195, 403) |
| 434 | } |
| 435 | } else { |
| 436 | id, err := strconv.ParseInt(actor, 10, 64) |
| 437 | if err != nil { |
| 438 | return ReturnError(c, "Invalid ID format", 195, 403) |
| 439 | } |
| 440 | actorPtr, err := bridge.TwitterIDToBlueSky(&id) |
| 441 | if err != nil { |
| 442 | return ReturnError(c, "ID not found.", 144, fiber.StatusNotFound) |
| 443 | } |
| 444 | if actorPtr == nil { |
| 445 | return ReturnError(c, "ID not found.", 144, fiber.StatusNotFound) |
| 446 | } |
| 447 | actor = *actorPtr |
| 448 | } |
| 449 | |
| 450 | // fetch followers |
| 451 | followers, err := blueskyapi.GetFollowers(*pds, *oauthToken, "", actor) |
| 452 | if err != nil { |
| 453 | fmt.Println("Error:", err) |
| 454 | return HandleBlueskyError(c, err.Error(), "app.bsky.graph.getFollowers", GetStatusesFollowers) |
| 455 | } |
| 456 | |
| 457 | // convert users into twitter format |
| 458 | // This right now doesn't act on pagination, i'll figure that out later |
| 459 | var actorsToLookUp []string |
| 460 | for _, user := range followers.Followers { |
| 461 | actorsToLookUp = append(actorsToLookUp, user.DID) |
| 462 | } |
| 463 | |
| 464 | twitterUsers, err := blueskyapi.GetUsersInfo(*pds, *oauthToken, actorsToLookUp, false) |
| 465 | if err != nil { |
| 466 | fmt.Println("Error:", err) |
| 467 | return HandleBlueskyError(c, err.Error(), "app.bsky.actor.getProfiles", GetStatusesFollowers) |
| 468 | } |
| 469 | |
| 470 | // Convert []*bridge.TwitterUser to []bridge.TwitterUser |
| 471 | var twitterUsersConverted []bridge.TwitterUser |
| 472 | for _, user := range twitterUsers { |
| 473 | twitterUsersConverted = append(twitterUsersConverted, *user) |
| 474 | } |
| 475 | |
| 476 | return EncodeAndSend(c, bridge.TwitterUsers{ |
| 477 | Users: twitterUsersConverted, |
nothing calls this directly
no test coverage detected