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

Function FollowUser

twitterv1/user.go:308–348  ·  view source on GitHub ↗

https://web.archive.org/web/20120407201029/https://dev.twitter.com/docs/api/1/post/friendships/create

(c *fiber.Ctx)

Source from the content-addressed store, hash-verified

306
307// https://web.archive.org/web/20120407201029/https://dev.twitter.com/docs/api/1/post/friendships/create
308func FollowUser(c *fiber.Ctx) error {
309 // auth
310 my_did, pds, _, oauthToken, err := GetAuthFromReq(c)
311 if err != nil {
312 return MissingAuth(c, err)
313 }
314
315 // lets get the user params
316 actor := c.FormValue("user_id")
317 if actor == "" {
318 actor = c.FormValue("screen_name")
319 if actor == "" {
320 return ReturnError(c, "No user was specified", 195, 403)
321 }
322 } else {
323 id, err := strconv.ParseInt(actor, 10, 64)
324 if err != nil {
325 return ReturnError(c, "Invalid ID format", 195, 403)
326 }
327 actorPtr, err := bridge.TwitterIDToBlueSky(&id)
328 if err != nil {
329 return ReturnError(c, "ID not found.", 144, fiber.StatusNotFound)
330 }
331 if actorPtr == nil {
332 return ReturnError(c, "ID not found.", 144, fiber.StatusNotFound)
333 }
334 actor = *actorPtr
335 }
336
337 // follow
338 user, err := blueskyapi.FollowUser(*pds, *oauthToken, actor, *my_did)
339
340 if err != nil {
341 HandleBlueskyError(c, err.Error(), "app.bsky.graph.follow", FollowUser) // lexicon isnt tecnically right, but its fine idc
342 }
343
344 // convert user into twitter format
345 twitterUser := blueskyapi.AuthorTTB(*user)
346
347 return EncodeAndSend(c, twitterUser)
348}
349
350// https://web.archive.org/web/20120407201029/https://dev.twitter.com/docs/api/1/post/friendships/create
351func UnfollowUser(c *fiber.Ctx, actor string) error {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected