mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Fix auto-selecting chat channel, add some more config options
This commit is contained in:
@@ -113,7 +113,7 @@ pub fn handler(init_ctx: &crate::InitConfig) -> OperationsHandler<crate::UserTy>
|
||||
.add(polariton_server::operations::Ack::<132, _>::default()) // verify user level
|
||||
.add(load_analytics::NoAnalytics)
|
||||
.add(polariton_server::operations::Ack::<131, _>::default()) // analytics updated notification
|
||||
.add(platform_config::platform_config_provider())
|
||||
.add(platform_config::platform_config_provider(&init_ctx.cubes))
|
||||
.add(tier_banding::tiers_banding_provider())
|
||||
.add(cube_list::cube_list_provider(&init_ctx.cubes))
|
||||
.add(special_items::special_item_list_provider())
|
||||
|
||||
@@ -1,29 +1,54 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton_server::operations::{SimpleOpError, SimpleOperation, SimpleOpImpl};
|
||||
use polariton::{operation::{Dict, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
const CODE: u8 = 165;
|
||||
|
||||
const PLATFORM_CONFIG_KEY: u8 = 197;
|
||||
|
||||
pub(super) fn platform_config_provider() -> SimpleFunc<165, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||
SimpleFunc::new(|params, _| {
|
||||
pub(super) fn platform_config_provider<C: Send + 'static>(conf: &oj_rc_core::ConfigImpl) -> SimpleOpImpl<C, crate::UserTy, PlatformConfigProvider> {
|
||||
SimpleOpImpl::new(PlatformConfigProvider {
|
||||
chat_config: <oj_rc_core::ConfigImpl as oj_rc_core::ConfigProvider<()>>::chat_system_config(conf),
|
||||
links: <oj_rc_core::ConfigImpl as oj_rc_core::ConfigProvider<()>>::url_links(conf),
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) struct PlatformConfigProvider {
|
||||
chat_config: oj_rc_core::persist::config::ChatSystemConfig,
|
||||
links: oj_rc_core::persist::config::LinksConfig,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl <C: Send + 'static> SimpleOperation<C> for PlatformConfigProvider {
|
||||
type User = crate::UserTy;
|
||||
const CODE: u8 = CODE;
|
||||
|
||||
async fn handle(&self, params: ParameterTable<C>, user: &Self::User) -> Result<ParameterTable<C>, SimpleOpError> {
|
||||
let user = user.user()?;
|
||||
let mut connected_channels = user.subscribed_channels_strings().await?;
|
||||
let client_selected_channel = if connected_channels.is_empty() || connected_channels.contains(&self.chat_config.default_channel) {
|
||||
self.chat_config.default_channel.clone()
|
||||
} else {
|
||||
connected_channels.remove(0)
|
||||
};
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PLATFORM_CONFIG_KEY, Typed::Dict(Dict {
|
||||
key_ty: TypePrefix::Any, // obj
|
||||
val_ty: TypePrefix::Any, // obj
|
||||
items: vec![
|
||||
(Typed::Str("BuyPremiumAvailable".into()), Typed::Bool(false.into())),
|
||||
(Typed::Str("MainShopButtonAvailable".into()), Typed::Bool(false.into())),
|
||||
(Typed::Str("RoboPassButtonAvailable".into()), Typed::Bool(false.into())),
|
||||
(Typed::Str("LanguageSelectionAvailable".into()), Typed::Bool(false.into())),
|
||||
(Typed::Str("AutoJoinPublicChatRoom".into()), Typed::Bool(true.into())), // TODO maybe?
|
||||
(Typed::Str("CanCreateChatRooms".into()), Typed::Bool(true.into())), // TODO
|
||||
(Typed::Str("CurseVoiceEnabled".into()), Typed::Bool(false.into())),
|
||||
(Typed::Str("DeltaDNAEnabled".into()), Typed::Bool(false.into())),
|
||||
(Typed::Str("UseDecimalSystem".into()), Typed::Bool(true.into())),
|
||||
(Typed::Str("FeedbackURL".into()), Typed::Str("https://mstdn.ca/@ngram".into())),
|
||||
(Typed::Str("SupportURL".into()), Typed::Str("https://git.ngni.us/OpenJam/servers".into())),
|
||||
(Typed::Str("WikiURL".into()), Typed::Str("https://git.ngram.ca/OpenJam/servers/wiki".into())),
|
||||
(Typed::Str("BuyPremiumAvailable".into()), Typed::Bool(false)),
|
||||
(Typed::Str("MainShopButtonAvailable".into()), Typed::Bool(false)),
|
||||
(Typed::Str("RoboPassButtonAvailable".into()), Typed::Bool(false)),
|
||||
(Typed::Str("LanguageSelectionAvailable".into()), Typed::Bool(false)),
|
||||
(Typed::Str("AutoJoinPublicChatRoom".into()), Typed::Str(client_selected_channel.into())),
|
||||
(Typed::Str("CanCreateChatRooms".into()), Typed::Bool(self.chat_config.can_create_channels)),
|
||||
(Typed::Str("CurseVoiceEnabled".into()), Typed::Bool(false)),
|
||||
(Typed::Str("DeltaDNAEnabled".into()), Typed::Bool(false)),
|
||||
(Typed::Str("UseDecimalSystem".into()), Typed::Bool(true)),
|
||||
(Typed::Str("FeedbackURL".into()), Typed::Str(self.links.feedback_url.clone().into())),
|
||||
(Typed::Str("SupportURL".into()), Typed::Str(self.links.support_url.clone().into())),
|
||||
(Typed::Str("WikiURL".into()), Typed::Str(self.links.wiki_url.clone().into())),
|
||||
].into(),
|
||||
}));
|
||||
Ok(params.into())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user