add private.publish rpc request

This commit is contained in:
glyph 2022-03-02 15:54:38 +02:00 committed by adria0.eth
parent 87e3ea58ba
commit fb7062de60
1 changed files with 22 additions and 0 deletions

View File

@ -14,6 +14,7 @@ const MAX_RPC_BODY_LEN: usize = 65536;
#[derive(Debug)]
pub enum ApiMethod {
PrivatePublish,
InviteCreate,
InviteUse,
FriendsIsFollowing,
@ -35,6 +36,7 @@ impl ApiMethod {
pub fn selector(&self) -> &'static [&'static str] {
use ApiMethod::*;
match self {
PrivatePublish => &["private", "publish"],
InviteCreate => &["invite", "create"],
InviteUse => &["invite", "use"],
FriendsIsFollowing => &["friends", "isFollowing"],
@ -55,6 +57,7 @@ impl ApiMethod {
pub fn from_selector(s: &[&str]) -> Option<Self> {
use ApiMethod::*;
match s {
["private", "publish"] => Some(PrivatePublish),
["invite", "create"] => Some(InviteCreate),
["invite", "use"] => Some(InviteUse),
["friends", "isFollowing"] => Some(FriendsIsFollowing),
@ -92,6 +95,25 @@ impl<W: Write + Unpin> ApiCaller<W> {
&mut self.rpc
}
/// Send ["private", "publish"] request.
pub async fn private_publish_req_send(
&mut self,
msg: TypedMessage,
recipients: Vec<String>,
) -> Result<RequestNo> {
let req_no = self
.rpc
.send_request(
ApiMethod::PrivatePublish.selector(),
RpcType::Async,
ArgType::Tuple,
&msg,
&Some(recipients),
)
.await?;
Ok(req_no)
}
/// Send ["invite", "create"] request.
pub async fn invite_create_req_send(&mut self, uses: u16) -> Result<RequestNo> {
let args = InviteCreateOptions { uses };