Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c62fddf44e | ||
|
|
b5a01cbdc2 |
@@ -0,0 +1,65 @@
|
|||||||
|
name: sender pr
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
name: Check
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: 1.96
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
|
- run: |
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/deploy_key
|
||||||
|
chmod 600 ~/.ssh/deploy_key
|
||||||
|
ssh-keyscan ${{ secrets.MY_HOST }} >> ~/.ssh/known_hosts
|
||||||
|
eval $(ssh-agent -s)
|
||||||
|
ssh-add -v ~/.ssh/deploy_key
|
||||||
|
cargo check
|
||||||
|
|
||||||
|
fmt:
|
||||||
|
name: Rustfmt
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
needs: setup_ssh
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: 1.96
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
|
- run: rustup component add rustfmt
|
||||||
|
- run: |
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/deploy_key
|
||||||
|
chmod 600 ~/.ssh/deploy_key
|
||||||
|
ssh-keyscan ${{ secrets.MY_HOST }} >> ~/.ssh/known_hosts
|
||||||
|
eval $(ssh-agent -s)
|
||||||
|
ssh-add -v ~/.ssh/deploy_key
|
||||||
|
cargo fmt --all -- --check
|
||||||
|
|
||||||
|
clippy:
|
||||||
|
name: Clippy
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
needs: setup_ssh
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: 1.96
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
|
- run: rustup component add clippy
|
||||||
|
- run: |
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/deploy_key
|
||||||
|
chmod 600 ~/.ssh/deploy_key
|
||||||
|
ssh-keyscan ${{ secrets.MY_HOST }} >> ~/.ssh/known_hosts
|
||||||
|
eval $(ssh-agent -s)
|
||||||
|
ssh-add -v ~/.ssh/deploy_key
|
||||||
|
cargo clippy -- -D warnings
|
||||||
@@ -4,9 +4,6 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check:
|
check:
|
||||||
@@ -16,7 +13,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.95
|
toolchain: 1.96
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
@@ -35,7 +32,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.95
|
toolchain: 1.96
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
env:
|
env:
|
||||||
AUTH_SID: 'n9c43yr3f2c4743f7y4329dnq238f7'
|
AUTH_SID: 'n9c43yr3f2c4743f7y4329dnq238f7'
|
||||||
@@ -61,7 +58,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.95
|
toolchain: 1.96
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
- run: rustup component add rustfmt
|
- run: rustup component add rustfmt
|
||||||
- run: |
|
- run: |
|
||||||
@@ -81,7 +78,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.95
|
toolchain: 1.96
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
- run: rustup component add clippy
|
- run: rustup component add clippy
|
||||||
- run: |
|
- run: |
|
||||||
@@ -101,7 +98,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.95
|
toolchain: 1.96
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
|
|||||||
Generated
+695
-670
File diff suppressed because it is too large
Load Diff
+6
-8
@@ -1,15 +1,13 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "sender"
|
name = "sender"
|
||||||
version = "0.1.2"
|
version = "0.1.4"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.95"
|
rust-version = "1.96.1"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde_json = { version = "1.0.149" }
|
serde_json = { version = "1.0.150" }
|
||||||
tokio = { version = "1.52.2", features = ["full"] }
|
tokio = { version = "1.52.3", features = ["full"] }
|
||||||
futures = { version = "0.3.32" }
|
textsender_models = { git = "ssh://git@git.kundeng.us/phoenix/textsender_models.git", tag = "v0.5.1", features = ["config", "contact", "envy", "message"] }
|
||||||
textsender_models = { git = "ssh://git@git.kundeng.us/phoenix/textsender_models.git", tag = "v0.3.0" }
|
swoosh = { git = "ssh://git@git.kundeng.us/phoenix/swoosh.git", tag = "v0.5.2" }
|
||||||
swoosh = { git = "ssh://git@git.kundeng.us/phoenix/swoosh.git", tag = "v0.3.3" }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
async-std = { version = "1.13.2" }
|
|
||||||
|
|||||||
+6
-6
@@ -20,14 +20,14 @@ fn path_exists(path: &str) -> bool {
|
|||||||
file.exists()
|
file.exists()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn parse_config() -> (textsender_models::config::auxiliary::TwilioConfig, bool) {
|
pub fn parse_config() -> (textsender_models::config::auxiliary::TwilioConfig, bool) {
|
||||||
let mut config = textsender_models::config::auxiliary::TwilioConfig {
|
let mut config = textsender_models::config::auxiliary::TwilioConfig {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let auth_sid_var = textsender_models::envy::environment::get_env("AUTH_SID").await;
|
let auth_sid_var = textsender_models::envy::environment::get_env("AUTH_SID");
|
||||||
let auth_token_var = textsender_models::envy::environment::get_env("AUTH_TOKEN").await;
|
let auth_token_var = textsender_models::envy::environment::get_env("AUTH_TOKEN");
|
||||||
let phone_number_var = textsender_models::envy::environment::get_env("PHONE_NUMBER").await;
|
let phone_number_var = textsender_models::envy::environment::get_env("PHONE_NUMBER");
|
||||||
let service_sid_var = textsender_models::envy::environment::get_env("SERVICE_SID").await;
|
let service_sid_var = textsender_models::envy::environment::get_env("SERVICE_SID");
|
||||||
config.account_sid = auth_sid_var.value;
|
config.account_sid = auth_sid_var.value;
|
||||||
config.auth_token = auth_token_var.value;
|
config.auth_token = auth_token_var.value;
|
||||||
config.phone_number = phone_number_var.value;
|
config.phone_number = phone_number_var.value;
|
||||||
@@ -46,7 +46,7 @@ pub async fn parse_config() -> (textsender_models::config::auxiliary::TwilioConf
|
|||||||
mod tests {
|
mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_config() {
|
fn test_parse_config() {
|
||||||
let (config, success) = async_std::task::block_on(super::parse_config());
|
let (config, success) = super::parse_config();
|
||||||
assert!(success, "Config was not parsed");
|
assert!(success, "Config was not parsed");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
false,
|
false,
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ async fn main() {
|
|||||||
println!("Message path: {m_path:?}");
|
println!("Message path: {m_path:?}");
|
||||||
println!("Phone Number path: {n_path:?}");
|
println!("Phone Number path: {n_path:?}");
|
||||||
|
|
||||||
let (config, success) = config::parse_config().await;
|
let (config, success) = config::parse_config();
|
||||||
if !success {
|
if !success {
|
||||||
eprintln!("Error parsing config");
|
eprintln!("Error parsing config");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+10
-1
@@ -16,7 +16,16 @@ pub async fn send_messages(
|
|||||||
schedule: false,
|
schedule: false,
|
||||||
schedule_at: None,
|
schedule_at: None,
|
||||||
};
|
};
|
||||||
match swoosh::twilio::api::send_mssage(message, contact, param, config).await {
|
let mut sendmsg = swoosh::SendMsg::default();
|
||||||
|
sendmsg.load_config(
|
||||||
|
&config.auth_token,
|
||||||
|
&config.phone_number,
|
||||||
|
&config.service_sid,
|
||||||
|
&config.account_sid,
|
||||||
|
);
|
||||||
|
sendmsg.load_recipient(&contact.phone_number);
|
||||||
|
sendmsg.load_message(&message.content);
|
||||||
|
match sendmsg.send_message(¶m).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
println!("Raw response: {response:?}");
|
println!("Raw response: {response:?}");
|
||||||
let val = swoosh::twilio::api::response_to_json(response).await;
|
let val = swoosh::twilio::api::response_to_json(response).await;
|
||||||
|
|||||||
Reference in New Issue
Block a user