Updating name references
This commit is contained in:
Generated
+17
-1
@@ -135,9 +135,9 @@ name = "catapult"
|
|||||||
version = "0.3.4"
|
version = "0.3.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"reqwest",
|
"reqwest",
|
||||||
|
"schedtxt_models",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"swoosh",
|
"swoosh",
|
||||||
"textsender_models",
|
|
||||||
"time",
|
"time",
|
||||||
"tokio",
|
"tokio",
|
||||||
"uuid",
|
"uuid",
|
||||||
@@ -1643,6 +1643,22 @@ dependencies = [
|
|||||||
"windows-sys 0.61.2",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "schedtxt_models"
|
||||||
|
version = "0.5.3"
|
||||||
|
source = "git+ssh://git@git.kundeng.us/phoenix/schedtxt_models.git?tag=v0.5.3#597af4e84c082bb437cc94817bb19592614681a5"
|
||||||
|
dependencies = [
|
||||||
|
"const_format",
|
||||||
|
"dotenvy",
|
||||||
|
"josekit",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"sqlx",
|
||||||
|
"time",
|
||||||
|
"utoipa",
|
||||||
|
"uuid",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "scopeguard"
|
name = "scopeguard"
|
||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ reqwest = { version = "0.13.4", features = ["json", "stream", "multipart"] }
|
|||||||
serde_json = { version = "1.0.150" }
|
serde_json = { version = "1.0.150" }
|
||||||
time = { version = "0.3.53", features = ["formatting", "macros", "parsing", "serde"] }
|
time = { version = "0.3.53", features = ["formatting", "macros", "parsing", "serde"] }
|
||||||
uuid = { version = "1.23.5", features = ["v4", "serde"] }
|
uuid = { version = "1.23.5", features = ["v4", "serde"] }
|
||||||
textsender_models = { git = "ssh://git@git.kundeng.us/phoenix/textsender_models.git", tag = "v0.5.2" }
|
schedtxt_models = { git = "ssh://git@git.kundeng.us/phoenix/schedtxt_models.git", tag = "v0.5.3" }
|
||||||
swoosh = { git = "ssh://git@git.kundeng.us/phoenix/swoosh.git", tag = "v0.5.3" }
|
swoosh = { git = "ssh://git@git.kundeng.us/phoenix/swoosh.git", tag = "v0.5.3" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|||||||
+3
-3
@@ -9,11 +9,11 @@ pub struct App {
|
|||||||
pub auth_url: String,
|
pub auth_url: String,
|
||||||
pub service_username: String,
|
pub service_username: String,
|
||||||
pub service_passphrase: String,
|
pub service_passphrase: String,
|
||||||
pub twilio_config: textsender_models::config::auxiliary::TwilioConfig,
|
pub twilio_config: schedtxt_models::config::auxiliary::TwilioConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_app() -> Result<App, std::io::Error> {
|
pub fn load_app() -> Result<App, std::io::Error> {
|
||||||
use textsender_models::envy;
|
use schedtxt_models::envy;
|
||||||
let auth_url_env = envy::environment::get_env("AUTH_URL");
|
let auth_url_env = envy::environment::get_env("AUTH_URL");
|
||||||
let api_url_env = envy::environment::get_env("API_URL");
|
let api_url_env = envy::environment::get_env("API_URL");
|
||||||
let service_username_env = envy::environment::get_env("SERVICE_USERNAME");
|
let service_username_env = envy::environment::get_env("SERVICE_USERNAME");
|
||||||
@@ -41,7 +41,7 @@ pub fn load_app() -> Result<App, std::io::Error> {
|
|||||||
let api_url: String = api_url_env.value;
|
let api_url: String = api_url_env.value;
|
||||||
let service_username: String = service_username_env.value;
|
let service_username: String = service_username_env.value;
|
||||||
let service_passphrase: String = service_passphrase_env.value;
|
let service_passphrase: String = service_passphrase_env.value;
|
||||||
match textsender_models::config::auxiliary::load_config() {
|
match schedtxt_models::config::auxiliary::load_config() {
|
||||||
Ok(twilio_config) => Ok(App {
|
Ok(twilio_config) => Ok(App {
|
||||||
api_url,
|
api_url,
|
||||||
auth_url,
|
auth_url,
|
||||||
|
|||||||
+6
-6
@@ -3,7 +3,7 @@ pub struct Auth {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Auth {
|
impl Auth {
|
||||||
pub async fn get_token(&self) -> Result<textsender_models::token::Login, std::io::Error> {
|
pub async fn get_token(&self) -> Result<schedtxt_models::token::Login, std::io::Error> {
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
let endpoint = String::from("api/v1/service/login");
|
let endpoint = String::from("api/v1/service/login");
|
||||||
let api_url = format!("{}/{endpoint}", self.app.auth_url);
|
let api_url = format!("{}/{endpoint}", self.app.auth_url);
|
||||||
@@ -37,8 +37,8 @@ impl Auth {
|
|||||||
|
|
||||||
pub async fn get_refresh_token(
|
pub async fn get_refresh_token(
|
||||||
&self,
|
&self,
|
||||||
login_result: &textsender_models::token::Login,
|
login_result: &schedtxt_models::token::Login,
|
||||||
) -> Result<textsender_models::token::Login, std::io::Error> {
|
) -> Result<schedtxt_models::token::Login, std::io::Error> {
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
let endpoint = String::from("api/v1/token/refresh");
|
let endpoint = String::from("api/v1/token/refresh");
|
||||||
let api_url = format!("{}/{endpoint}", self.app.auth_url);
|
let api_url = format!("{}/{endpoint}", self.app.auth_url);
|
||||||
@@ -70,7 +70,7 @@ impl Auth {
|
|||||||
|
|
||||||
async fn parse_token_response(
|
async fn parse_token_response(
|
||||||
response: &str,
|
response: &str,
|
||||||
) -> Result<textsender_models::token::LoginResult, std::io::Error> {
|
) -> Result<schedtxt_models::token::LoginResult, std::io::Error> {
|
||||||
match serde_json::from_str::<serde_json::Value>(response) {
|
match serde_json::from_str::<serde_json::Value>(response) {
|
||||||
Ok(j) => {
|
Ok(j) => {
|
||||||
println!("Good");
|
println!("Good");
|
||||||
@@ -85,7 +85,7 @@ async fn parse_token_response(
|
|||||||
Err(std::io::Error::other("Error response is empty"))
|
Err(std::io::Error::other("Error response is empty"))
|
||||||
} else {
|
} else {
|
||||||
let lr = lrs[0].clone();
|
let lr = lrs[0].clone();
|
||||||
let ll: textsender_models::token::LoginResult =
|
let ll: schedtxt_models::token::LoginResult =
|
||||||
match serde_json::from_value(lr) {
|
match serde_json::from_value(lr) {
|
||||||
Ok(lr) => lr,
|
Ok(lr) => lr,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
@@ -102,7 +102,7 @@ async fn parse_token_response(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn has_token_expired(token: &textsender_models::token::LoginResult) -> bool {
|
pub async fn has_token_expired(token: &schedtxt_models::token::LoginResult) -> bool {
|
||||||
let now = time::OffsetDateTime::now_utc();
|
let now = time::OffsetDateTime::now_utc();
|
||||||
let expire = match time::OffsetDateTime::from_unix_timestamp(token.expires_in) {
|
let expire = match time::OffsetDateTime::from_unix_timestamp(token.expires_in) {
|
||||||
Ok(res) => res,
|
Ok(res) => res,
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
pub struct Contact {
|
pub struct Contact {
|
||||||
pub app: std::sync::Arc<crate::app::App>,
|
pub app: std::sync::Arc<crate::app::App>,
|
||||||
pub token: std::sync::Arc<textsender_models::token::LoginResult>,
|
pub token: std::sync::Arc<schedtxt_models::token::LoginResult>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Contact {
|
impl Contact {
|
||||||
pub async fn get(
|
pub async fn get(
|
||||||
&self,
|
&self,
|
||||||
contact_id: &uuid::Uuid,
|
contact_id: &uuid::Uuid,
|
||||||
) -> Result<Vec<textsender_models::contact::Contact>, std::io::Error> {
|
) -> Result<Vec<schedtxt_models::contact::Contact>, std::io::Error> {
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
let endpoint = format!("api/v1/contact?id={contact_id}");
|
let endpoint = format!("api/v1/contact?id={contact_id}");
|
||||||
let api_url = format!("{}/{endpoint}", self.app.api_url);
|
let api_url = format!("{}/{endpoint}", self.app.api_url);
|
||||||
@@ -34,17 +34,17 @@ impl Contact {
|
|||||||
|
|
||||||
async fn parse_response(
|
async fn parse_response(
|
||||||
response: &str,
|
response: &str,
|
||||||
) -> Result<Vec<textsender_models::contact::Contact>, std::io::Error> {
|
) -> Result<Vec<schedtxt_models::contact::Contact>, std::io::Error> {
|
||||||
match serde_json::from_str::<serde_json::Value>(response) {
|
match serde_json::from_str::<serde_json::Value>(response) {
|
||||||
Ok(j) => match j.get("data") {
|
Ok(j) => match j.get("data") {
|
||||||
Some(serde_json::Value::Array(lrs)) => {
|
Some(serde_json::Value::Array(lrs)) => {
|
||||||
if lrs.is_empty() {
|
if lrs.is_empty() {
|
||||||
Err(std::io::Error::other("Error response is empty"))
|
Err(std::io::Error::other("Error response is empty"))
|
||||||
} else {
|
} else {
|
||||||
let mut events: Vec<textsender_models::contact::Contact> = Vec::new();
|
let mut events: Vec<schedtxt_models::contact::Contact> = Vec::new();
|
||||||
|
|
||||||
for event in lrs.iter() {
|
for event in lrs.iter() {
|
||||||
let ll: textsender_models::contact::Contact =
|
let ll: schedtxt_models::contact::Contact =
|
||||||
match serde_json::from_value(event.clone()) {
|
match serde_json::from_value(event.clone()) {
|
||||||
Ok(lr) => lr,
|
Ok(lr) => lr,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|||||||
+4
-4
@@ -1,13 +1,13 @@
|
|||||||
pub struct Service {
|
pub struct Service {
|
||||||
pub app: std::sync::Arc<crate::app::App>,
|
pub app: std::sync::Arc<crate::app::App>,
|
||||||
pub token: std::sync::Arc<textsender_models::token::Login>,
|
pub token: std::sync::Arc<schedtxt_models::token::Login>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Service {
|
impl Service {
|
||||||
pub async fn do_the_work(&mut self) {
|
pub async fn do_the_work(&mut self) {
|
||||||
println!("Checking queue");
|
println!("Checking queue");
|
||||||
|
|
||||||
use textsender_models::message::scheduling::ScheduledMessage;
|
use schedtxt_models::message::scheduling::ScheduledMessage;
|
||||||
|
|
||||||
let queue = super::queue::Queue {
|
let queue = super::queue::Queue {
|
||||||
app: std::sync::Arc::clone(&self.app),
|
app: std::sync::Arc::clone(&self.app),
|
||||||
@@ -120,7 +120,7 @@ impl Service {
|
|||||||
println!("Message scheduled");
|
println!("Message scheduled");
|
||||||
// MER response
|
// MER response
|
||||||
let result = swoosh::twilio::api::response_to_json(resp).await;
|
let result = swoosh::twilio::api::response_to_json(resp).await;
|
||||||
let mer = textsender_models::message::event::MessageEventResponse {
|
let mer = schedtxt_models::message::event::MessageEventResponse {
|
||||||
contact_id: contact.id.unwrap(),
|
contact_id: contact.id.unwrap(),
|
||||||
scheduled_message_event_id: Some(event.id),
|
scheduled_message_event_id: Some(event.id),
|
||||||
response: result,
|
response: result,
|
||||||
@@ -151,7 +151,7 @@ impl Service {
|
|||||||
|
|
||||||
fn is_schedulable(
|
fn is_schedulable(
|
||||||
&self,
|
&self,
|
||||||
queue_item: &textsender_models::message::scheduling::ScheduledMessage,
|
queue_item: &schedtxt_models::message::scheduling::ScheduledMessage,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
match queue_item.scheduled {
|
match queue_item.scheduled {
|
||||||
Some(date) => date > time::OffsetDateTime::now_utc(),
|
Some(date) => date > time::OffsetDateTime::now_utc(),
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
pub struct Event {
|
pub struct Event {
|
||||||
pub app: std::sync::Arc<crate::app::App>,
|
pub app: std::sync::Arc<crate::app::App>,
|
||||||
pub token: std::sync::Arc<textsender_models::token::LoginResult>,
|
pub token: std::sync::Arc<schedtxt_models::token::LoginResult>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Event {
|
impl Event {
|
||||||
pub async fn get(
|
pub async fn get(
|
||||||
&self,
|
&self,
|
||||||
scheduled_message_id: &uuid::Uuid,
|
scheduled_message_id: &uuid::Uuid,
|
||||||
) -> Result<Vec<textsender_models::message::scheduling::ScheduledMessageEvent>, std::io::Error>
|
) -> Result<Vec<schedtxt_models::message::scheduling::ScheduledMessageEvent>, std::io::Error>
|
||||||
{
|
{
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
let endpoint =
|
let endpoint =
|
||||||
@@ -38,7 +38,7 @@ impl Event {
|
|||||||
|
|
||||||
async fn parse_response(
|
async fn parse_response(
|
||||||
response: &str,
|
response: &str,
|
||||||
) -> Result<Vec<textsender_models::message::scheduling::ScheduledMessageEvent>, std::io::Error> {
|
) -> Result<Vec<schedtxt_models::message::scheduling::ScheduledMessageEvent>, std::io::Error> {
|
||||||
match serde_json::from_str::<serde_json::Value>(response) {
|
match serde_json::from_str::<serde_json::Value>(response) {
|
||||||
Ok(j) => match j.get("data") {
|
Ok(j) => match j.get("data") {
|
||||||
Some(serde_json::Value::Array(lrs)) => {
|
Some(serde_json::Value::Array(lrs)) => {
|
||||||
@@ -46,11 +46,11 @@ async fn parse_response(
|
|||||||
Err(std::io::Error::other("Error response is empty"))
|
Err(std::io::Error::other("Error response is empty"))
|
||||||
} else {
|
} else {
|
||||||
let mut events: Vec<
|
let mut events: Vec<
|
||||||
textsender_models::message::scheduling::ScheduledMessageEvent,
|
schedtxt_models::message::scheduling::ScheduledMessageEvent,
|
||||||
> = Vec::new();
|
> = Vec::new();
|
||||||
|
|
||||||
for event in lrs.iter() {
|
for event in lrs.iter() {
|
||||||
let ll: textsender_models::message::scheduling::ScheduledMessageEvent =
|
let ll: schedtxt_models::message::scheduling::ScheduledMessageEvent =
|
||||||
match serde_json::from_value(event.clone()) {
|
match serde_json::from_value(event.clone()) {
|
||||||
Ok(lr) => lr,
|
Ok(lr) => lr,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|||||||
+6
-6
@@ -1,13 +1,13 @@
|
|||||||
pub struct MessageEventResponse {
|
pub struct MessageEventResponse {
|
||||||
pub app: std::sync::Arc<crate::app::App>,
|
pub app: std::sync::Arc<crate::app::App>,
|
||||||
pub token: std::sync::Arc<textsender_models::token::LoginResult>,
|
pub token: std::sync::Arc<schedtxt_models::token::LoginResult>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MessageEventResponse {
|
impl MessageEventResponse {
|
||||||
pub async fn record_message_event_response(
|
pub async fn record_message_event_response(
|
||||||
&self,
|
&self,
|
||||||
mer: &textsender_models::message::event::MessageEventResponse,
|
mer: &schedtxt_models::message::event::MessageEventResponse,
|
||||||
) -> Result<textsender_models::message::event::MessageEventResponse, std::io::Error> {
|
) -> Result<schedtxt_models::message::event::MessageEventResponse, std::io::Error> {
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
let endpoint = String::from("api/v1/schedule/message/event/response/record");
|
let endpoint = String::from("api/v1/schedule/message/event/response/record");
|
||||||
let api_url = format!("{}/{endpoint}", self.app.api_url);
|
let api_url = format!("{}/{endpoint}", self.app.api_url);
|
||||||
@@ -27,7 +27,7 @@ impl MessageEventResponse {
|
|||||||
"response": mer.response,
|
"response": mer.response,
|
||||||
"user_id": mer.user_id,
|
"user_id": mer.user_id,
|
||||||
"sent": sent,
|
"sent": sent,
|
||||||
"status": textsender_models::message::event::MESSAGE_EVENT_RESPONSE_STATUS_SCHEDULED,
|
"status": schedtxt_models::message::event::MESSAGE_EVENT_RESPONSE_STATUS_SCHEDULED,
|
||||||
"contact_id": mer.contact_id,
|
"contact_id": mer.contact_id,
|
||||||
"message_id": mer.message_id
|
"message_id": mer.message_id
|
||||||
});
|
});
|
||||||
@@ -79,7 +79,7 @@ impl MessageEventResponse {
|
|||||||
|
|
||||||
async fn parse_response(
|
async fn parse_response(
|
||||||
response: &str,
|
response: &str,
|
||||||
) -> Result<textsender_models::message::event::MessageEventResponse, std::io::Error> {
|
) -> Result<schedtxt_models::message::event::MessageEventResponse, std::io::Error> {
|
||||||
match serde_json::from_str::<serde_json::Value>(response) {
|
match serde_json::from_str::<serde_json::Value>(response) {
|
||||||
Ok(j) => {
|
Ok(j) => {
|
||||||
println!("Good");
|
println!("Good");
|
||||||
@@ -94,7 +94,7 @@ async fn parse_response(
|
|||||||
Err(std::io::Error::other("Error response is empty"))
|
Err(std::io::Error::other("Error response is empty"))
|
||||||
} else {
|
} else {
|
||||||
let lr = lrs[0].clone();
|
let lr = lrs[0].clone();
|
||||||
let ll: textsender_models::message::event::MessageEventResponse =
|
let ll: schedtxt_models::message::event::MessageEventResponse =
|
||||||
match serde_json::from_value(lr) {
|
match serde_json::from_value(lr) {
|
||||||
Ok(lr) => lr,
|
Ok(lr) => lr,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
pub struct Message {
|
pub struct Message {
|
||||||
pub app: std::sync::Arc<crate::app::App>,
|
pub app: std::sync::Arc<crate::app::App>,
|
||||||
pub token: std::sync::Arc<textsender_models::token::LoginResult>,
|
pub token: std::sync::Arc<schedtxt_models::token::LoginResult>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Message {
|
impl Message {
|
||||||
pub async fn get(
|
pub async fn get(
|
||||||
&self,
|
&self,
|
||||||
message_id: &uuid::Uuid,
|
message_id: &uuid::Uuid,
|
||||||
) -> Result<Vec<textsender_models::message::Message>, std::io::Error> {
|
) -> Result<Vec<schedtxt_models::message::Message>, std::io::Error> {
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
let endpoint = format!("api/v1/message?id={message_id}");
|
let endpoint = format!("api/v1/message?id={message_id}");
|
||||||
let api_url = format!("{}/{endpoint}", self.app.api_url);
|
let api_url = format!("{}/{endpoint}", self.app.api_url);
|
||||||
@@ -34,17 +34,17 @@ impl Message {
|
|||||||
|
|
||||||
async fn parse_response(
|
async fn parse_response(
|
||||||
response: &str,
|
response: &str,
|
||||||
) -> Result<Vec<textsender_models::message::Message>, std::io::Error> {
|
) -> Result<Vec<schedtxt_models::message::Message>, std::io::Error> {
|
||||||
match serde_json::from_str::<serde_json::Value>(response) {
|
match serde_json::from_str::<serde_json::Value>(response) {
|
||||||
Ok(j) => match j.get("data") {
|
Ok(j) => match j.get("data") {
|
||||||
Some(serde_json::Value::Array(lrs)) => {
|
Some(serde_json::Value::Array(lrs)) => {
|
||||||
if lrs.is_empty() {
|
if lrs.is_empty() {
|
||||||
Err(std::io::Error::other("Error response is empty"))
|
Err(std::io::Error::other("Error response is empty"))
|
||||||
} else {
|
} else {
|
||||||
let mut events: Vec<textsender_models::message::Message> = Vec::new();
|
let mut events: Vec<schedtxt_models::message::Message> = Vec::new();
|
||||||
|
|
||||||
for event in lrs.iter() {
|
for event in lrs.iter() {
|
||||||
let ll: textsender_models::message::Message =
|
let ll: schedtxt_models::message::Message =
|
||||||
match serde_json::from_value(event.clone()) {
|
match serde_json::from_value(event.clone()) {
|
||||||
Ok(lr) => lr,
|
Ok(lr) => lr,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
pub struct Queue {
|
pub struct Queue {
|
||||||
pub app: std::sync::Arc<crate::app::App>,
|
pub app: std::sync::Arc<crate::app::App>,
|
||||||
pub token: std::sync::Arc<textsender_models::token::LoginResult>,
|
pub token: std::sync::Arc<schedtxt_models::token::LoginResult>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Queue {
|
impl Queue {
|
||||||
pub async fn get_queue(
|
pub async fn get_queue(
|
||||||
&self,
|
&self,
|
||||||
) -> Result<textsender_models::message::scheduling::ScheduledMessage, std::io::Error> {
|
) -> Result<schedtxt_models::message::scheduling::ScheduledMessage, std::io::Error> {
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
let endpoint = String::from("api/v1/schedule/message/fetch");
|
let endpoint = String::from("api/v1/schedule/message/fetch");
|
||||||
let api_url = format!("{}/{endpoint}", self.app.api_url);
|
let api_url = format!("{}/{endpoint}", self.app.api_url);
|
||||||
@@ -36,7 +36,7 @@ impl Queue {
|
|||||||
|
|
||||||
async fn parse_queue_response(
|
async fn parse_queue_response(
|
||||||
response: &str,
|
response: &str,
|
||||||
) -> Result<textsender_models::message::scheduling::ScheduledMessage, std::io::Error> {
|
) -> Result<schedtxt_models::message::scheduling::ScheduledMessage, std::io::Error> {
|
||||||
match serde_json::from_str::<serde_json::Value>(response) {
|
match serde_json::from_str::<serde_json::Value>(response) {
|
||||||
Ok(j) => {
|
Ok(j) => {
|
||||||
let message = &j["message"];
|
let message = &j["message"];
|
||||||
@@ -50,7 +50,7 @@ async fn parse_queue_response(
|
|||||||
Err(std::io::Error::other("Error response is empty"))
|
Err(std::io::Error::other("Error response is empty"))
|
||||||
} else {
|
} else {
|
||||||
let lr = lrs[0].clone();
|
let lr = lrs[0].clone();
|
||||||
let ll: textsender_models::message::scheduling::ScheduledMessage =
|
let ll: schedtxt_models::message::scheduling::ScheduledMessage =
|
||||||
match serde_json::from_value(lr) {
|
match serde_json::from_value(lr) {
|
||||||
Ok(lr) => lr,
|
Ok(lr) => lr,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
pub struct ScheduledMessage {
|
pub struct ScheduledMessage {
|
||||||
pub app: std::sync::Arc<crate::app::App>,
|
pub app: std::sync::Arc<crate::app::App>,
|
||||||
pub token: std::sync::Arc<textsender_models::token::LoginResult>,
|
pub token: std::sync::Arc<schedtxt_models::token::LoginResult>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ScheduledMessage {
|
impl ScheduledMessage {
|
||||||
pub async fn get(
|
pub async fn get(
|
||||||
&self,
|
&self,
|
||||||
scheduled_message_id: &uuid::Uuid,
|
scheduled_message_id: &uuid::Uuid,
|
||||||
) -> Result<textsender_models::message::scheduling::ScheduledMessage, std::io::Error> {
|
) -> Result<schedtxt_models::message::scheduling::ScheduledMessage, std::io::Error> {
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
let endpoint = format!("api/v1/schedule/message?id={scheduled_message_id}");
|
let endpoint = format!("api/v1/schedule/message?id={scheduled_message_id}");
|
||||||
let api_url = format!("{}/{endpoint}", self.app.api_url);
|
let api_url = format!("{}/{endpoint}", self.app.api_url);
|
||||||
@@ -34,14 +34,14 @@ impl ScheduledMessage {
|
|||||||
|
|
||||||
async fn parse_response(
|
async fn parse_response(
|
||||||
response: &str,
|
response: &str,
|
||||||
) -> Result<textsender_models::message::scheduling::ScheduledMessage, std::io::Error> {
|
) -> Result<schedtxt_models::message::scheduling::ScheduledMessage, std::io::Error> {
|
||||||
match serde_json::from_str::<serde_json::Value>(response) {
|
match serde_json::from_str::<serde_json::Value>(response) {
|
||||||
Ok(j) => match j.get("data") {
|
Ok(j) => match j.get("data") {
|
||||||
Some(serde_json::Value::Array(lrs)) => {
|
Some(serde_json::Value::Array(lrs)) => {
|
||||||
if lrs.is_empty() {
|
if lrs.is_empty() {
|
||||||
Err(std::io::Error::other("Error response is empty"))
|
Err(std::io::Error::other("Error response is empty"))
|
||||||
} else {
|
} else {
|
||||||
let ll: textsender_models::message::scheduling::ScheduledMessage =
|
let ll: schedtxt_models::message::scheduling::ScheduledMessage =
|
||||||
match serde_json::from_value(lrs[0].clone()) {
|
match serde_json::from_value(lrs[0].clone()) {
|
||||||
Ok(lr) => lr,
|
Ok(lr) => lr,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user