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

Function GetFollowers

twitterv1/user.go:481–593  ·  view source on GitHub ↗
(c *fiber.Ctx)

Source from the content-addressed store, hash-verified

479}
480
481func GetFollowers(c *fiber.Ctx) error {
482 // auth
483 userDID, pds, _, oauthToken, err := GetAuthFromReq(c)
484 if err != nil {
485 return MissingAuth(c, err)
486 }
487
488 // lets go get our user data
489 actor := c.FormValue("user_id")
490 if actor == "" {
491 actor = c.FormValue("screen_name")
492 if actor == "" {
493 if userDID != nil {
494 actor = *userDID
495 } else {
496 return ReturnError(c, "No user was specified", 195, 403)
497 }
498 }
499 } else {
500 id, err := strconv.ParseInt(actor, 10, 64)
501 if err != nil {
502 return ReturnError(c, "Invalid ID format", 195, 403)
503 }
504 actorPtr, err := bridge.TwitterIDToBlueSky(&id)
505 if err != nil {
506 return ReturnError(c, "ID not found.", 144, fiber.StatusNotFound)
507 }
508 if actorPtr == nil {
509 return ReturnError(c, "ID not found.", 144, fiber.StatusNotFound)
510 }
511 actor = *actorPtr
512 }
513
514 cursor := ""
515 var cursorInt int64
516
517 cursorStr := c.FormValue("cursor")
518 if cursorStr != "" {
519 cursorInt, err = strconv.ParseInt(cursorStr, 10, 64)
520 if err != nil || cursorInt > 1 {
521 cursor, err = bridge.NumToTid(uint64(cursorInt))
522 if err != nil {
523 fmt.Println("Error when converting Followers Cursor:", err)
524 cursor = ""
525 }
526 } else {
527 cursor = ""
528 }
529 } else {
530 cursor = ""
531 }
532
533 if cursorInt == 0 {
534 return EncodeAndSend(c, struct {
535 Users []bridge.TwitterUser `json:"users" xml:"users"`
536 NextCursor uint64 `json:"next_cursor" xml:"next_cursor"`
537 PreviousCursor uint64 `json:"previous_cursor" xml:"previous_cursor"`
538 NextCursorStr string `json:"next_cursor_str" xml:"-"`

Callers

nothing calls this directly

Calls 8

TwitterIDToBlueSkyFunction · 0.92
NumToTidFunction · 0.92
TidToNumFunction · 0.92
GetAuthFromReqFunction · 0.85
MissingAuthFunction · 0.85
ReturnErrorFunction · 0.85
EncodeAndSendFunction · 0.85
HandleBlueskyErrorFunction · 0.85

Tested by

no test coverage detected