mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Fix dependency build error, rename operation modifier
This commit is contained in:
@@ -24,5 +24,5 @@ libfj.workspace = true
|
||||
jsonwebtoken = "9"
|
||||
argon2 = { version = "0.5", features = [ "std" ] }
|
||||
|
||||
oj_rc_database = { version = "0.2", path = "../rc_database" }
|
||||
oj_rc_factory = { version = "0.2", path = "../rc_factory" }
|
||||
oj_rc_database = { version = "*", path = "../rc_database" }
|
||||
oj_rc_factory = { version = "*", path = "../rc_factory" }
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
mod svelto_uuid_copy;
|
||||
pub use svelto_uuid_copy::OpIdCopy;
|
||||
mod op_mod;
|
||||
pub use op_mod::RcOpModifier;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
use polariton_server::operations::OperationModifier;
|
||||
|
||||
pub struct OpIdCopy;
|
||||
pub struct RcOpModifier;
|
||||
|
||||
impl OpIdCopy {
|
||||
impl RcOpModifier {
|
||||
const SERVICE_MAPPING_KEY: u8 = 0;
|
||||
}
|
||||
|
||||
impl <C: Clone + Send + Sync + 'static> OperationModifier<C> for OpIdCopy {
|
||||
impl <C: Clone + Send + Sync + 'static> OperationModifier<C> for RcOpModifier {
|
||||
fn after(&self, req: &mut polariton::operation::OperationRequest<C>, resp: &mut polariton::operation::OperationResponse<C>, flags: &mut u8) {
|
||||
if resp.params.get(&Self::SERVICE_MAPPING_KEY).is_none() {
|
||||
if let Some(svelto_service_id) = req.params.get(&Self::SERVICE_MAPPING_KEY) {
|
||||
@@ -1,12 +1,13 @@
|
||||
use crate::persist::user::UserProvider;
|
||||
use polariton_server::ToSend;
|
||||
|
||||
pub struct UserState<C: Clone = ()> {
|
||||
pub struct UserState<C: Clone + Send + 'static = ()> {
|
||||
state: std::sync::RwLock<InitState<C>>,
|
||||
event_tx: tokio::sync::mpsc::UnboundedSender<ToSend<C>>,
|
||||
event_emitter: polariton_server::events::EventEmitter<C>,
|
||||
}
|
||||
|
||||
impl <C: Clone> UserState<C> {
|
||||
impl <C: Clone + Send + 'static> UserState<C> {
|
||||
pub async fn update_with_auth(&self, auth_str: &str) -> bool {
|
||||
self.update_with_auth_ext(auth_str, |_| Some(Default::default())).await
|
||||
}
|
||||
@@ -53,9 +54,11 @@ impl <C: Clone> UserState<C> {
|
||||
}
|
||||
|
||||
pub fn new(provider: std::sync::Arc<crate::persist::user::UserImpl>, event_tx: tokio::sync::mpsc::UnboundedSender<ToSend<C>>) -> Self {
|
||||
let emitter = polariton_server::events::EventEmitter::new(event_tx.clone());
|
||||
Self {
|
||||
state: std::sync::RwLock::new(InitState::Unauthenticated(provider)),
|
||||
event_tx,
|
||||
event_emitter: emitter,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,12 +70,16 @@ impl <C: Clone> UserState<C> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn event(&self, event_data: ToSend<C>) {
|
||||
/*pub fn event(&self, event_data: ToSend<C>) {
|
||||
self.event_tx.send(event_data).unwrap()
|
||||
}*/
|
||||
|
||||
pub fn event_chann(&self) -> tokio::sync::mpsc::UnboundedSender<ToSend<C>> {
|
||||
self.event_tx.clone()
|
||||
}
|
||||
|
||||
pub fn event_sender(&self) -> tokio::sync::mpsc::UnboundedSender<ToSend<C>> {
|
||||
self.event_tx.clone()
|
||||
pub fn event_sender(&self) -> &'_ polariton_server::events::EventEmitter<C> {
|
||||
&self.event_emitter
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user