Consolidates the standalone hackathon backend (16 crates) into a single imphnen-hackathon crate following the existing clean architecture patterns. All endpoints are exposed under /v1/hackathon/ via the gateway. Features migrated: - Auth: Supabase-based signup/login/GitHub OAuth/password reset (own JWT) - Users: profile management with team listing - Teams: CRUD with city validation, deadline enforcement, invite system - Invitations: team member invitations with accept/reject flow - Join Requests: team join request workflow - Chat: team messaging with author/leader delete permissions - Submissions: project submission lifecycle (draft→pending→submitted) - Storage: Supabase Storage file upload endpoints - Certificates: public user certificate data endpoint - Winners: public winners listing - Admin: admin-only CRUD for all entities Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
37 lines
1.5 KiB
Rust
37 lines
1.5 KiB
Rust
use axum::{Extension, Json, extract::Path, response::IntoResponse};
|
|
use std::sync::Arc;
|
|
use uuid::Uuid;
|
|
use imphnen_utils::{errors::AppError, response_format::{ApiSuccess, ApiMessage}};
|
|
use crate::middleware::hackathon_auth::HackathonAuthUser;
|
|
use crate::chat::domain::service::ChatService;
|
|
use super::dto::*;
|
|
|
|
pub async fn get_team_messages_handler(
|
|
Extension(service): Extension<Arc<dyn ChatService>>,
|
|
Extension(auth): Extension<HackathonAuthUser>,
|
|
Path(team_id): Path<Uuid>,
|
|
) -> Result<axum::response::Response, AppError> {
|
|
let messages = service.get_team_messages(team_id, auth.user_id).await?;
|
|
let response: Vec<MessageResponse> = messages.into_iter().map(MessageResponse::from).collect();
|
|
Ok(ApiSuccess(response).into_response())
|
|
}
|
|
|
|
pub async fn send_message_handler(
|
|
Extension(service): Extension<Arc<dyn ChatService>>,
|
|
Extension(auth): Extension<HackathonAuthUser>,
|
|
Path(team_id): Path<Uuid>,
|
|
Json(body): Json<SendMessageRequest>,
|
|
) -> Result<axum::response::Response, AppError> {
|
|
let message = service.send_message(team_id, auth.user_id, body.into()).await?;
|
|
Ok(ApiSuccess(MessageResponse::from(message)).into_response())
|
|
}
|
|
|
|
pub async fn delete_message_handler(
|
|
Extension(service): Extension<Arc<dyn ChatService>>,
|
|
Extension(auth): Extension<HackathonAuthUser>,
|
|
Path(message_id): Path<Uuid>,
|
|
) -> Result<axum::response::Response, AppError> {
|
|
service.delete_message(message_id, auth.user_id).await?;
|
|
Ok(ApiMessage::ok("Message deleted").into_response())
|
|
}
|