mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Add server-wide and user-only federation controls (#133)
### Description Completes #122 ### Please confirm - [x] I am the legal owner or represent the legal owner of all work submitted (including LLM-generated code, if any) - [x] I consent to my changes being added to this FOSS project - [x] I have confirmed that this does not add new errors or warnings with `utils/clippy.sh` - [ ] This PR used LLMs to generate some or all of the code changes Reviewed-on: https://git.ngram.ca/OpenJam/rc-servers/pulls/133
This commit is contained in:
1 parent
e65d0eeb80
commit
995bafa70c
22 files changed
+522
-15
No files matched your search
@@ -8,7 +8,7 @@ use polariton::serdes::TypePrefix;
|
||||
|
||||
use crate::persist::config::SelfValidator;
|
||||
|
||||
use super::super::{MovementCategoryData, MovementData, Cube, ItemCategory, ItemTier, BattleConfig, Settings, ChatConfig, FactoryConfig, ItemShopConfig};
|
||||
use super::super::{MovementCategoryData, MovementData, Cube, ItemCategory, ItemTier, BattleConfig, Settings, ChatConfig, FactoryConfig, ItemShopConfig, FederationConfig};
|
||||
|
||||
const CUBE_CONFIG_FILENAME: &str = "config.json";
|
||||
|
||||
@@ -22,6 +22,8 @@ pub struct CubeConfig {
|
||||
factory: FactoryConfig,
|
||||
shop: ItemShopConfig,
|
||||
settings: Settings,
|
||||
#[serde(default = "super::super::default_federation")]
|
||||
federation: FederationConfig,
|
||||
}
|
||||
|
||||
impl CubeConfig {
|
||||
@@ -623,7 +625,15 @@ impl <C: Clone + Send> super::ConfigProvider<C> for CubeConfig {
|
||||
factory: self.factory.redacted_clone(),
|
||||
shop: self.shop.clone(),
|
||||
settings: self.settings.redacted_clone(),
|
||||
federation: self.federation.clone(),
|
||||
};
|
||||
serde_json::to_string(&redacted_self).expect("Failed to re-serialize config.json")
|
||||
}
|
||||
|
||||
fn federation(&self) -> Option<super::Federation> {
|
||||
self.federation.enabled.then(|| super::Federation {
|
||||
aliases: self.federation.aliases.clone(),
|
||||
defederated: self.federation.defederated.clone(),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ mod cubes_json;
|
||||
pub use cubes_json::CubeConfig;
|
||||
|
||||
mod traits;
|
||||
pub use traits::{ConfigProvider, DevMessageProvider, ServerConfig, GarageUpgrades, GarageUpgradeIncrement, ChatSystemConfig, GameEventSequence, GameEvents, GameRotationStrategy, GameEvent, GameMap, GameVisibility, GameType, SingleplayerConfig, VehicleInfo, VehicleDescriptor, QueueChangeMode, Point, Sphere, MapConfig, LinksConfig, FakePlayer, ClientEmulator, EnergyConfig, BattleArenaResolver, PitSettings, PitWinCondition, TeamDeathMatchSettings, ShopEntriesResolver, ShopAction, ShopGain, PromoCode, MultiplayerSettings, BattleArenaCrystalParams, VehicleValidators, TeamChoosers, FactoryConfig, PlatformConfig};
|
||||
pub use traits::{ConfigProvider, DevMessageProvider, ServerConfig, GarageUpgrades, GarageUpgradeIncrement, ChatSystemConfig, GameEventSequence, GameEvents, GameRotationStrategy, GameEvent, GameMap, GameVisibility, GameType, SingleplayerConfig, VehicleInfo, VehicleDescriptor, QueueChangeMode, Point, Sphere, MapConfig, LinksConfig, FakePlayer, ClientEmulator, EnergyConfig, BattleArenaResolver, PitSettings, PitWinCondition, TeamDeathMatchSettings, ShopEntriesResolver, ShopAction, ShopGain, PromoCode, MultiplayerSettings, BattleArenaCrystalParams, VehicleValidators, TeamChoosers, FactoryConfig, PlatformConfig, Federation};
|
||||
pub(super) use traits::RedactedClone;
|
||||
|
||||
mod validation;
|
||||
|
||||
@@ -46,6 +46,8 @@ pub trait ConfigProvider<C: Clone> {
|
||||
fn garage_slot_limit(&self) -> i32;
|
||||
fn team_choosers(&self) -> TeamChoosers;
|
||||
fn redacted_json(&self) -> String;
|
||||
/// None when federation is not enabled
|
||||
fn federation(&self) -> Option<Federation>;
|
||||
}
|
||||
|
||||
pub struct DevMessageProvider<C: Clone> {
|
||||
@@ -579,3 +581,8 @@ pub struct PlatformConfig {
|
||||
pub trait RedactedClone {
|
||||
fn redacted_clone(&self) -> Self;
|
||||
}
|
||||
|
||||
pub struct Federation {
|
||||
pub aliases: std::collections::HashMap<String, String>,
|
||||
pub defederated: Vec<String>,
|
||||
}
|
||||
Reference in new issue
Block a user