Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't find account transactions like follow and delete_follow #268

Open
arjanvaneersel opened this issue Dec 13, 2024 · 1 comment
Open

Comments

@arjanvaneersel
Copy link

I want to use the functions as decribed here in the BlueSky documentation: https://docs.bsky.app/docs/tutorials/following.

However I can't find anywhere in the documentation or examples of any subproject (atrium-api, bsky-sdk, etc) how to do this.

Is it at all possible to do such actions with any of the atrium projects. If so, how?

@notapage
Copy link

Hello. You can do it like so:

use atrium_api::{
    app::bsky::graph::follow,
    com::atproto::repo::{create_record, delete_record},
    types::{string::Datetime, Object},
};
use bsky_sdk::BskyAgent;

type Error = Box<dyn std::error::Error>;

pub async fn follow(
    agent: &BskyAgent,
    did: &str,
) -> Result<Object<create_record::OutputData>, Error> {
    Ok(agent
        .create_record(follow::RecordData {
            created_at: Datetime::now(),
            subject: did.parse()?,
        })
        .await?)
}

pub async fn delete_follow(
    agent: &BskyAgent,
    uri: &str,
) -> Result<Object<delete_record::OutputData>, Error> {
    Ok(agent.delete_record(uri).await?)
}

The did for follow can be obtained by requesting https://bsky.social/xrpc/com.atproto.identity.resolveHandle?handle=USERNAME_HERE and the uri for delete_follow can be obtained by accessing the uri field of the create_record::OutputData.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants