sugyan / atrium

Rust libraries for Bluesky's AT Protocol services.
MIT License
195 stars 21 forks source link

How can I delete reposts of a user? #253

Closed klausi closed 1 hour ago

klausi commented 2 hours ago

Hi, it's me again :)

I'm building a tool to delete all posts older than 90 days https://github.com/klausi/mastodon-bluesky-sync/blob/main/src/delete_posts.rs#L34

I already managed to implement the deletion of the author's own posts and now I would like to also delete reposts. The Javascript SDK has this as agent.deleteRepost(uri) https://docs.bsky.app/docs/tutorials/like-repost#un-reposting-a-post .

Is this already possible with the atrium library?

Thanks!

klausi commented 1 hour ago

Ah, I see the repost URI in the post data like at://did:plc:i7uartkbj7ktzo4tj4rq6oyi/app.bsky.feed.repost/3kikravjfid2u, so I should be able to use that with agent.delete_record().

klausi commented 1 hour ago

Yep, that was it! Checking if the post is a repost and using that URI works:

// Check if this post is a repost.
if let Some(viewer) = &post.post.viewer {
    if let Some(repost) = &viewer.repost {
        dates.insert(
            record.created_at.as_ref().clone().into(),
            repost.to_string(),
        );
        continue;
    }
}

Full code at https://github.com/klausi/mastodon-bluesky-sync/blob/main/src/delete_posts.rs