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 @@
11 use bitcode::{Decode, Encode};
22
33 use crate::request::{
4- community::{CreateCommunity, DeleteCommunity, ReadCommunity, UpdateCommunity},
4+ community::{
5+ CreateCommunity, DeleteCommunity, ReadCommunity, SearchCommunity, UpdateCommunity,
6+ },
57 message::{
68 CreateMessage, DeleteMessage, ReadMessage, ReadMessageByCommunityIDWithMarkerAndLimit,
79 UpdateMessage,
@@ -63,4 +65,5 @@ pub enum Request {
6365 IsUserIn(IsUserIn),
6466 UsersIn(UsersIn),
6567 CommunityOf(CommunityOf),
68+ SearchCommunity(SearchCommunity),
6669 }
crates/common/src/request/community.rsmodified+18 -0
@@ -80,3 +80,21 @@ impl DeleteCommunity {
8080 &self.community_id
8181 }
8282 }
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 {
2828 IsUserIn(bool),
2929 UsersIn(Vec<String>),
3030 CommunityOf(Vec<String>),
31+ SearchCommunity(Vec<Community>),
3132 Error(Error),
3233 }