(pds string, token string, id string, my_did string)
| 1216 | } |
| 1217 | |
| 1218 | func ReTweet(pds string, token string, id string, my_did string) (*ThreadRoot, *string, error) { |
| 1219 | url := pds + "/xrpc/com.atproto.repo.createRecord" |
| 1220 | |
| 1221 | thread, err := GetPost(pds, token, id, 0, 1) |
| 1222 | if err != nil { |
| 1223 | return nil, nil, err |
| 1224 | } |
| 1225 | |
| 1226 | payload := CreateRecordPayload{ |
| 1227 | Collection: "app.bsky.feed.repost", |
| 1228 | Repo: my_did, |
| 1229 | Record: PostInteractionRecord{ |
| 1230 | Type: "app.bsky.feed.repost", |
| 1231 | CreatedAt: time.Now().UTC().Format(time.RFC3339), |
| 1232 | Subject: Subject{ |
| 1233 | URI: thread.Thread.Post.URI, |
| 1234 | CID: thread.Thread.Post.CID, |
| 1235 | }, |
| 1236 | }, |
| 1237 | } |
| 1238 | |
| 1239 | reqBody, err := json.Marshal(payload) |
| 1240 | if err != nil { |
| 1241 | return nil, nil, errors.New("failed to marshal payload") |
| 1242 | } |
| 1243 | |
| 1244 | resp, err := SendRequest(&token, http.MethodPost, url, bytes.NewReader(reqBody)) |
| 1245 | if err != nil { |
| 1246 | return nil, nil, err |
| 1247 | } |
| 1248 | defer resp.Body.Close() |
| 1249 | |
| 1250 | if resp.StatusCode != http.StatusOK { |
| 1251 | bodyBytes, _ := io.ReadAll(resp.Body) |
| 1252 | bodyString := string(bodyBytes) |
| 1253 | fmt.Println("Response Status:", resp.StatusCode) |
| 1254 | fmt.Println("Response Body:", bodyString) |
| 1255 | return nil, nil, errors.New(bodyString) // return response |
| 1256 | } |
| 1257 | |
| 1258 | repost := CreateRecordResult{} |
| 1259 | if err := json.NewDecoder(resp.Body).Decode(&repost); err != nil { |
| 1260 | return nil, nil, err |
| 1261 | } |
| 1262 | |
| 1263 | return thread, &repost.URI, nil |
| 1264 | } |
| 1265 | |
| 1266 | func LikePost(pds string, token string, id string, my_did string) (*ThreadRoot, error) { |
| 1267 | url := pds + "/xrpc/com.atproto.repo.createRecord" |
nothing calls this directly
no test coverage detected