From dd9cf9b16c3c7f198d5cc64e7d8c6a73cad40679 Mon Sep 17 00:00:00 2001 From: MCorange99 Date: Sat, 30 Mar 2024 18:18:53 +0200 Subject: [PATCH] asghfuiasgkuagdsisgbkvusyudkfyugfiykgigkufgugfuyrogeig --- src/web/routes/api/webhooks/github/mod.rs | 14 ++++---------- src/web/routes/api/webhooks/mod.rs | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/web/routes/api/webhooks/github/mod.rs b/src/web/routes/api/webhooks/github/mod.rs index c150df9..9f4e671 100644 --- a/src/web/routes/api/webhooks/github/mod.rs +++ b/src/web/routes/api/webhooks/github/mod.rs @@ -3,22 +3,16 @@ pub mod events; use std::{borrow::BorrowMut, sync::Mutex}; -use actix_web::{http::header, web::{self, Bytes, Data}, HttpRequest, HttpResponse, Responder, Result, Scope}; +use actix_web::{http::header, post, web::{self, Bytes, Data}, HttpRequest, HttpResponse, Responder, Result, Scope}; use crate::database::{models, Database}; -pub async fn handler(req: HttpRequest, body: Bytes, db: Data>) -> Result { - let Some(auth) = req.headers().get(header::AUTHORIZATION) else { - return Ok(HttpResponse::Unauthorized()); - }; +pub async fn handler(req: HttpRequest, token: web::Path, body: Bytes, db: Data>) -> Result { - let Ok(token) = auth.to_str() else { - return Ok(HttpResponse::Unauthorized()); - }; let token = models::tokens::Token::get_by_token( - db.lock().unwrap().borrow_mut(), - token.to_string() + db.lock().unwrap().borrow_mut(), + token.to_string() ).await; let Ok(token) = token else { diff --git a/src/web/routes/api/webhooks/mod.rs b/src/web/routes/api/webhooks/mod.rs index c56bebb..3372ea1 100644 --- a/src/web/routes/api/webhooks/mod.rs +++ b/src/web/routes/api/webhooks/mod.rs @@ -7,5 +7,5 @@ pub fn get_scope() -> Scope { Scope::new("/wh") .route("/", web::get().to(HttpResponse::Ok)) .route("/github", web::get().to(HttpResponse::Ok)) - .route("/github", web::post().to(github::handler)) + .route("/github/{token}", web::post().to(github::handler)) } \ No newline at end of file