Replies This is going to be painful to implement with lack of any docs
(c *fiber.Ctx)
| 171 | // Replies |
| 172 | // This is going to be painful to implement with lack of any docs |
| 173 | func RelatedResults(c *fiber.Ctx) error { |
| 174 | encodedId := c.Params("id") |
| 175 | idInt, err := strconv.ParseInt(encodedId, 10, 64) |
| 176 | if err != nil { |
| 177 | return ReturnError(c, "Invalid ID format", 195, 403) |
| 178 | } |
| 179 | // Fetch ID |
| 180 | uriPtr, _, _, err := bridge.TwitterMsgIdToBluesky(&idInt) |
| 181 | if err != nil { |
| 182 | return ReturnError(c, "ID not found.", 144, fiber.StatusNotFound) |
| 183 | } |
| 184 | uri := *uriPtr |
| 185 | |
| 186 | _, pds, _, oauthToken, err := GetAuthFromReq(c) |
| 187 | |
| 188 | if err != nil { |
| 189 | blankstring := "" |
| 190 | oauthToken = &blankstring |
| 191 | } |
| 192 | |
| 193 | thread, err := blueskyapi.GetPost(*pds, *oauthToken, uri, 1, 0) |
| 194 | |
| 195 | if err != nil { |
| 196 | return HandleBlueskyError(c, err.Error(), "app.bsky.feed.getPostThread", RelatedResults) |
| 197 | } |
| 198 | |
| 199 | if thread.Thread.Replies == nil { |
| 200 | return EncodeAndSend(c, []bridge.RelatedResultsQuery{}) |
| 201 | } |
| 202 | |
| 203 | // Caching the user DIDs efficiently |
| 204 | userDIDs := []string{} |
| 205 | |
| 206 | for _, item := range *thread.Thread.Replies { |
| 207 | if !slices.Contains(userDIDs, item.Post.Author.DID) { |
| 208 | userDIDs = append(userDIDs, item.Post.Author.DID) |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | blueskyapi.GetUsersInfo(*pds, *oauthToken, userDIDs, false) |
| 213 | |
| 214 | postAuthor := bridge.BlueSkyToTwitterID(thread.Thread.Post.Author.DID) |
| 215 | |
| 216 | twitterReplies := bridge.RelatedResultsQuery{ |
| 217 | Annotations: []bridge.Annotations{}, |
| 218 | ResultType: "Tweet", |
| 219 | Score: 1.0, |
| 220 | GroupName: "TweetsWithConversation", |
| 221 | Results: []bridge.Results{}, |
| 222 | } |
| 223 | for _, reply := range *thread.Thread.Replies { |
| 224 | reply.Post.Record.CreatedAt = blueskyapi.FTime{Time: reply.Post.IndexedAt} |
| 225 | twitterReplies.Results = append(twitterReplies.Results, bridge.Results{ |
| 226 | Kind: "Tweet", |
| 227 | Score: 1.0, |
| 228 | Value: TranslatePostToTweet(reply.Post, uri, strconv.FormatInt(*postAuthor, 10), reply.Post.Author.Handle, &thread.Thread.Post.Record.CreatedAt.Time, nil, *oauthToken, *pds), |
| 229 | Annotations: []bridge.Annotations{ |
| 230 | { |
nothing calls this directly
no test coverage detected