- add: Refresh Session call to actually refresh the cache session.

This commit is contained in:
2025-03-21 23:23:38 -04:00
parent 4046f56191
commit 9e984d2aa8
5 changed files with 68 additions and 6 deletions

View File

@@ -2,7 +2,7 @@ use crate::grpc::database_service::MyDatabaseService;
use crate::grpc::session_service_server::SessionService;
use tonic::{Request, Response, Status};
use tracing::debug;
use crate::grpc::{GetSessionRequest, GetSessionResponse};
use crate::grpc::{GetSessionRequest, GetSessionResponse, RefreshSessionRequest, RefreshSessionResponse};
#[tonic::async_trait]
impl SessionService for MyDatabaseService {
@@ -22,4 +22,19 @@ impl SessionService for MyDatabaseService {
user_id: session.user_id,
}))
}
async fn refresh_session(&self, request: Request<RefreshSessionRequest>) -> Result<Response<RefreshSessionResponse>, Status> {
let req = request.into_inner();
debug!("get_session: {:?}", req);
let session = self.db.session_repo.refresh_session(&req.session_id).await
.map_err(|_| Status::not_found("Session not found"))?;
let valid = true;
debug!("session: {:?}", session);
Ok(Response::new(RefreshSessionResponse {
valid
}))
}
}