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

Function discovery

twitterv1/discover.go:177–250  ·  view source on GitHub ↗
(c *fiber.Ctx)

Source from the content-addressed store, hash-verified

175}
176
177func discovery(c *fiber.Ctx) error {
178 // auth
179 _, pds, _, oauthToken, err := GetAuthFromReq(c)
180
181 if err != nil {
182 blankstring := ""
183 oauthToken = &blankstring
184 }
185
186 thread, err := blueskyapi.GetPost(*pds, *oauthToken, "at://did:plc:khcyntihpu7snjszuojjgjc4/app.bsky.feed.post/3lfgrcq4di22c", 0, 1)
187
188 if err != nil {
189 return HandleBlueskyError(c, err.Error(), "app.bsky.feed.getPostThread", discovery)
190 }
191
192 var displayTweet bridge.Tweet
193
194 // TODO: Some things may be needed for reposts to show up correctly. thats a later problem :)
195 if thread.Thread.Parent == nil {
196 displayTweet = TranslatePostToTweet(thread.Thread.Post, "", "", "", nil, nil, *oauthToken, *pds)
197 } else {
198 displayTweet = TranslatePostToTweet(thread.Thread.Post, thread.Thread.Parent.Post.URI, thread.Thread.Parent.Post.Author.DID, thread.Thread.Parent.Post.Author.Handle, &thread.Thread.Parent.Post.Record.CreatedAt.Time, nil, *oauthToken, *pds)
199 }
200
201 return EncodeAndSend(c, bridge.Discovery{
202 Statuses: []bridge.Tweet{
203 displayTweet,
204 },
205 Stories: []bridge.Story{
206 {
207 Type: "news",
208 Score: 0.92,
209 Data: bridge.StoryData{
210 Title: "Thank you for using A Twitter Bridge!",
211 Articles: []bridge.NewsArticle{
212 {
213 Title: "Thank you for using A Twitter Bridge!",
214 Url: bridge.StoryURL{
215 DisplayURL: "twitterbridge.loganserver.net",
216 ExpandedURL: "https://twitterbridge.loganserver.net",
217 },
218 TweetCount: 1500,
219 Media: []bridge.StoryMediaInfo{
220 {
221 Type: "image", // ?
222 MediaURL: "https://raw.githubusercontent.com/Preloading/TwitterAPIBridge/refs/heads/main/resources/1.png",
223 Width: 1920,
224 Height: 1080,
225 },
226 },
227 },
228 },
229 },
230 SocialProof: bridge.SocialProof{
231 Type: "social",
232 ReferencedBy: bridge.SocialProofedReferencedBy{
233 GlobalCount: 2500,
234 Statuses: []bridge.Tweet{displayTweet},

Callers

nothing calls this directly

Calls 4

GetAuthFromReqFunction · 0.85
HandleBlueskyErrorFunction · 0.85
TranslatePostToTweetFunction · 0.85
EncodeAndSendFunction · 0.85

Tested by

no test coverage detected