add req_send methods for friends.hops, friends.isFollowing and friends.isBlocking
This commit is contained in:
@ -1,5 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
api::dto::content::{SubsetQuery, SubsetQueryOptions, TypedMessage},
|
api::dto::content::{
|
||||||
|
FriendsHops, RelationshipQuery, SubsetQuery, SubsetQueryOptions, TypedMessage,
|
||||||
|
},
|
||||||
feed::Message,
|
feed::Message,
|
||||||
rpc::{Body, BodyType, RequestNo, RpcType, RpcWriter},
|
rpc::{Body, BodyType, RequestNo, RpcType, RpcWriter},
|
||||||
};
|
};
|
||||||
@ -11,6 +13,9 @@ const MAX_RPC_BODY_LEN: usize = 65536;
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ApiMethod {
|
pub enum ApiMethod {
|
||||||
|
FriendsIsFollowing,
|
||||||
|
FriendsIsBlocking,
|
||||||
|
FriendsHops,
|
||||||
GetSubset,
|
GetSubset,
|
||||||
Publish,
|
Publish,
|
||||||
WhoAmI,
|
WhoAmI,
|
||||||
@ -26,6 +31,9 @@ impl ApiMethod {
|
|||||||
pub fn selector(&self) -> &'static [&'static str] {
|
pub fn selector(&self) -> &'static [&'static str] {
|
||||||
use ApiMethod::*;
|
use ApiMethod::*;
|
||||||
match self {
|
match self {
|
||||||
|
FriendsIsFollowing => &["friends", "isFollowing"],
|
||||||
|
FriendsIsBlocking => &["friends", "isBlocking"],
|
||||||
|
FriendsHops => &["friends", "hops"],
|
||||||
GetSubset => &["partialReplication", "getSubset"],
|
GetSubset => &["partialReplication", "getSubset"],
|
||||||
Publish => &["publish"],
|
Publish => &["publish"],
|
||||||
WhoAmI => &["whoami"],
|
WhoAmI => &["whoami"],
|
||||||
@ -40,6 +48,9 @@ impl ApiMethod {
|
|||||||
pub fn from_selector(s: &[&str]) -> Option<Self> {
|
pub fn from_selector(s: &[&str]) -> Option<Self> {
|
||||||
use ApiMethod::*;
|
use ApiMethod::*;
|
||||||
match s {
|
match s {
|
||||||
|
["friends", "isFollowing"] => Some(FriendsIsFollowing),
|
||||||
|
["friends", "isBlocking"] => Some(FriendsIsBlocking),
|
||||||
|
["friends", "hops"] => Some(FriendsHops),
|
||||||
["partialReplication", "getSubset"] => Some(GetSubset),
|
["partialReplication", "getSubset"] => Some(GetSubset),
|
||||||
["publish"] => Some(Publish),
|
["publish"] => Some(Publish),
|
||||||
["whoami"] => Some(WhoAmI),
|
["whoami"] => Some(WhoAmI),
|
||||||
@ -71,6 +82,57 @@ impl<W: Write + Unpin> ApiCaller<W> {
|
|||||||
&mut self.rpc
|
&mut self.rpc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Send ["friends", "isFollowing"] request.
|
||||||
|
pub async fn friends_is_following_req_send(
|
||||||
|
&mut self,
|
||||||
|
args: RelationshipQuery,
|
||||||
|
) -> Result<RequestNo> {
|
||||||
|
let req_no = self
|
||||||
|
.rpc
|
||||||
|
.send_request(
|
||||||
|
ApiMethod::FriendsIsFollowing.selector(),
|
||||||
|
RpcType::Async,
|
||||||
|
&args,
|
||||||
|
// specify None value for `opts`
|
||||||
|
&None::<()>,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
Ok(req_no)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Send ["friends", "isBlocking"] request.
|
||||||
|
pub async fn friends_is_blocking_req_send(
|
||||||
|
&mut self,
|
||||||
|
args: RelationshipQuery,
|
||||||
|
) -> Result<RequestNo> {
|
||||||
|
let req_no = self
|
||||||
|
.rpc
|
||||||
|
.send_request(
|
||||||
|
ApiMethod::FriendsIsBlocking.selector(),
|
||||||
|
RpcType::Async,
|
||||||
|
&args,
|
||||||
|
// specify None value for `opts`
|
||||||
|
&None::<()>,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
Ok(req_no)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Send ["friends", "hops"] request
|
||||||
|
pub async fn friends_hops_req_send(&mut self, args: FriendsHops) -> Result<RequestNo> {
|
||||||
|
let req_no = self
|
||||||
|
.rpc
|
||||||
|
.send_request(
|
||||||
|
ApiMethod::FriendsHops.selector(),
|
||||||
|
RpcType::Source,
|
||||||
|
&args,
|
||||||
|
// specify None value for `opts`
|
||||||
|
&None::<()>,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
Ok(req_no)
|
||||||
|
}
|
||||||
|
|
||||||
/// Send ["partialReplication", "getSubset"] request.
|
/// Send ["partialReplication", "getSubset"] request.
|
||||||
pub async fn getsubset_req_send(
|
pub async fn getsubset_req_send(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
Reference in New Issue
Block a user