+ Adding POST handler for message sending /message/send
Working as intended
This commit is contained in:
parent
fe448d07d4
commit
9ad963f097
@ -2,6 +2,7 @@ use serde::Deserialize;
|
||||
use crate::api_types::{Jwt, Channel, TEXT_CHANNEL};
|
||||
use reqwest::{Client, Url};
|
||||
use reqwest::Result as HttpResult;
|
||||
use reqwest::Response;
|
||||
|
||||
// TODO: Url generation is kinda gross looking but i'm not 100%
|
||||
// convinced it needs to be pretty if its just going to add overhead
|
||||
@ -36,3 +37,16 @@ pub async fn list_channels(url: &str, id: u64, jwt: &str) -> HttpResult<Vec<Cha
|
||||
let response: ChannelResponse = client.get(url).send().await?.json().await?;
|
||||
Ok(response.channels)
|
||||
}
|
||||
|
||||
pub async fn send_text(url: &str, id: u64, jwt: &str, chan: u64) -> HttpResult<Response> {
|
||||
let client = Client::new();
|
||||
let url = Url::parse_with_params(
|
||||
&format!("{}/message/send", url),
|
||||
&[
|
||||
("id", format!("{}", id).as_str()),
|
||||
("jwt", jwt),
|
||||
("channel_id", &format!("{}", chan))
|
||||
]
|
||||
).unwrap();
|
||||
Ok(client.post(url).send().await?)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user