fix merge conflict

This commit is contained in:
glyph 2022-02-04 10:49:11 +02:00
commit 5391529466
2 changed files with 46 additions and 24 deletions

View File

@ -5,7 +5,7 @@ use std::process;
use golgi::error::GolgiError;
use golgi::messages::SsbMessageContent;
use golgi::sbot::Sbot;
use golgi::sbot::{FriendsHopsOpts, SubsetQuery, SubsetQueryOptions};
use golgi::sbot::{FriendsHops, RelationshipQuery, SubsetQuery, SubsetQueryOptions};
async fn run() -> Result<(), GolgiError> {
let mut sbot_client = Sbot::init(None, None).await?;
@ -14,20 +14,22 @@ async fn run() -> Result<(), GolgiError> {
println!("whoami: {}", id);
// test ids to follow and block
let to_follow = "@5Pt3dKy2HTJ0mWuS78oIiklIX0gBz6BTfEnXsbvke9c=.ed25519";
let to_block = "@7Y4nwfQmVtAilEzi5knXdS2gilW7cGKSHXdXoT086LM=.ed25519";
let to_follow = String::from("@5Pt3dKy2HTJ0mWuS78oIiklIX0gBz6BTfEnXsbvke9c=.ed25519");
let to_block = String::from("@7Y4nwfQmVtAilEzi5knXdS2gilW7cGKSHXdXoT086LM=.ed25519");
// follow to_follow
let response = sbot_client.set_relationship(to_follow, true, false).await?;
let response = sbot_client
.set_relationship(&to_follow, true, false)
.await?;
println!("follow_response: {:?}", response);
// block to_block
let response = sbot_client.set_relationship(to_block, false, true).await?;
let response = sbot_client.set_relationship(&to_block, false, true).await?;
println!("follow_response: {:?}", response);
// print all users you are following
let follows = sbot_client
.friends_hops(FriendsHopsOpts {
.friends_hops(FriendsHops {
max: 1,
start: None,
// doesnt seem like reverse does anything, currently
@ -37,19 +39,39 @@ async fn run() -> Result<(), GolgiError> {
println!("follows: {:?}", follows);
// print if you are following to_follow (should be true)
let mref = sbot_client.friends_is_following(&id, to_follow).await?;
let mref = sbot_client
.friends_is_following(RelationshipQuery {
source: id.clone(),
dest: to_follow.clone(),
})
.await?;
println!("isfollowingmref: {}", mref);
// print if you are blocking to_block (should be true)
let mref = sbot_client.friends_is_blocking(&id, to_block).await?;
let mref = sbot_client
.friends_is_blocking(RelationshipQuery {
source: id.clone(),
dest: to_block.clone(),
})
.await?;
println!("isblockingmref: {}", mref);
// print if you are blocking to_follow (should be false)
let mref = sbot_client.friends_is_blocking(&id, to_follow).await?;
let mref = sbot_client
.friends_is_blocking(RelationshipQuery {
source: id.clone(),
dest: to_follow,
})
.await?;
println!("isblockingmref(should be false): {}", mref);
// print if you are following to_block (should be false)
let mref = sbot_client.friends_is_following(&id, to_block).await?;
let mref = sbot_client
.friends_is_following(RelationshipQuery {
source: id,
dest: to_block.clone(),
})
.await?;
println!("isfollowingmref(should be false): {}", mref);
Ok(())

View File

@ -21,7 +21,9 @@ use crate::utils;
use crate::utils::get_source_stream;
// re-export types from kuska
pub use kuska_ssb::api::dto::content::{FriendsHops, SubsetQuery, SubsetQueryOptions};
pub use kuska_ssb::api::dto::content::{
FriendsHops, RelationshipQuery, SubsetQuery, SubsetQueryOptions,
};
/// A struct representing a connection with a running sbot.
/// A client and an rpc_reader can together be used to make requests to the sbot
@ -211,17 +213,16 @@ impl Sbot {
}
/*
/// Call the `friends isfollowing` RPC method and return a message reference.
/// returns true if src_id is following dest_id and false otherwise
/// Call the `friends isFollowing` RPC method and return a message reference.
/// Returns true if src_id is following dest_id and false otherwise.
pub async fn friends_is_following(
&mut self,
src_id: &str,
dest_id: &str,
args: RelationshipQuery,
) -> Result<String, GolgiError> {
let mut sbot_connection = self.get_sbot_connection().await?;
let req_id = sbot_connection
.client
.friends_isfollowing_req_send(src_id, dest_id)
.friends_is_following_req_send(args)
.await?;
utils::get_async(
@ -233,16 +234,15 @@ impl Sbot {
}
/// Call the `friends isblocking` RPC method and return a message reference.
/// returns true if src_id is blocking dest_id and false otherwise
/// Returns true if src_id is blocking dest_id and false otherwise.
pub async fn friends_is_blocking(
&mut self,
src_id: &str,
dest_id: &str,
args: RelationshipQuery,
) -> Result<String, GolgiError> {
let mut sbot_connection = self.get_sbot_connection().await?;
let req_id = sbot_connection
.client
.friends_isblocking_req_send(src_id, dest_id)
.friends_is_blocking_req_send(args)
.await?;
utils::get_async(
@ -255,7 +255,7 @@ impl Sbot {
// Gets a Vec<String> where each element is a peer you are following
pub async fn get_follows(&mut self) -> Result<Vec<String>, GolgiError> {
self.friends_hops(FriendsHopsOpts {
self.friends_hops(FriendsHops {
max: 1,
start: None,
reverse: Some(false),
@ -268,7 +268,7 @@ impl Sbot {
/// go-sbot does not seem to listen to the reverse=True parameter
/// and just returns follows
async fn get_followers(&mut self) -> Result<Vec<String>, GolgiError> {
self.friends_hops(FriendsHopsOpts {
self.friends_hops(FriendsHops {
max: 1,
start: None,
reverse: Some(true),
@ -281,9 +281,9 @@ impl Sbot {
///
/// When opts.reverse = True, it should return peers who are following you
/// (but this is currently not working)
pub async fn friends_hops(&mut self, opts: FriendsHopsOpts) -> Result<Vec<String>, GolgiError> {
pub async fn friends_hops(&mut self, args: FriendsHops) -> Result<Vec<String>, GolgiError> {
let mut sbot_connection = self.get_sbot_connection().await?;
let req_id = sbot_connection.client.friends_hops_req_send(opts).await?;
let req_id = sbot_connection.client.friends_hops_req_send(args).await?;
utils::get_source_until_eof(
&mut sbot_connection.rpc_reader,
req_id,