forge
Explore
Log in

Don't you dare go Hollow

Add community search request

Browse files at this commit

e86062ef8b1c2d2482e311547fb823b0cc524f0eAhmet Kaan GümüşParent: 4e8ba23
  • feat
    • add community search request
Show full message
✨ feat(common): add community search request
crates/common/src/request.rsmodified+4 -1
@@ -1,7 +1,9 @@
1 use bitcode::{Decode, Encode};1 use bitcode::{Decode, Encode};
2 2
3 use crate::request::{3 use crate::request::{
4- community::{CreateCommunity, DeleteCommunity, ReadCommunity, UpdateCommunity},4+ community::{
5+ CreateCommunity, DeleteCommunity, ReadCommunity, SearchCommunity, UpdateCommunity,
6+ },
5 message::{7 message::{
6 CreateMessage, DeleteMessage, ReadMessage, ReadMessageByCommunityIDWithMarkerAndLimit,8 CreateMessage, DeleteMessage, ReadMessage, ReadMessageByCommunityIDWithMarkerAndLimit,
7 UpdateMessage,9 UpdateMessage,
@@ -63,4 +65,5 @@ pub enum Request {
63 IsUserIn(IsUserIn),65 IsUserIn(IsUserIn),
64 UsersIn(UsersIn),66 UsersIn(UsersIn),
65 CommunityOf(CommunityOf),67 CommunityOf(CommunityOf),
68+ SearchCommunity(SearchCommunity),
66 }69 }
crates/common/src/request/community.rsmodified+18 -0
@@ -80,3 +80,21 @@ impl DeleteCommunity {
80 &self.community_id80 &self.community_id
81 }81 }
82 }82 }
83+
84+#[derive(Debug, Clone, Encode, Decode)]
85+pub struct SearchCommunity {
86+ community_name: String,
87+}
88+
89+impl SearchCommunity {
90+ pub fn new(community_name: &str) -> Result<Self, Error> {
91+ let community_name = community_name.to_string();
92+ validate_community_name(&community_name)?;
93+
94+ Ok(Self { community_name })
95+ }
96+
97+ pub fn get_community_name(&self) -> &str {
98+ &self.community_name
99+ }
100+}
crates/common/src/response.rsmodified+1 -0
@@ -28,5 +28,6 @@ pub enum Response {
28 IsUserIn(bool),28 IsUserIn(bool),
29 UsersIn(Vec<String>),29 UsersIn(Vec<String>),
30 CommunityOf(Vec<String>),30 CommunityOf(Vec<String>),
31+ SearchCommunity(Vec<Community>),
31 Error(Error),32 Error(Error),
32 }33 }