Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0fde9c2edd
|
||
|
|
a9fde833aa
|
||
|
|
0e68debd42
|
||
|
|
d21d72f596
|
||
|
|
29fcf41a9c
|
@@ -21,7 +21,7 @@ jobs:
|
|||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/textsender-models_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/textsender-models_deploy_key
|
||||||
chmod 600 ~/.ssh/textsender-models_deploy_key
|
chmod 600 ~/.ssh/textsender-models_deploy_key
|
||||||
ssh-keyscan ${{ secret.MYHOST }} >> ~/.ssh/known_hosts
|
ssh-keyscan ${{ secrets.MY_HOST }} >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
eval $(ssh-agent -s)
|
eval $(ssh-agent -s)
|
||||||
ssh-add -v ~/.ssh/textsender-models_deploy_key
|
ssh-add -v ~/.ssh/textsender-models_deploy_key
|
||||||
@@ -40,7 +40,7 @@ jobs:
|
|||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/textsender-models_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/textsender-models_deploy_key
|
||||||
chmod 600 ~/.ssh/textsender-models_deploy_key
|
chmod 600 ~/.ssh/textsender-models_deploy_key
|
||||||
ssh-keyscan ${{ secret.MYHOST }} >> ~/.ssh/known_hosts
|
ssh-keyscan ${{ secrets.MY_HOST }} >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
eval $(ssh-agent -s)
|
eval $(ssh-agent -s)
|
||||||
ssh-add -v ~/.ssh/textsender-models_deploy_key
|
ssh-add -v ~/.ssh/textsender-models_deploy_key
|
||||||
@@ -60,7 +60,7 @@ jobs:
|
|||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/textsender-models_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/textsender-models_deploy_key
|
||||||
chmod 600 ~/.ssh/textsender-models_deploy_key
|
chmod 600 ~/.ssh/textsender-models_deploy_key
|
||||||
ssh-keyscan ${{ secret.MYHOST }} >> ~/.ssh/known_hosts
|
ssh-keyscan ${{ secrets.MY_HOST }} >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
eval $(ssh-agent -s)
|
eval $(ssh-agent -s)
|
||||||
ssh-add -v ~/.ssh/textsender-models_deploy_key
|
ssh-add -v ~/.ssh/textsender-models_deploy_key
|
||||||
@@ -80,7 +80,7 @@ jobs:
|
|||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/textsender-models_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/textsender-models_deploy_key
|
||||||
chmod 600 ~/.ssh/textsender-models_deploy_key
|
chmod 600 ~/.ssh/textsender-models_deploy_key
|
||||||
ssh-keyscan ${{ secret.MYHOST }} >> ~/.ssh/known_hosts
|
ssh-keyscan ${{ secrets.MY_HOST }} >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
eval $(ssh-agent -s)
|
eval $(ssh-agent -s)
|
||||||
ssh-add -v ~/.ssh/textsender-models_deploy_key
|
ssh-add -v ~/.ssh/textsender-models_deploy_key
|
||||||
@@ -99,7 +99,7 @@ jobs:
|
|||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/textsender-models_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/textsender-models_deploy_key
|
||||||
chmod 600 ~/.ssh/textsender-models_deploy_key
|
chmod 600 ~/.ssh/textsender-models_deploy_key
|
||||||
ssh-keyscan ${{ secret.MYHOST }} >> ~/.ssh/known_hosts
|
ssh-keyscan ${{ secrets.MY_HOST }} >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
eval $(ssh-agent -s)
|
eval $(ssh-agent -s)
|
||||||
ssh-add -v ~/.ssh/textsender-models_deploy_key
|
ssh-add -v ~/.ssh/textsender-models_deploy_key
|
||||||
|
|||||||
Generated
+2
-2
@@ -1658,8 +1658,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "textsender_models"
|
name = "textsender_models"
|
||||||
version = "0.3.0"
|
version = "0.2.5"
|
||||||
source = "git+ssh://git@git.kundeng.us/phoenix/textsender-models.git?tag=v0.3.0-20-15820d5505-111#15820d550526aea3016821c01f508d8d590292cc"
|
source = "git+ssh://git@git.kundeng.us/phoenix/textsender-models.git?tag=v0.2.5-v0.3.0-migrate-38dbcb09f7-111#38dbcb09f7c2c572f429ec382c01e14b72b1d615"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"const_format",
|
"const_format",
|
||||||
"dotenvy",
|
"dotenvy",
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ uuid = { version = "1.23.1", features = ["v4", "serde"] }
|
|||||||
base64-ng = { version = "1.0.6" }
|
base64-ng = { version = "1.0.6" }
|
||||||
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.3.0-20-15820d5505-111" }
|
textsender_models = { git = "ssh://git@git.kundeng.us/phoenix/textsender-models.git", tag = "v0.2.5-v0.3.0-migrate-38dbcb09f7-111" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempfile = { version = "3.27.0" }
|
tempfile = { version = "3.27.0" }
|
||||||
|
|||||||
+24
-21
@@ -8,7 +8,7 @@ pub async fn send_mssage(
|
|||||||
param: crate::twilio::types::Parameters,
|
param: crate::twilio::types::Parameters,
|
||||||
config: &textsender_models::config::auxiliary::TwilioConfig,
|
config: &textsender_models::config::auxiliary::TwilioConfig,
|
||||||
) -> Result<crate::twilio::api::types::TwilioAPIMessage, std::io::Error> {
|
) -> Result<crate::twilio::api::types::TwilioAPIMessage, std::io::Error> {
|
||||||
if config.account_sid.is_nil() {
|
if config.account_sid.is_empty() {
|
||||||
Err(std::io::Error::other("Account SID is empty"))
|
Err(std::io::Error::other("Account SID is empty"))
|
||||||
} else if config.auth_token.is_empty() {
|
} else if config.auth_token.is_empty() {
|
||||||
Err(std::io::Error::other(" Auth token is empty"))
|
Err(std::io::Error::other(" Auth token is empty"))
|
||||||
@@ -45,9 +45,7 @@ pub async fn send_mssage(
|
|||||||
let converted = date_value.to_string();
|
let converted = date_value.to_string();
|
||||||
converted
|
converted
|
||||||
}
|
}
|
||||||
None => {
|
None => String::new(),
|
||||||
String::new()
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
if param.schedule && is_scheduleable(&Some(now), ¶m.schedule_at) {
|
if param.schedule && is_scheduleable(&Some(now), ¶m.schedule_at) {
|
||||||
params.insert("ScheduleType", "fixed");
|
params.insert("ScheduleType", "fixed");
|
||||||
@@ -60,7 +58,8 @@ pub async fn send_mssage(
|
|||||||
params.insert("Body", msg.content.as_str());
|
params.insert("Body", msg.content.as_str());
|
||||||
|
|
||||||
let url = format!(
|
let url = format!(
|
||||||
"https://api.twilio.com/2010-04-01/Accounts/ACefa1ef516314c9d1a68cbd657de49277/Messages.json"
|
"https://api.twilio.com/2010-04-01/Accounts/{}/Messages.json",
|
||||||
|
config.account_sid
|
||||||
);
|
);
|
||||||
|
|
||||||
// let client = reqwest::Client::new();
|
// let client = reqwest::Client::new();
|
||||||
@@ -73,6 +72,14 @@ pub async fn send_mssage(
|
|||||||
|
|
||||||
match request.send().await {
|
match request.send().await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
|
match response
|
||||||
|
.json::<crate::twilio::api::types::TwilioAPIMessage>()
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(resp) => Ok(resp),
|
||||||
|
Err(err) => Err(std::io::Error::other(err)),
|
||||||
|
}
|
||||||
|
/*
|
||||||
match response.text().await {
|
match response.text().await {
|
||||||
Ok(body) => {
|
Ok(body) => {
|
||||||
let mut obj = crate::twilio::api::types::TwilioAPIMessage {
|
let mut obj = crate::twilio::api::types::TwilioAPIMessage {
|
||||||
@@ -85,6 +92,7 @@ pub async fn send_mssage(
|
|||||||
Err(std::io::Error::other(err))
|
Err(std::io::Error::other(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
Err(err) => Err(std::io::Error::other(err.to_string())),
|
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||||
}
|
}
|
||||||
@@ -94,15 +102,13 @@ pub async fn send_mssage(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generate_auth(config: &textsender_models::config::auxiliary::TwilioConfig) -> Result<String, base64_ng::EncodeError> {
|
fn generate_auth(
|
||||||
|
config: &textsender_models::config::auxiliary::TwilioConfig,
|
||||||
|
) -> Result<String, base64_ng::EncodeError> {
|
||||||
let input = format!("{}:{}", config.account_sid, config.auth_token);
|
let input = format!("{}:{}", config.account_sid, config.auth_token);
|
||||||
match base64_ng::encode(input.as_bytes()) {
|
match base64_ng::encode(input.as_bytes()) {
|
||||||
Ok(encoded) => {
|
Ok(encoded) => Ok(format!("Basic {encoded}")),
|
||||||
Ok(format!("Basic {encoded}"))
|
Err(err) => Err(err),
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
Err(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@@ -205,15 +211,12 @@ fn is_scheduleable(
|
|||||||
) -> bool {
|
) -> bool {
|
||||||
match scheduled {
|
match scheduled {
|
||||||
Some(schedule_at) => {
|
Some(schedule_at) => {
|
||||||
let early = now.unwrap().checked_add(time::Duration::seconds(300)).unwrap();
|
let early = now
|
||||||
if *schedule_at > early {
|
.unwrap()
|
||||||
true
|
.checked_add(time::Duration::seconds(300))
|
||||||
} else {
|
.unwrap();
|
||||||
false
|
if *schedule_at > early { true } else { false }
|
||||||
}
|
|
||||||
}
|
|
||||||
None => {
|
|
||||||
false
|
|
||||||
}
|
}
|
||||||
|
None => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,20 +3,28 @@ pub struct TwilioAPIMessage {
|
|||||||
pub account_sid: String,
|
pub account_sid: String,
|
||||||
pub api_version: String,
|
pub api_version: String,
|
||||||
pub body: String,
|
pub body: String,
|
||||||
// pub date_created: time::OffsetDateTime,
|
#[serde(with = "time::serde::rfc3339::option")]
|
||||||
|
pub date_created: Option<time::OffsetDateTime>,
|
||||||
|
#[serde(with = "time::serde::rfc3339::option")]
|
||||||
pub date_sent: Option<time::OffsetDateTime>,
|
pub date_sent: Option<time::OffsetDateTime>,
|
||||||
|
#[serde(with = "time::serde::rfc3339::option")]
|
||||||
pub date_updated: Option<time::OffsetDateTime>,
|
pub date_updated: Option<time::OffsetDateTime>,
|
||||||
pub direction: String,
|
pub direction: String,
|
||||||
// Not definite of what type this is
|
// Not definite of what type this is
|
||||||
pub error_code: Option<String>,
|
#[serde(skip_serializing_if = "String::is_empty")]
|
||||||
|
pub error_code: String,
|
||||||
// Not definite of what type this is
|
// Not definite of what type this is
|
||||||
pub error_message: Option<String>,
|
#[serde(skip_serializing_if = "String::is_empty")]
|
||||||
|
pub error_message: String,
|
||||||
pub from: String,
|
pub from: String,
|
||||||
pub messaging_service_sid: String,
|
pub messaging_service_sid: String,
|
||||||
pub num_media: String,
|
pub num_media: String,
|
||||||
pub num_segments: String,
|
pub num_segments: String,
|
||||||
pub price: Option<String>,
|
#[serde(skip_serializing_if = "String::is_empty")]
|
||||||
pub price_unit: Option<String>,
|
pub price: String,
|
||||||
|
#[serde(skip_serializing_if = "String::is_empty")]
|
||||||
|
pub price_unit: String,
|
||||||
|
#[serde(skip_serializing_if = "String::is_empty")]
|
||||||
pub sid: String,
|
pub sid: String,
|
||||||
pub status: String,
|
pub status: String,
|
||||||
pub subresource_uris: SubresourceURI,
|
pub subresource_uris: SubresourceURI,
|
||||||
|
|||||||
Reference in New Issue
Block a user