2022-01-15 15:36:52 +00:00
|
|
|
use std::process;
|
|
|
|
|
|
|
|
use golgi::error::GolgiError;
|
|
|
|
use golgi::sbot::Sbot;
|
2022-02-07 12:44:36 +00:00
|
|
|
use golgi::sbot::{FriendsHops, RelationshipQuery};
|
2022-01-15 15:36:52 +00:00
|
|
|
|
|
|
|
async fn run() -> Result<(), GolgiError> {
|
2022-02-07 12:44:36 +00:00
|
|
|
let mut sbot_client = Sbot::connect(None, None).await?;
|
2022-01-15 15:36:52 +00:00
|
|
|
|
|
|
|
let id = sbot_client.whoami().await?;
|
|
|
|
println!("whoami: {}", id);
|
|
|
|
|
|
|
|
// test ids to follow and block
|
2022-01-31 08:46:58 +00:00
|
|
|
let to_follow = String::from("@5Pt3dKy2HTJ0mWuS78oIiklIX0gBz6BTfEnXsbvke9c=.ed25519");
|
|
|
|
let to_block = String::from("@7Y4nwfQmVtAilEzi5knXdS2gilW7cGKSHXdXoT086LM=.ed25519");
|
2022-01-15 15:36:52 +00:00
|
|
|
|
|
|
|
// follow to_follow
|
2022-01-31 08:46:58 +00:00
|
|
|
let response = sbot_client
|
|
|
|
.set_relationship(&to_follow, true, false)
|
|
|
|
.await?;
|
2022-01-15 15:36:52 +00:00
|
|
|
println!("follow_response: {:?}", response);
|
|
|
|
|
|
|
|
// block to_block
|
2022-01-31 08:46:58 +00:00
|
|
|
let response = sbot_client.set_relationship(&to_block, false, true).await?;
|
2022-01-15 15:36:52 +00:00
|
|
|
println!("follow_response: {:?}", response);
|
|
|
|
|
|
|
|
// print all users you are following
|
2022-01-16 13:55:05 +00:00
|
|
|
let follows = sbot_client
|
2022-01-31 08:46:58 +00:00
|
|
|
.friends_hops(FriendsHops {
|
2022-01-16 13:55:05 +00:00
|
|
|
max: 1,
|
|
|
|
start: None,
|
|
|
|
// doesnt seem like reverse does anything, currently
|
|
|
|
reverse: Some(false),
|
|
|
|
})
|
|
|
|
.await?;
|
2022-01-15 15:36:52 +00:00
|
|
|
println!("follows: {:?}", follows);
|
|
|
|
|
|
|
|
// print if you are following to_follow (should be true)
|
2022-01-31 08:46:58 +00:00
|
|
|
let mref = sbot_client
|
|
|
|
.friends_is_following(RelationshipQuery {
|
|
|
|
source: id.clone(),
|
|
|
|
dest: to_follow.clone(),
|
|
|
|
})
|
|
|
|
.await?;
|
2022-01-15 15:36:52 +00:00
|
|
|
println!("isfollowingmref: {}", mref);
|
|
|
|
|
|
|
|
// print if you are blocking to_block (should be true)
|
2022-01-31 08:46:58 +00:00
|
|
|
let mref = sbot_client
|
|
|
|
.friends_is_blocking(RelationshipQuery {
|
|
|
|
source: id.clone(),
|
|
|
|
dest: to_block.clone(),
|
|
|
|
})
|
|
|
|
.await?;
|
2022-01-15 15:36:52 +00:00
|
|
|
println!("isblockingmref: {}", mref);
|
|
|
|
|
|
|
|
// print if you are blocking to_follow (should be false)
|
2022-01-31 08:46:58 +00:00
|
|
|
let mref = sbot_client
|
|
|
|
.friends_is_blocking(RelationshipQuery {
|
|
|
|
source: id.clone(),
|
|
|
|
dest: to_follow,
|
|
|
|
})
|
|
|
|
.await?;
|
2022-01-15 15:36:52 +00:00
|
|
|
println!("isblockingmref(should be false): {}", mref);
|
|
|
|
|
|
|
|
// print if you are following to_block (should be false)
|
2022-01-31 08:46:58 +00:00
|
|
|
let mref = sbot_client
|
|
|
|
.friends_is_following(RelationshipQuery {
|
|
|
|
source: id,
|
|
|
|
dest: to_block.clone(),
|
|
|
|
})
|
|
|
|
.await?;
|
2022-01-15 15:36:52 +00:00
|
|
|
println!("isfollowingmref(should be false): {}", mref);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[async_std::main]
|
|
|
|
async fn main() {
|
|
|
|
if let Err(e) = run().await {
|
|
|
|
eprintln!("Application error: {}", e);
|
|
|
|
process::exit(1);
|
|
|
|
}
|
|
|
|
}
|