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

Function Unfavourite

twitterv1/interaction.go:274–318  ·  view source on GitHub ↗

https://web.archive.org/web/20120412041153/https://dev.twitter.com/docs/api/1/post/favorites/destroy/%3Aid

(c *fiber.Ctx)

Source from the content-addressed store, hash-verified

272
273// https://web.archive.org/web/20120412041153/https://dev.twitter.com/docs/api/1/post/favorites/destroy/%3Aid
274func Unfavourite(c *fiber.Ctx) error { // yes i am canadian
275 postId := c.Params("id")
276 user_did, pds, _, oauthToken, err := GetAuthFromReq(c)
277
278 if err != nil {
279 return MissingAuth(c, err)
280 }
281
282 // Fetch ID
283 idBigInt, err := strconv.ParseInt(postId, 10, 64)
284 if err != nil {
285 return ReturnError(c, "Invalid ID format", 195, 403)
286 }
287 postIdPtr, _, _, err := bridge.TwitterMsgIdToBluesky(&idBigInt)
288 if err != nil {
289 return ReturnError(c, "ID not found.", 144, fiber.StatusNotFound)
290 }
291 postId = *postIdPtr
292
293 post, err := blueskyapi.UnlikePost(*pds, *oauthToken, postId, *user_did)
294
295 if err != nil {
296 fmt.Println("Error:", err)
297 return HandleBlueskyError(c, err.Error(), "com.atproto.repo.deleteRecord", Unfavourite)
298 }
299
300 var newTweet bridge.Tweet
301 if post.Thread.Parent == nil {
302 newTweet = TranslatePostToTweet(post.Thread.Post, "", "", "", nil, nil, *oauthToken, *pds)
303 } else {
304 newTweet = TranslatePostToTweet(post.Thread.Post, post.Thread.Parent.Post.URI, post.Thread.Parent.Post.Author.DID, post.Thread.Parent.Post.Author.Handle, &post.Thread.Parent.Post.Record.CreatedAt.Time, nil, *oauthToken, *pds)
305 }
306
307 db_controller.StoreAnalyticData(db_controller.AnalyticData{
308 DataType: "unfavorite",
309 IPAddress: c.IP(),
310 UserAgent: c.Get("User-Agent"),
311 Language: c.Get("Accept-Language"),
312 TwitterClient: c.Get("X-Twitter-Client"),
313 TwitterClientVersion: c.Get("X-Twitter-Client-Version"),
314 Timestamp: time.Now(),
315 })
316
317 return EncodeAndSend(c, newTweet)
318}
319
320// This handles deleting a tweet, retweet, or reply
321func DeleteTweet(c *fiber.Ctx) error {

Callers

nothing calls this directly

Calls 9

TwitterMsgIdToBlueskyFunction · 0.92
StoreAnalyticDataFunction · 0.92
GetAuthFromReqFunction · 0.85
MissingAuthFunction · 0.85
ReturnErrorFunction · 0.85
HandleBlueskyErrorFunction · 0.85
TranslatePostToTweetFunction · 0.85
EncodeAndSendFunction · 0.85
GetMethod · 0.45

Tested by

no test coverage detected