Skip to content

Commit 91c2de4

Browse files
committed
feat: implement replies
1 parent 422b8a6 commit 91c2de4

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

bridge/bridge.go

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,23 @@ import (
1212
)
1313

1414
type RelatedResultsQuery struct {
15-
Annotations interface{} `json:"annotations"` // TODO
16-
ResultType string `json:"resultType"`
17-
Score float64 `json:"score"`
18-
GroupName string `json:"groupName"`
19-
Results []Results `json:"results"`
15+
Annotations []Annotations `json:"annotations"` // TODO
16+
ResultType string `json:"resultType"`
17+
Score float64 `json:"score"`
18+
GroupName string `json:"groupName"`
19+
Results []Results `json:"results"`
2020
}
2121

2222
type Results struct {
23-
Kind string `json:"kind"`
24-
Score float64 `json:"score"`
25-
Annotations interface{} `json:"annotations"` // TODO
26-
Value Tweet `json:"results"`
23+
Kind string `json:"kind"`
24+
Score float64 `json:"score"`
25+
Annotations []Annotations `json:"annotations"` // TODO
26+
Value Tweet `json:"value"`
27+
}
28+
29+
// TODO: Figure out what this is for, and how to use this
30+
type Annotations struct {
31+
ConversationRole string `json:"ConversationRole"`
2732
}
2833

2934
type Retweet struct {
@@ -277,10 +282,9 @@ func TwitterMsgIdToBluesky(id *big.Int) (*string, *time.Time, *string, error) {
277282
if err != nil {
278283
return nil, nil, nil, err
279284
}
280-
} else {
285+
} else if len(parts) == 2 {
281286
// Any other type of tweet
282287
uri = parts[0]
283-
fmt.Println(encodedId)
284288
timestamp, err = time.Parse("20060102T15:04:05Z", strings.ToUpper(parts[1]))
285289
if err != nil {
286290
return nil, nil, nil, err
@@ -291,6 +295,8 @@ func TwitterMsgIdToBluesky(id *big.Int) (*string, *time.Time, *string, error) {
291295
// return nil, nil, nil, errors.New("invalid URI format")
292296
// }
293297
// timestamp, err = DecodeTID(uriparts[4])
298+
} else {
299+
return nil, nil, nil, errors.New("invalid ID format")
294300
}
295301
return &uri, &timestamp, &retweetUserId, nil
296302
}

twitterv1/post_viewing.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ func home_timeline(c *fiber.Ctx) error {
7979

8080
}
8181

82+
// Replies
83+
// This is going to be painful to implement with lack of any docs
8284
func RelatedResults(c *fiber.Ctx) error {
8385
encodedId := c.Params("id")
8486
idBigInt, ok := new(big.Int).SetString(encodedId, 10)
@@ -109,17 +111,23 @@ func RelatedResults(c *fiber.Ctx) error {
109111
postAuthor := bridge.BlueSkyToTwitterID(thread.Thread.Post.Author.DID)
110112

111113
twitterReplies := bridge.RelatedResultsQuery{
112-
Annotations: nil,
114+
Annotations: []bridge.Annotations{},
113115
ResultType: "Tweet",
114116
Score: 1.0,
115117
GroupName: "TweetsWithConversation",
116118
Results: []bridge.Results{},
117119
}
118120
for _, reply := range *thread.Thread.Replies {
121+
reply.Post.Record.CreatedAt = reply.Post.IndexedAt
119122
twitterReplies.Results = append(twitterReplies.Results, bridge.Results{
120123
Kind: "Tweet",
121124
Score: 1.0,
122125
Value: TranslatePostToTweet(reply.Post, uri, postAuthor.String(), &thread.Thread.Post.Record.CreatedAt, nil),
126+
Annotations: []bridge.Annotations{
127+
{
128+
ConversationRole: "Descendant",
129+
},
130+
},
123131
})
124132
}
125133

0 commit comments

Comments
 (0)