Gets the relationship between the authenticated user and the users specified another xml endpoint https://github.com/RuaanV/MyTwit/blob/3466157350ad8ce2ca4e3503ae3cc5bbbe3d3de4/MyTwit/LinqToTwitterAg/Friendship/FriendshipRequestProcessor.cs#L118 and https://web.archive.org/web/20120516155714/https:/
(c *fiber.Ctx)
| 107 | // and |
| 108 | // https://web.archive.org/web/20120516155714/https://dev.twitter.com/docs/api/1/get/friendships/lookup |
| 109 | func UserRelationships(c *fiber.Ctx) error { |
| 110 | actors := c.Query("user_id") |
| 111 | isID := true |
| 112 | if actors == "" { |
| 113 | actors = c.Query("screen_name") |
| 114 | isID = false |
| 115 | if actors == "" { |
| 116 | return ReturnError(c, "No user was specified", 195, 403) |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | _, pds, _, oauthToken, err := GetAuthFromReq(c) |
| 121 | |
| 122 | if err != nil { |
| 123 | return MissingAuth(c, err) |
| 124 | } |
| 125 | |
| 126 | actorsArray := strings.Split(actors, ",") |
| 127 | if len(actorsArray) > 100 { |
| 128 | return ReturnError(c, "Max number of times to look up reached (100)", 195, 403) |
| 129 | } |
| 130 | if isID { |
| 131 | for i, actor := range actorsArray { |
| 132 | actorID, err := strconv.ParseInt(actor, 10, 64) |
| 133 | if err != nil { |
| 134 | return ReturnError(c, "Invalid ID format ("+actor+")", 195, 403) |
| 135 | } |
| 136 | actorPtr, err := bridge.TwitterIDToBlueSky(&actorID) |
| 137 | if err != nil { |
| 138 | return ReturnError(c, "ID not found. ("+strconv.FormatInt(actorID, 10)+")", 144, fiber.StatusNotFound) |
| 139 | } |
| 140 | if actorPtr != nil { |
| 141 | actorsArray[i] = *actorPtr |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | relationships := []bridge.UsersRelationship{} |
| 147 | users, err := blueskyapi.GetUsersInfoRaw(*pds, *oauthToken, actorsArray, false) |
| 148 | if err != nil { |
| 149 | fmt.Println("Error:", err) |
| 150 | return HandleBlueskyError(c, err.Error(), "app.bsky.actor.getProfiles", UserRelationships) |
| 151 | } |
| 152 | for _, user := range users { |
| 153 | encodedUserId := bridge.BlueSkyToTwitterID(user.DID) |
| 154 | |
| 155 | connections := bridge.Connections{} |
| 156 | connectionJSON := []string{} |
| 157 | |
| 158 | if user.Viewer.Following != nil { |
| 159 | connections.Connection = append(connections.Connection, bridge.Connection{Value: "following"}) |
| 160 | connectionJSON = append(connectionJSON, "following") |
| 161 | } |
| 162 | if user.Viewer.FollowedBy != nil { |
| 163 | connections.Connection = append(connections.Connection, bridge.Connection{Value: "followed_by"}) |
| 164 | connectionJSON = append(connectionJSON, "followed_by") |
| 165 | } |
| 166 | if user.Viewer.Blocking != nil { |
nothing calls this directly
no test coverage detected