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

Function UsersLookup

twitterv1/user.go:56–102  ·  view source on GitHub ↗

https://web.archive.org/web/20120508165240/https://dev.twitter.com/docs/api/1/get/users/lookup

(c *fiber.Ctx)

Source from the content-addressed store, hash-verified

54
55// https://web.archive.org/web/20120508165240/https://dev.twitter.com/docs/api/1/get/users/lookup
56func UsersLookup(c *fiber.Ctx) error {
57 screen_name := c.Query("screen_name")
58 user_id := c.Query("user_id")
59 var usersToLookUp []string
60
61 if screen_name != "" {
62 usersToLookUp = strings.Split(screen_name, ",")
63 } else if user_id != "" {
64 userIDs := strings.Split(user_id, ",")
65 for _, idStr := range userIDs {
66 userID, err := strconv.ParseInt(idStr, 10, 64)
67 if err != nil {
68 return ReturnError(c, "Invalid ID format ("+idStr+")", 195, 403)
69 }
70 actor, err := bridge.TwitterIDToBlueSky(&userID)
71 if err != nil {
72 return ReturnError(c, "ID not found. ("+strconv.FormatInt(userID, 10)+")", 144, fiber.StatusNotFound)
73 }
74 if *actor != "" {
75 usersToLookUp = append(usersToLookUp, *actor)
76 }
77 }
78 } else {
79 return ReturnError(c, "No user was specified", 195, 403)
80 }
81
82 if len(usersToLookUp) > 100 {
83 return ReturnError(c, "Max number of times to look up reached (100)", 195, 403)
84 }
85
86 _, pds, _, oauthToken, err := GetAuthFromReq(c)
87
88 if err != nil {
89 blankstring := ""
90 oauthToken = &blankstring
91 }
92
93 // here's some fun problems!
94 // twitter api's max is 100 users per call. bluesky's is 25. so we get to lookup in multiple requests
95
96 users, err := blueskyapi.GetUsersInfo(*pds, *oauthToken, usersToLookUp, false)
97 if err != nil {
98 fmt.Println("Error:", err)
99 return HandleBlueskyError(c, err.Error(), "app.bsky.actor.getProfiles", UsersLookup)
100 }
101 return EncodeAndSend(c, users)
102}
103
104// Gets the relationship between the authenticated user and the users specified
105// another xml endpoint

Callers

nothing calls this directly

Calls 5

TwitterIDToBlueSkyFunction · 0.92
ReturnErrorFunction · 0.85
GetAuthFromReqFunction · 0.85
HandleBlueskyErrorFunction · 0.85
EncodeAndSendFunction · 0.85

Tested by

no test coverage detected