2026-04-02 15:15:00 +07:00
|
|
|
use super::entity::*;
|
2026-04-02 22:29:08 +07:00
|
|
|
use async_trait::async_trait;
|
|
|
|
|
use imphnen_utils::errors::AppError;
|
|
|
|
|
use uuid::Uuid;
|
2026-04-02 15:15:00 +07:00
|
|
|
|
|
|
|
|
#[async_trait]
|
|
|
|
|
pub trait ChatRepository: Send + Sync {
|
2026-04-02 22:29:08 +07:00
|
|
|
async fn find_team_messages(
|
|
|
|
|
&self,
|
|
|
|
|
team_id: Uuid,
|
|
|
|
|
) -> Result<Vec<MessageWithUser>, AppError>;
|
2026-04-02 15:15:00 +07:00
|
|
|
|
2026-04-02 22:29:08 +07:00
|
|
|
async fn create_message(
|
|
|
|
|
&self,
|
|
|
|
|
id: Uuid,
|
|
|
|
|
team_id: Uuid,
|
|
|
|
|
user_id: Uuid,
|
|
|
|
|
message: &str,
|
|
|
|
|
) -> Result<MessageEntity, AppError>;
|
2026-04-02 15:15:00 +07:00
|
|
|
|
2026-04-02 22:29:08 +07:00
|
|
|
async fn find_message_by_id(
|
|
|
|
|
&self,
|
|
|
|
|
id: Uuid,
|
|
|
|
|
) -> Result<Option<MessageEntity>, AppError>;
|
2026-04-02 15:15:00 +07:00
|
|
|
|
2026-04-02 22:29:08 +07:00
|
|
|
async fn delete_message(&self, id: Uuid) -> Result<bool, AppError>;
|
2026-04-02 15:15:00 +07:00
|
|
|
|
2026-04-02 22:29:08 +07:00
|
|
|
async fn get_user_info(
|
|
|
|
|
&self,
|
|
|
|
|
user_id: Uuid,
|
|
|
|
|
) -> Result<Option<(String, Option<String>)>, AppError>;
|
2026-04-02 15:15:00 +07:00
|
|
|
|
2026-04-02 22:29:08 +07:00
|
|
|
async fn is_team_member(
|
|
|
|
|
&self,
|
|
|
|
|
team_id: Uuid,
|
|
|
|
|
user_id: Uuid,
|
|
|
|
|
) -> Result<bool, AppError>;
|
2026-04-02 15:15:00 +07:00
|
|
|
|
2026-04-02 22:29:08 +07:00
|
|
|
async fn is_team_leader(
|
|
|
|
|
&self,
|
|
|
|
|
team_id: Uuid,
|
|
|
|
|
user_id: Uuid,
|
|
|
|
|
) -> Result<bool, AppError>;
|
2026-04-02 15:15:00 +07:00
|
|
|
}
|