From e86062ef8b1c2d2482e311547fb823b0cc524f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Mon, 3 Aug 2026 06:22:06 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(common):=20add=20community=20s?= =?UTF-8?q?earch=20request?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/common/src/request.rs | 5 ++++- crates/common/src/request/community.rs | 18 ++++++++++++++++++ crates/common/src/response.rs | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/crates/common/src/request.rs b/crates/common/src/request.rs index 0860d46..884c8a7 100644 --- a/crates/common/src/request.rs +++ b/crates/common/src/request.rs @@ -1,7 +1,9 @@ use bitcode::{Decode, Encode}; use crate::request::{ - community::{CreateCommunity, DeleteCommunity, ReadCommunity, UpdateCommunity}, + community::{ + CreateCommunity, DeleteCommunity, ReadCommunity, SearchCommunity, UpdateCommunity, + }, message::{ CreateMessage, DeleteMessage, ReadMessage, ReadMessageByCommunityIDWithMarkerAndLimit, UpdateMessage, @@ -63,4 +65,5 @@ pub enum Request { IsUserIn(IsUserIn), UsersIn(UsersIn), CommunityOf(CommunityOf), + SearchCommunity(SearchCommunity), } diff --git a/crates/common/src/request/community.rs b/crates/common/src/request/community.rs index f3a47f2..b6dda00 100644 --- a/crates/common/src/request/community.rs +++ b/crates/common/src/request/community.rs @@ -80,3 +80,21 @@ impl DeleteCommunity { &self.community_id } } + +#[derive(Debug, Clone, Encode, Decode)] +pub struct SearchCommunity { + community_name: String, +} + +impl SearchCommunity { + pub fn new(community_name: &str) -> Result { + let community_name = community_name.to_string(); + validate_community_name(&community_name)?; + + Ok(Self { community_name }) + } + + pub fn get_community_name(&self) -> &str { + &self.community_name + } +} diff --git a/crates/common/src/response.rs b/crates/common/src/response.rs index 97c69f2..6f15cdf 100644 --- a/crates/common/src/response.rs +++ b/crates/common/src/response.rs @@ -28,5 +28,6 @@ pub enum Response { IsUserIn(bool), UsersIn(Vec), CommunityOf(Vec), + SearchCommunity(Vec), Error(Error), }