MCPcopy Create free account
hub / github.com/Preloading/TwitterAPIBridge / UnlikePost

Function UnlikePost

bluesky/blueskyapi.go:1316–1358  ·  view source on GitHub ↗
(pds string, token string, id string, my_did string)

Source from the content-addressed store, hash-verified

1314}
1315
1316func UnlikePost(pds string, token string, id string, my_did string) (*ThreadRoot, error) {
1317 url := pds + "/xrpc/com.atproto.repo.deleteRecord"
1318
1319 thread, err := GetPost(pds, token, id, 0, 1)
1320 if err != nil {
1321 return nil, errors.New("failed to fetch post")
1322 }
1323
1324 payload := DeleteRecordPayload{
1325 Collection: "app.bsky.feed.like",
1326 Repo: my_did,
1327 RKey: strings.Split(*thread.Thread.Post.Viewer.Like, "/app.bsky.feed.like/")[1],
1328 }
1329
1330 reqBody, err := json.Marshal(payload)
1331 if err != nil {
1332 return nil, errors.New("failed to marshal payload")
1333 }
1334
1335 resp, err := SendRequest(&token, http.MethodPost, url, bytes.NewReader(reqBody))
1336 if err != nil {
1337 return nil, err
1338 }
1339 defer resp.Body.Close()
1340
1341 if resp.StatusCode != http.StatusOK {
1342 bodyBytes, _ := io.ReadAll(resp.Body)
1343 bodyString := string(bodyBytes)
1344 fmt.Println("Response Status:", resp.StatusCode)
1345 fmt.Println("Response Body:", bodyString)
1346 return nil, errors.New(bodyString) // return response
1347 }
1348
1349 likeRes := CreateRecordResult{}
1350 if err := json.NewDecoder(resp.Body).Decode(&likeRes); err != nil {
1351 return nil, err
1352 }
1353
1354 emptyString := ""
1355 thread.Thread.Post.Viewer.Like = &emptyString
1356
1357 return thread, nil
1358}
1359
1360func FollowUser(pds string, token string, targetActor string, my_did string) (*User, error) {
1361 url := pds + "/xrpc/com.atproto.repo.createRecord"

Callers

nothing calls this directly

Calls 2

GetPostFunction · 0.85
SendRequestFunction · 0.85

Tested by

no test coverage detected