Compare commits
24
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a9f27a3f29
|
||
|
|
fcc8c3966c
|
||
|
|
4d3bb7778a
|
||
|
|
b5fd3dbfff
|
||
|
|
bb58dafed3
|
||
|
|
c71f5bed7a
|
||
|
|
6d5e10857d
|
||
|
|
70f5261b49
|
||
|
|
0fde9c2edd
|
||
|
|
a9fde833aa
|
||
|
|
0e68debd42
|
||
|
|
d21d72f596
|
||
|
|
29fcf41a9c
|
||
|
|
f0ffc580e6
|
||
|
|
57d16c6996
|
||
|
|
a065388805
|
||
|
|
3c45061026
|
||
|
|
5752741972
|
||
|
|
2971363d2f
|
||
|
|
0cbf63c78d
|
||
|
|
e487a2c275
|
||
|
|
97dcb360ab
|
||
|
|
7c3b51d6a0
|
||
|
|
c6103ebba4
|
@@ -3,10 +3,10 @@ name: Release Tagging
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- v0.3.x
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- v0.3.x
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ name: swoosh Build
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- v0.3.x
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- v0.3.x
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check:
|
check:
|
||||||
@@ -17,7 +17,6 @@ jobs:
|
|||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.95
|
toolchain: 1.95
|
||||||
- uses: Swatinem/rust-cache@v2
|
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/textsender-models_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/textsender-models_deploy_key
|
||||||
@@ -37,7 +36,6 @@ jobs:
|
|||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.95
|
toolchain: 1.95
|
||||||
- uses: Swatinem/rust-cache@v2
|
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/textsender-models_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/textsender-models_deploy_key
|
||||||
@@ -57,7 +55,6 @@ jobs:
|
|||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.95
|
toolchain: 1.95
|
||||||
- uses: Swatinem/rust-cache@v2
|
|
||||||
- run: rustup component add rustfmt
|
- run: rustup component add rustfmt
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
@@ -78,7 +75,6 @@ jobs:
|
|||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.95
|
toolchain: 1.95
|
||||||
- uses: Swatinem/rust-cache@v2
|
|
||||||
- run: rustup component add clippy
|
- run: rustup component add clippy
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
@@ -99,7 +95,6 @@ jobs:
|
|||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.95
|
toolchain: 1.95
|
||||||
- uses: Swatinem/rust-cache@v2
|
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/textsender-models_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/textsender-models_deploy_key
|
||||||
@@ -110,3 +105,4 @@ jobs:
|
|||||||
ssh-add -v ~/.ssh/textsender-models_deploy_key
|
ssh-add -v ~/.ssh/textsender-models_deploy_key
|
||||||
|
|
||||||
cargo build
|
cargo build
|
||||||
|
|
||||||
|
|||||||
Generated
+12
-11
@@ -59,15 +59,15 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "base64-ng"
|
name = "base64-ng"
|
||||||
version = "1.0.7"
|
version = "1.0.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8992e20e420add1e6e31c6c548a4ba698ed9339bb0863b37478427179c56f05d"
|
checksum = "8452b0c98385f31f08318109d6e06a859f89e0c5e38aad6103f095443b063052"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "2.13.0"
|
version = "2.12.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8"
|
checksum = "84d7ced0ae9557296835c32bf1b1e02b44c746701f898460fb000d7eaa84f00a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bumpalo"
|
name = "bumpalo"
|
||||||
@@ -862,9 +862,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "log"
|
name = "log"
|
||||||
version = "0.4.32"
|
version = "0.4.31"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "953f07c43838f8e6f9758cab68bf5bed85465e7587ebe0b823f1bcd81978ad3a"
|
checksum = "113b30b4cd05f7c06868fdb2854f66a7b9fece9a48425351cd532e810d74024f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lru-slab"
|
name = "lru-slab"
|
||||||
@@ -1573,7 +1573,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "swoosh"
|
name = "swoosh"
|
||||||
version = "0.3.2"
|
version = "0.2.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64-ng",
|
"base64-ng",
|
||||||
"const_format",
|
"const_format",
|
||||||
@@ -1658,12 +1658,13 @@ 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#d504108745b7b97a02eac24e16763cdb5e731f2b"
|
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",
|
||||||
"josekit",
|
"josekit",
|
||||||
|
"rand 0.10.1",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"time",
|
"time",
|
||||||
@@ -2428,9 +2429,9 @@ checksum = "1ffae5123b2d3fc086436f8834ae3ab053a283cfac8fe0a0b8eaae044768a4c4"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "yoke"
|
name = "yoke"
|
||||||
version = "0.8.3"
|
version = "0.8.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5"
|
checksum = "abe8c5fda708d9ca3df187cae8bfb9ceda00dd96231bed36e445a1a48e66f9ca"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"stable_deref_trait",
|
"stable_deref_trait",
|
||||||
"yoke-derive",
|
"yoke-derive",
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "swoosh"
|
name = "swoosh"
|
||||||
version = "0.3.2"
|
version = "0.2.2"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.95"
|
rust-version = "1.95"
|
||||||
description = "Library to send text messages"
|
description = "Library to send text messages"
|
||||||
@@ -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" }
|
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" }
|
||||||
|
|||||||
+15
-11
@@ -1,12 +1,5 @@
|
|||||||
pub mod types;
|
pub mod types;
|
||||||
|
|
||||||
pub async fn response_to_json(response: reqwest::Response) -> serde_json::Value {
|
|
||||||
match response.json().await {
|
|
||||||
Ok(json_body) => json_body,
|
|
||||||
Err(_err) => serde_json::Value::Null,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn send_mssage(
|
pub async fn send_mssage(
|
||||||
msg: &textsender_models::message::Message,
|
msg: &textsender_models::message::Message,
|
||||||
contact: &textsender_models::contact::Contact,
|
contact: &textsender_models::contact::Contact,
|
||||||
@@ -32,11 +25,17 @@ pub async fn send_mssage(
|
|||||||
|
|
||||||
let mut params = std::collections::HashMap::new();
|
let mut params = std::collections::HashMap::new();
|
||||||
params.insert("To", contact.phone_number.as_str());
|
params.insert("To", contact.phone_number.as_str());
|
||||||
|
// params.insert("StatusCallback", "http://OjQozHznkhNTTR.vpnrM1zdXFuiQ");
|
||||||
|
// params.insert("MaxPrice", "1");
|
||||||
params.insert("ProvideFeedback", "true");
|
params.insert("ProvideFeedback", "true");
|
||||||
|
// params.insert("Attempt", "5");
|
||||||
|
// params.insert("ValidityPeriod", "1537");
|
||||||
params.insert("ForceDelivery", "false");
|
params.insert("ForceDelivery", "false");
|
||||||
params.insert("ContentRetention", "retain");
|
params.insert("ContentRetention", "retain");
|
||||||
params.insert("AddressRetention", "obfuscate");
|
params.insert("AddressRetention", "obfuscate");
|
||||||
params.insert("SmartEncoded", "true");
|
params.insert("SmartEncoded", "true");
|
||||||
|
// params.insert("PersistentAction", "string");
|
||||||
|
// params.insert("PersistentAction", "string");
|
||||||
params.insert("ShortenUrls", "true");
|
params.insert("ShortenUrls", "true");
|
||||||
let date = match param.schedule_at {
|
let date = match param.schedule_at {
|
||||||
Some(date_value) => date_value.to_string(),
|
Some(date_value) => date_value.to_string(),
|
||||||
@@ -60,7 +59,7 @@ pub async fn send_mssage(
|
|||||||
let request = client.post(url).headers(headers).form(¶ms);
|
let request = client.post(url).headers(headers).form(¶ms);
|
||||||
match request.send().await {
|
match request.send().await {
|
||||||
Ok(response) => match response.status() {
|
Ok(response) => match response.status() {
|
||||||
reqwest::StatusCode::CREATED => Ok(response),
|
reqwest::StatusCode::OK => Ok(response),
|
||||||
status => Err(std::io::Error::other(format!(
|
status => Err(std::io::Error::other(format!(
|
||||||
"Unaccounted status: {status:?}"
|
"Unaccounted status: {status:?}"
|
||||||
))),
|
))),
|
||||||
@@ -98,9 +97,14 @@ fn generate_auth(
|
|||||||
params.insert("ShortenUrls", "true");
|
params.insert("ShortenUrls", "true");
|
||||||
params.insert("SendAsMms", "true");
|
params.insert("SendAsMms", "true");
|
||||||
params.insert("RiskCheck", "enable");
|
params.insert("RiskCheck", "enable");
|
||||||
*/
|
|
||||||
|
|
||||||
const DEFAULT_SCHEDULING_SECONDS: i64 = 300;
|
let response = request.send().await?;
|
||||||
|
let body = response.text().await?;
|
||||||
|
println!("{}", body);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
fn is_scheduleable(
|
fn is_scheduleable(
|
||||||
now: &Option<time::OffsetDateTime>,
|
now: &Option<time::OffsetDateTime>,
|
||||||
@@ -110,7 +114,7 @@ fn is_scheduleable(
|
|||||||
Some(schedule_at) => {
|
Some(schedule_at) => {
|
||||||
let early = now
|
let early = now
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.checked_add(time::Duration::seconds(DEFAULT_SCHEDULING_SECONDS))
|
.checked_add(time::Duration::seconds(300))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
*schedule_at > early
|
*schedule_at > early
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user