Files
arcadia/backend/api/src/handlers/conversations/create_conversation_message.rs
FrenchGithubUser af124c9a77 renamed jwt_middleware to auth_middleware, await shared Tracker
struct creation, fix passkeys length
2025-10-14 17:40:12 +02:00

36 lines
966 B
Rust

use crate::{middlewares::auth_middleware::Authdata, Arcadia};
use actix_web::{
web::{Data, Json},
HttpResponse,
};
use arcadia_common::error::Result;
use arcadia_storage::{
models::conversation::{ConversationMessage, UserCreatedConversationMessage},
redis::RedisPoolInterface,
};
#[utoipa::path(
post,
operation_id = "Create conversation message",
tag = "Conversation",
path = "/api/conversations/messages",
security(
("http" = ["Bearer"])
),
responses(
(status = 200, description = "Successfully created the conversation's message", body=ConversationMessage),
)
)]
pub async fn exec<R: RedisPoolInterface + 'static>(
message: Json<UserCreatedConversationMessage>,
arc: Data<Arcadia<R>>,
user: Authdata,
) -> Result<HttpResponse> {
let message = arc
.pool
.create_conversation_message(&message, user.sub)
.await?;
Ok(HttpResponse::Created().json(message))
}