fix: add --all to cargo fmt in script/test and autoformat codebase
cargo fmt without --all fails with "Failed to find targets" in workspace repos. This was blocking every story's gates. Also ran cargo fmt --all to fix all existing formatting issues. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -77,7 +77,6 @@ pub struct BotConfig {
|
||||
|
||||
// ── WhatsApp Business API fields ─────────────────────────────────
|
||||
// These are only required when `transport = "whatsapp"`.
|
||||
|
||||
/// WhatsApp Business phone number ID from the Meta dashboard.
|
||||
#[serde(default)]
|
||||
pub whatsapp_phone_number_id: Option<String>,
|
||||
@@ -105,7 +104,6 @@ pub struct BotConfig {
|
||||
|
||||
// ── Twilio WhatsApp fields ─────────────────────────────────────────
|
||||
// Only required when `transport = "whatsapp"` and `whatsapp_provider = "twilio"`.
|
||||
|
||||
/// Twilio Account SID (starts with `AC`).
|
||||
#[serde(default)]
|
||||
pub twilio_account_sid: Option<String>,
|
||||
@@ -126,7 +124,6 @@ pub struct BotConfig {
|
||||
|
||||
// ── Slack Bot API fields ─────────────────────────────────────────
|
||||
// These are only required when `transport = "slack"`.
|
||||
|
||||
/// Slack Bot User OAuth Token (starts with `xoxb-`).
|
||||
#[serde(default)]
|
||||
pub slack_bot_token: Option<String>,
|
||||
@@ -139,7 +136,6 @@ pub struct BotConfig {
|
||||
|
||||
// ── Discord Bot API fields ──────────────────────────────────────
|
||||
// These are only required when `transport = "discord"`.
|
||||
|
||||
/// Discord bot token from the Discord Developer Portal.
|
||||
#[serde(default)]
|
||||
pub discord_bot_token: Option<String>,
|
||||
@@ -189,21 +185,33 @@ impl BotConfig {
|
||||
if config.transport == "whatsapp" {
|
||||
if config.whatsapp_provider == "twilio" {
|
||||
// Validate Twilio-specific fields.
|
||||
if config.twilio_account_sid.as_ref().is_none_or(|s| s.is_empty()) {
|
||||
if config
|
||||
.twilio_account_sid
|
||||
.as_ref()
|
||||
.is_none_or(|s| s.is_empty())
|
||||
{
|
||||
eprintln!(
|
||||
"[bot] bot.toml: whatsapp_provider=\"twilio\" requires \
|
||||
twilio_account_sid"
|
||||
);
|
||||
return None;
|
||||
}
|
||||
if config.twilio_auth_token.as_ref().is_none_or(|s| s.is_empty()) {
|
||||
if config
|
||||
.twilio_auth_token
|
||||
.as_ref()
|
||||
.is_none_or(|s| s.is_empty())
|
||||
{
|
||||
eprintln!(
|
||||
"[bot] bot.toml: whatsapp_provider=\"twilio\" requires \
|
||||
twilio_auth_token"
|
||||
);
|
||||
return None;
|
||||
}
|
||||
if config.twilio_whatsapp_number.as_ref().is_none_or(|s| s.is_empty()) {
|
||||
if config
|
||||
.twilio_whatsapp_number
|
||||
.as_ref()
|
||||
.is_none_or(|s| s.is_empty())
|
||||
{
|
||||
eprintln!(
|
||||
"[bot] bot.toml: whatsapp_provider=\"twilio\" requires \
|
||||
twilio_whatsapp_number"
|
||||
@@ -212,21 +220,33 @@ impl BotConfig {
|
||||
}
|
||||
} else {
|
||||
// Validate Meta (default) WhatsApp fields.
|
||||
if config.whatsapp_phone_number_id.as_ref().is_none_or(|s| s.is_empty()) {
|
||||
if config
|
||||
.whatsapp_phone_number_id
|
||||
.as_ref()
|
||||
.is_none_or(|s| s.is_empty())
|
||||
{
|
||||
eprintln!(
|
||||
"[bot] bot.toml: transport=\"whatsapp\" requires \
|
||||
whatsapp_phone_number_id"
|
||||
);
|
||||
return None;
|
||||
}
|
||||
if config.whatsapp_access_token.as_ref().is_none_or(|s| s.is_empty()) {
|
||||
if config
|
||||
.whatsapp_access_token
|
||||
.as_ref()
|
||||
.is_none_or(|s| s.is_empty())
|
||||
{
|
||||
eprintln!(
|
||||
"[bot] bot.toml: transport=\"whatsapp\" requires \
|
||||
whatsapp_access_token"
|
||||
);
|
||||
return None;
|
||||
}
|
||||
if config.whatsapp_verify_token.as_ref().is_none_or(|s| s.is_empty()) {
|
||||
if config
|
||||
.whatsapp_verify_token
|
||||
.as_ref()
|
||||
.is_none_or(|s| s.is_empty())
|
||||
{
|
||||
eprintln!(
|
||||
"[bot] bot.toml: transport=\"whatsapp\" requires \
|
||||
whatsapp_verify_token"
|
||||
@@ -243,7 +263,11 @@ impl BotConfig {
|
||||
);
|
||||
return None;
|
||||
}
|
||||
if config.slack_signing_secret.as_ref().is_none_or(|s| s.is_empty()) {
|
||||
if config
|
||||
.slack_signing_secret
|
||||
.as_ref()
|
||||
.is_none_or(|s| s.is_empty())
|
||||
{
|
||||
eprintln!(
|
||||
"[bot] bot.toml: transport=\"slack\" requires \
|
||||
slack_signing_secret"
|
||||
@@ -259,7 +283,11 @@ impl BotConfig {
|
||||
}
|
||||
} else if config.transport == "discord" {
|
||||
// Validate Discord-specific fields.
|
||||
if config.discord_bot_token.as_ref().is_none_or(|s| s.is_empty()) {
|
||||
if config
|
||||
.discord_bot_token
|
||||
.as_ref()
|
||||
.is_none_or(|s| s.is_empty())
|
||||
{
|
||||
eprintln!(
|
||||
"[bot] bot.toml: transport=\"discord\" requires \
|
||||
discord_bot_token"
|
||||
@@ -276,21 +304,15 @@ impl BotConfig {
|
||||
} else {
|
||||
// Default transport is Matrix — validate Matrix-specific fields.
|
||||
if config.homeserver.as_ref().is_none_or(|s| s.is_empty()) {
|
||||
eprintln!(
|
||||
"[bot] bot.toml: transport=\"matrix\" requires homeserver"
|
||||
);
|
||||
eprintln!("[bot] bot.toml: transport=\"matrix\" requires homeserver");
|
||||
return None;
|
||||
}
|
||||
if config.username.as_ref().is_none_or(|s| s.is_empty()) {
|
||||
eprintln!(
|
||||
"[bot] bot.toml: transport=\"matrix\" requires username"
|
||||
);
|
||||
eprintln!("[bot] bot.toml: transport=\"matrix\" requires username");
|
||||
return None;
|
||||
}
|
||||
if config.password.as_ref().is_none_or(|s| s.is_empty()) {
|
||||
eprintln!(
|
||||
"[bot] bot.toml: transport=\"matrix\" requires password"
|
||||
);
|
||||
eprintln!("[bot] bot.toml: transport=\"matrix\" requires password");
|
||||
return None;
|
||||
}
|
||||
if config.room_ids.is_empty() {
|
||||
@@ -402,7 +424,10 @@ enabled = true
|
||||
let result = BotConfig::load(tmp.path());
|
||||
assert!(result.is_some());
|
||||
let config = result.unwrap();
|
||||
assert_eq!(config.homeserver.as_deref(), Some("https://matrix.example.com"));
|
||||
assert_eq!(
|
||||
config.homeserver.as_deref(),
|
||||
Some("https://matrix.example.com")
|
||||
);
|
||||
assert_eq!(config.username.as_deref(), Some("@bot:example.com"));
|
||||
assert_eq!(
|
||||
config.effective_room_ids(),
|
||||
@@ -761,18 +786,9 @@ whatsapp_verify_token = "my-verify"
|
||||
.unwrap();
|
||||
let config = BotConfig::load(tmp.path()).unwrap();
|
||||
assert_eq!(config.transport, "whatsapp");
|
||||
assert_eq!(
|
||||
config.whatsapp_phone_number_id.as_deref(),
|
||||
Some("123456")
|
||||
);
|
||||
assert_eq!(
|
||||
config.whatsapp_access_token.as_deref(),
|
||||
Some("EAAtoken")
|
||||
);
|
||||
assert_eq!(
|
||||
config.whatsapp_verify_token.as_deref(),
|
||||
Some("my-verify")
|
||||
);
|
||||
assert_eq!(config.whatsapp_phone_number_id.as_deref(), Some("123456"));
|
||||
assert_eq!(config.whatsapp_access_token.as_deref(), Some("EAAtoken"));
|
||||
assert_eq!(config.whatsapp_verify_token.as_deref(), Some("my-verify"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1106,14 +1122,8 @@ discord_channel_ids = ["123456789012345678"]
|
||||
.unwrap();
|
||||
let config = BotConfig::load(tmp.path()).unwrap();
|
||||
assert_eq!(config.transport, "discord");
|
||||
assert_eq!(
|
||||
config.discord_bot_token.as_deref(),
|
||||
Some("Bot.Token.Here")
|
||||
);
|
||||
assert_eq!(
|
||||
config.discord_channel_ids,
|
||||
vec!["123456789012345678"]
|
||||
);
|
||||
assert_eq!(config.discord_bot_token.as_deref(), Some("Bot.Token.Here"));
|
||||
assert_eq!(config.discord_channel_ids, vec!["123456789012345678"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1176,9 +1186,6 @@ discord_allowed_users = ["111222333", "444555666"]
|
||||
"#,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
config.discord_allowed_users,
|
||||
vec!["111222333", "444555666"]
|
||||
);
|
||||
assert_eq!(config.discord_allowed_users, vec!["111222333", "444555666"]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user