Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4550702c7a
|
||
|
|
28de0f61e4
|
||
|
|
a6ba305d13
|
||
|
|
0bb8679e61
|
Generated
+3
-3
@@ -2283,7 +2283,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "swoosh"
|
name = "swoosh"
|
||||||
version = "0.4.1"
|
version = "0.4.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64-ng",
|
"base64-ng",
|
||||||
"const_format",
|
"const_format",
|
||||||
@@ -2368,8 +2368,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "textsender_models"
|
name = "textsender_models"
|
||||||
version = "0.4.3"
|
version = "0.4.10"
|
||||||
source = "git+ssh://git@git.kundeng.us/phoenix/textsender_models.git?tag=v0.4.3-29-720f3d8f75-111#720f3d8f7515d8cd20a9cd73086bd6c1ab857651"
|
source = "git+ssh://git@git.kundeng.us/phoenix/textsender_models.git?tag=v0.4.10-29-6e91320709-111#6e91320709a369b525e911c51682a0d959a746dc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"const_format",
|
"const_format",
|
||||||
"dotenvy",
|
"dotenvy",
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "swoosh"
|
name = "swoosh"
|
||||||
version = "0.4.1"
|
version = "0.4.2"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.96"
|
rust-version = "1.96"
|
||||||
description = "Library to send text messages"
|
description = "Library to send text messages"
|
||||||
@@ -18,7 +18,7 @@ uuid = { version = "1.23.3", features = ["v4", "serde"] }
|
|||||||
base64-ng = { version = "1.0.8" }
|
base64-ng = { version = "1.0.8" }
|
||||||
const_format = { version = "0.2.36" }
|
const_format = { version = "0.2.36" }
|
||||||
josekit = { version = "0.10.3" }
|
josekit = { version = "0.10.3" }
|
||||||
textsender_models = { git = "ssh://git@git.kundeng.us/phoenix/textsender_models.git", tag = "v0.4.3-29-720f3d8f75-111", features = ["config", "contact", "message"] }
|
textsender_models = { git = "ssh://git@git.kundeng.us/phoenix/textsender_models.git", tag = "v0.4.10-29-6e91320709-111", features = ["config", "contact", "message"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempfile = { version = "3.27.0" }
|
tempfile = { version = "3.27.0" }
|
||||||
|
|||||||
+18
-2
@@ -37,6 +37,8 @@ pub async fn send_message(
|
|||||||
|
|
||||||
let params = init_params(contact, msg, config, param);
|
let params = init_params(contact, msg, config, param);
|
||||||
|
|
||||||
|
println!("Params: {params:?}");
|
||||||
|
|
||||||
let url = format!(
|
let url = format!(
|
||||||
"https://api.twilio.com/2010-04-01/Accounts/{}/Messages.json",
|
"https://api.twilio.com/2010-04-01/Accounts/{}/Messages.json",
|
||||||
config.account_sid
|
config.account_sid
|
||||||
@@ -74,7 +76,13 @@ fn init_params(
|
|||||||
params.insert(String::from("SmartEncoded"), String::from("true"));
|
params.insert(String::from("SmartEncoded"), String::from("true"));
|
||||||
params.insert(String::from("ShortenUrls"), String::from("true"));
|
params.insert(String::from("ShortenUrls"), String::from("true"));
|
||||||
let date = match param.schedule_at {
|
let date = match param.schedule_at {
|
||||||
Some(date_value) => date_value.to_string(),
|
Some(date_value) => match convert_time_to_iso(date_value) {
|
||||||
|
Ok(converted) => converted,
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!("Error: {err:?}");
|
||||||
|
String::new()
|
||||||
|
}
|
||||||
|
},
|
||||||
None => String::new(),
|
None => String::new(),
|
||||||
};
|
};
|
||||||
let scheduled_at = match param.schedule_at {
|
let scheduled_at = match param.schedule_at {
|
||||||
@@ -83,7 +91,7 @@ fn init_params(
|
|||||||
};
|
};
|
||||||
if param.schedule && is_scheduleable(Some(&now), Some(&scheduled_at)) {
|
if param.schedule && is_scheduleable(Some(&now), Some(&scheduled_at)) {
|
||||||
params.insert(String::from("ScheduleType"), String::from("fixed"));
|
params.insert(String::from("ScheduleType"), String::from("fixed"));
|
||||||
params.insert(String::from("SendAt"), date);
|
params.insert(String::from("SendAt"), date.clone());
|
||||||
}
|
}
|
||||||
params.insert(String::from("SendAsMms"), String::from("true"));
|
params.insert(String::from("SendAsMms"), String::from("true"));
|
||||||
params.insert(String::from("RiskCheck"), String::from("enable"));
|
params.insert(String::from("RiskCheck"), String::from("enable"));
|
||||||
@@ -115,6 +123,14 @@ fn init_params(
|
|||||||
params
|
params
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn convert_time_to_iso(time: time::OffsetDateTime) -> Result<String, time::error::Format> {
|
||||||
|
use time::format_description::well_known::Iso8601;
|
||||||
|
match time.format(&Iso8601::DEFAULT) {
|
||||||
|
Ok(converted) => Ok(converted),
|
||||||
|
Err(err) => Err(err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn generate_auth(
|
fn generate_auth(
|
||||||
config: &textsender_models::config::auxiliary::TwilioConfig,
|
config: &textsender_models::config::auxiliary::TwilioConfig,
|
||||||
) -> Result<String, base64_ng::EncodeError> {
|
) -> Result<String, base64_ng::EncodeError> {
|
||||||
|
|||||||
Reference in New Issue
Block a user