mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Move chat system into core, merge configs, save to database
This commit is contained in:
1 parent
b83a23c115
commit
4f0bcde7d8
29 files changed
+362
-331
No files matched your search
@@ -0,0 +1,35 @@
|
||||
//use rc_core::persist::user::ChatUser;
|
||||
use polariton::operation::{ParameterTable, OperationResponse};
|
||||
|
||||
const CODE: u8 = 12;
|
||||
|
||||
const PARAM_KEY: u8 = 18;
|
||||
|
||||
async fn do_handling(params: ParameterTable<()>, user: &crate::UserTy) -> Result<ParameterTable, i16> {
|
||||
let mut params = params.to_dict();
|
||||
let user_info = user.user()?;
|
||||
params.insert(PARAM_KEY, user_info.subscribed_channels().await?);
|
||||
Ok(params.into())
|
||||
}
|
||||
|
||||
pub struct SubscribedChannelsProvider;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl polariton_server::operations::Operation<()> for SubscribedChannelsProvider {
|
||||
type User = crate::UserTy;
|
||||
|
||||
async fn handle_async(&self, params: ParameterTable<()>, user: &Self::User) -> OperationResponse<()> {
|
||||
polariton_server::operations::result_to_op_resp::<CODE, ()>(do_handling(params, user).await)
|
||||
}
|
||||
}
|
||||
|
||||
impl polariton_server::operations::OperationCode for SubscribedChannelsProvider {
|
||||
fn op_code() -> u8 {
|
||||
CODE
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub(super) fn all_subbed_channels_provider() -> SubscribedChannelsProvider {
|
||||
SubscribedChannelsProvider
|
||||
}
|
||||
Reference in new issue
Block a user