Add IsNeedSendQuery struct for deserialization

This commit is contained in:
2024-03-20 15:03:42 +01:00
parent 94b58c9dea
commit ba4bb77ad8

View File

@@ -6,14 +6,20 @@ use axum::{
Json, Router, Json, Router,
}; };
use chrono::Duration; use chrono::Duration;
use serde::Deserialize;
use crate::prisma::chat_donate_notifications; use crate::prisma::chat_donate_notifications;
use super::Database; use super::Database;
#[derive(Deserialize)]
struct IsNeedSendQuery {
is_private: bool,
}
async fn is_need_send( async fn is_need_send(
Path(chat_id): Path<i64>, Path(chat_id): Path<i64>,
Query(is_private): Query<String>, query: Query<IsNeedSendQuery>,
db: Database, db: Database,
) -> impl IntoResponse { ) -> impl IntoResponse {
const NOTIFICATION_DELTA_DAYS_PRIVATE: i64 = 60; const NOTIFICATION_DELTA_DAYS_PRIVATE: i64 = 60;
@@ -26,7 +32,7 @@ async fn is_need_send(
.await .await
.unwrap(); .unwrap();
let delta_days = if is_private == "true" { let delta_days = if query.is_private {
NOTIFICATION_DELTA_DAYS_PRIVATE NOTIFICATION_DELTA_DAYS_PRIVATE
} else { } else {
NOTIFICATION_DELTA_DAYS NOTIFICATION_DELTA_DAYS