mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Friends functionality (#90)
### Description Implements and closes #86 ### Game Robocraft ### Please confirm - [x] I am the legal owner or represent the owner of all work submitted - [x] I consent to my submission being added to this FOSS project - [ ] This PR used LLMs to generate some or all of the code changes Reviewed-on: https://git.ngram.ca/OpenJam/rc-servers/pulls/90 Co-authored-by: NG (Graham) <ngniusness@gmail.com> Co-committed-by: NG (Graham) <ngniusness@gmail.com>
This commit is contained in:
1 parent
872f224af6
commit
9502522ac4
30 files changed
+1108
-35
No files matched your search
@@ -0,0 +1,34 @@
|
||||
use polariton_server::operations::{SimpleOpError, SimpleOperation, SimpleOpImpl};
|
||||
use polariton::operation::{ParameterTable, Typed};
|
||||
|
||||
const CODE: u8 = 3;
|
||||
|
||||
const USERNAME_PARAM_KEY: u8 = 1; // str; in & out
|
||||
|
||||
pub(super) struct FriendRequestRemover {
|
||||
social: std::sync::Arc<crate::SocialMesh>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl SimpleOperation<crate::data::custom::CustomType> for FriendRequestRemover {
|
||||
type User = crate::UserTy;
|
||||
const CODE: u8 = CODE;
|
||||
|
||||
async fn handle(&self, mut params: ParameterTable<crate::data::custom::CustomType>, user: &Self::User) -> Result<ParameterTable<crate::data::custom::CustomType>, SimpleOpError> {
|
||||
if let Some(Typed::Str(username)) = params.remove(&USERNAME_PARAM_KEY) {
|
||||
let user_info = user.user()?;
|
||||
user_info.remove_friend(username.string.clone()).await?;
|
||||
self.social.send_event_to(&username.string, crate::events::friend_removed::FriendRemoved {
|
||||
friend_public_id: user_info.public_id().to_owned(),
|
||||
friend_display_name: user_info.display_name().to_owned(),
|
||||
}).await;
|
||||
}
|
||||
Ok(params)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn friend_remove_provider(init_ctx: &crate::InitConfig) -> SimpleOpImpl<crate::data::custom::CustomType, crate::UserTy, FriendRequestRemover> {
|
||||
SimpleOpImpl::new(FriendRequestRemover {
|
||||
social: init_ctx.social.clone(),
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user