fix: enforce OMO ↔ OMO Slim cross-category mutual exclusion

When activating an OMO provider, deactivate all OMO Slim providers
in the same transaction and delete the Slim config file, and vice
versa. This prevents both plugin variants from being active
simultaneously.
This commit is contained in:
Jason
2026-02-26 18:08:46 +08:00
parent 55e21c3c19
commit 082cb0327d
2 changed files with 19 additions and 0 deletions
+13
View File
@@ -375,6 +375,19 @@ impl Database {
params![app_type, category],
)
.map_err(|e| AppError::Database(e.to_string()))?;
// OMO ↔ OMO Slim mutually exclusive: deactivate the opposite category
let opposite = match category {
"omo" => Some("omo-slim"),
"omo-slim" => Some("omo"),
_ => None,
};
if let Some(opp) = opposite {
tx.execute(
"UPDATE providers SET is_current = 0 WHERE app_type = ?1 AND category = ?2",
params![app_type, opp],
)
.map_err(|e| AppError::Database(e.to_string()))?;
}
let updated = tx
.execute(
"UPDATE providers SET is_current = 1 WHERE id = ?1 AND app_type = ?2 AND category = ?3",
+6
View File
@@ -513,6 +513,8 @@ impl ProviderService {
state,
&crate::services::omo::STANDARD,
)?;
// OMO ↔ OMO Slim mutually exclusive: remove Slim config
let _ = crate::services::OmoService::delete_config_file(&crate::services::omo::SLIM);
return Ok(SwitchResult::default());
}
@@ -522,6 +524,10 @@ impl ProviderService {
.db
.set_omo_provider_current(app_type.as_str(), id, "omo-slim")?;
crate::services::OmoService::write_config_to_file(state, &crate::services::omo::SLIM)?;
// OMO ↔ OMO Slim mutually exclusive: remove Standard config
let _ = crate::services::OmoService::delete_config_file(
&crate::services::omo::STANDARD,
);
return Ok(SwitchResult::default());
}