1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Create RC database layer

This commit is contained in:
NGnius (Graham)
2025-05-07 20:23:22 -04:00
parent 69c6c54650
commit 77ddeb7891
55 changed files with 2689 additions and 395 deletions

View File

@@ -19,3 +19,4 @@ rc_core = { version = "*", path = "../rc_core" }
serde.workspace = true
serde_json.workspace = true
regex = "1"
async-trait.workspace = true

View File

@@ -24,7 +24,7 @@ async fn main() -> std::io::Result<()> {
log::debug!("Got cli args {:?}", args);
let cubes = rc_core::persist::config::ConfigImpl::load(&args.assets).expect("Bad config data");
let users = std::sync::Arc::new(rc_core::persist::user::UserImpl::load(&args.data, &cubes).expect("Bad user data"));
let users = std::sync::Arc::new(rc_core::persist::user::UserImpl::load(&args.data, &cubes).await.expect("Bad user data"));
let chat_system = state::chat::ChatImpl::new(&args.assets, &args.data).expect("Bad chat config data");

View File

@@ -31,9 +31,9 @@ impl MoreLobbyAuth {
Some(map)
}
fn do_auth<C>(&self, params: std::collections::HashMap<u8, Typed<C>>, user: &crate::UserTy) -> Result<polariton::operation::ParameterTable<C>, i16> {
async fn do_auth<C>(&self, params: std::collections::HashMap<u8, Typed<C>>, user: &crate::UserTy) -> Result<polariton::operation::ParameterTable<C>, i16> {
if let Some(Typed::Str(auth_payload)) = params.get(&Self::AUTH_PAYLOAD_KEY) {
if user.update_with_auth_ext(&auth_payload.string, |t| self.build_ext_map(t)) {
if user.update_with_auth_ext(&auth_payload.string, |t| self.build_ext_map(t)).await {
let user_impl = user.user()?;
let name = user_impl.token().uuid.clone();
let chat_user = super::get_chat_user(user_impl.as_ref().as_ref());
@@ -49,12 +49,13 @@ impl MoreLobbyAuth {
}
}
#[async_trait::async_trait]
impl <C: Send + 'static> Operation<C> for MoreLobbyAuth {
type User = crate::UserTy;
fn handle(&self, params: polariton::operation::ParameterTable<C>, user: &Self::User) -> polariton::operation::OperationResponse<C> {
async fn handle_async(&self, params: polariton::operation::ParameterTable<C>, user: &Self::User) -> polariton::operation::OperationResponse<C> {
let params_dict = params.to_dict();
match self.do_auth(params_dict, user) {
match self.do_auth(params_dict, user).await {
Ok(params) => {
polariton::operation::OperationResponse {
code: Self::op_code(),