huskies: merge 726_story_notify_chat_transports_when_oauth_account_swaps_or_all_accounts_are_exhausted

This commit is contained in:
dave
2026-04-27 18:39:35 +00:00
parent 80661fa622
commit 4b64bc614f
8 changed files with 187 additions and 4 deletions
@@ -17,6 +17,10 @@ pub enum EventAction {
RateLimitWarning,
/// Post a story-blocked notification.
StoryBlocked,
/// Post an OAuth account-swap notification naming the new account.
OAuthAccountSwapped,
/// Post an OAuth accounts-exhausted notification with the earliest reset time.
OAuthAccountsExhausted,
/// Log server-side only; do not post to chat (e.g. hard rate-limit blocks).
LogOnly,
/// Reload the project configuration.
@@ -42,6 +46,8 @@ pub fn classify(event: &WatcherEvent) -> EventAction {
WatcherEvent::StoryBlocked { .. } => EventAction::StoryBlocked,
WatcherEvent::RateLimitHardBlock { .. } => EventAction::LogOnly,
WatcherEvent::ConfigChanged => EventAction::ReloadConfig,
WatcherEvent::OAuthAccountSwapped { .. } => EventAction::OAuthAccountSwapped,
WatcherEvent::OAuthAccountsExhausted { .. } => EventAction::OAuthAccountsExhausted,
_ => EventAction::Skip,
}
}
@@ -116,4 +122,20 @@ mod tests {
EventAction::ReloadConfig
);
}
#[test]
fn oauth_account_swapped_is_classified_correctly() {
let event = WatcherEvent::OAuthAccountSwapped {
new_email: "new@example.com".to_string(),
};
assert_eq!(classify(&event), EventAction::OAuthAccountSwapped);
}
#[test]
fn oauth_accounts_exhausted_is_classified_correctly() {
let event = WatcherEvent::OAuthAccountsExhausted {
earliest_reset_msg: "All accounts rate-limited; earliest reset in 2h".to_string(),
};
assert_eq!(classify(&event), EventAction::OAuthAccountsExhausted);
}
}