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

Function GetFollows

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

Source from the content-addressed store, hash-verified

655}
656
657func GetFollows(c *fiber.Ctx) error {
658 // auth
659 userDID, pds, _, oauthToken, err := GetAuthFromReq(c)
660 if err != nil {
661 return MissingAuth(c, err)
662 }
663
664 // lets go get our user data
665 actor := c.FormValue("user_id")
666 if actor == "" {
667 actor = c.FormValue("screen_name")
668 if actor == "" {
669 if userDID != nil {
670 actor = *userDID
671 } else {
672 return ReturnError(c, "No user was specified", 195, 403)
673 }
674 }
675 } else {
676 id, err := strconv.ParseInt(actor, 10, 64)
677 if err != nil {
678 return ReturnError(c, "Invalid ID format", 195, 403)
679 }
680 actorPtr, err := bridge.TwitterIDToBlueSky(&id)
681 if err != nil {
682 return ReturnError(c, "ID not found.", 144, fiber.StatusNotFound)
683 }
684 if actorPtr == nil {
685 return ReturnError(c, "ID not found.", 144, fiber.StatusNotFound)
686 }
687 actor = *actorPtr
688 }
689
690 cursor := ""
691 var cursorInt int64
692
693 cursorStr := c.FormValue("cursor")
694 if cursorStr != "" {
695 cursorInt, err = strconv.ParseInt(cursorStr, 10, 64)
696 if err != nil || cursorInt > 1 {
697 cursor, err = bridge.NumToTid(uint64(cursorInt))
698 if err != nil {
699 fmt.Println("Error when converting Followers Cursor:", err)
700 cursor = ""
701 }
702 } else {
703 cursor = ""
704 }
705 } else {
706 cursor = ""
707 }
708
709 if cursorInt == 0 {
710 return EncodeAndSend(c, struct {
711 Users []bridge.TwitterUser `json:"users" xml:"users"`
712 NextCursor uint64 `json:"next_cursor" xml:"next_cursor"`
713 PreviousCursor uint64 `json:"previous_cursor" xml:"previous_cursor"`
714 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