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

Function status_update

twitterv1/interaction.go:21–68  ·  view source on GitHub ↗

https://web.archive.org/web/20120508224719/https://dev.twitter.com/docs/api/1/post/statuses/update

(c *fiber.Ctx)

Source from the content-addressed store, hash-verified

19
20// https://web.archive.org/web/20120508224719/https://dev.twitter.com/docs/api/1/post/statuses/update
21func status_update(c *fiber.Ctx) error {
22 my_did, pds, _, oauthToken, err := GetAuthFromReq(c)
23
24 if err != nil {
25 return MissingAuth(c, err)
26 }
27
28 status := c.FormValue("status")
29
30 // Status parsing!
31 mentions := findHandleInstances(status)
32 links := findUrlInstances(status)
33 tags := findTagInstances(status)
34
35 // trim_user := c.FormValue("trim_user") // Unused
36 encoded_in_reply_to_status_id_str := c.FormValue("in_reply_to_status_id")
37 encoded_in_reply_to_status_id_int, err := strconv.ParseInt(encoded_in_reply_to_status_id_str, 10, 64)
38 var in_reply_to_status_id *string
39 if err == nil {
40 in_reply_to_status_id, _, _, err = bridge.TwitterMsgIdToBluesky(&encoded_in_reply_to_status_id_int)
41 if err != nil {
42 return ReturnError(c, "The in_reply_to_status_id was not found", 144, fiber.StatusNotFound)
43 }
44 }
45
46 thread, err := blueskyapi.UpdateStatus(*pds, *oauthToken, *my_did, status, in_reply_to_status_id, mentions, links, tags, nil, []int{})
47
48 if err != nil {
49 fmt.Println("Error:", err)
50 return HandleBlueskyError(c, err.Error(), "com.atproto.repo.createRecord", status_update)
51 }
52
53 db_controller.StoreAnalyticData(db_controller.AnalyticData{
54 DataType: "status_update",
55 IPAddress: c.IP(),
56 UserAgent: c.Get("User-Agent"),
57 Language: c.Get("Accept-Language"),
58 TwitterClient: c.Get("X-Twitter-Client"),
59 TwitterClientVersion: c.Get("X-Twitter-Client-Version"),
60 Timestamp: time.Now(),
61 })
62
63 if thread.Thread.Parent == nil {
64 return EncodeAndSend(c, TranslatePostToTweet(thread.Thread.Post, "", "", "", nil, nil, *oauthToken, *pds))
65 } else {
66 return EncodeAndSend(c, 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))
67 }
68}
69
70// https://web.archive.org/web/20120508224719/https://dev.twitter.com/docs/api/1/post/statuses/update
71func status_update_with_media(c *fiber.Ctx) error {

Callers

nothing calls this directly

Calls 12

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

Tested by

no test coverage detected