uwu
This commit is contained in:
parent
96a4089bfc
commit
5f9b260d76
|
@ -17,7 +17,7 @@ pub struct Post {
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
impl Post {
|
impl Post {
|
||||||
pub async fn create_new(db: &mut Database, title: String, descr: String, img_url: String, origin_url: String, orignal_request: Value) -> anyhow::Result<Uuid> {
|
pub async fn create_new(db: &mut Database, title: String, descr: String, img_url: String, origin_url: String, orignal_request: String) -> anyhow::Result<Uuid> {
|
||||||
let id = Uuid::new_v4();
|
let id = Uuid::new_v4();
|
||||||
let posted_on = chrono::Utc::now().timestamp_millis();
|
let posted_on = chrono::Utc::now().timestamp_millis();
|
||||||
|
|
||||||
|
|
|
@ -6,21 +6,26 @@ use crate::database::{models::{self, tokens::Token}, Database};
|
||||||
|
|
||||||
use super::types::ReleaseEvent;
|
use super::types::ReleaseEvent;
|
||||||
|
|
||||||
pub async fn release_handler(db: Data<Mutex<Database>>, token: Token, body: ReleaseEvent, raw_body: String,) -> Result<HttpResponseBuilder> {
|
pub async fn release_handler(db: Data<Mutex<Database>>, token: Token, body: ReleaseEvent, raw_body: String) -> Result<HttpResponseBuilder> {
|
||||||
|
|
||||||
let title = format!("{} has been released on {}!", body.release.tag_name, body.repository.full_name);
|
let title = format!("(New release {}:{}) {}", body.repository.full_name, body.release.tag_name, body.release.name.unwrap_or("No title provided".into()));
|
||||||
|
let origin_url = body.repository.html_url.clone();
|
||||||
dbg!(body);
|
let descr = body.release.body.unwrap_or("No body provided".into());
|
||||||
// models::posts::Post::create_new(
|
let img_url = body.repository.owner.avatar_url.clone();
|
||||||
// db.lock().unwrap().borrow_mut(),
|
|
||||||
// title,
|
|
||||||
// descr,
|
|
||||||
// img_url,
|
|
||||||
// origin_url,
|
|
||||||
// orignal_request
|
|
||||||
// );
|
|
||||||
|
|
||||||
|
let res = models::posts::Post::create_new(
|
||||||
|
db.lock().unwrap().borrow_mut(),
|
||||||
|
title,
|
||||||
|
descr,
|
||||||
|
img_url,
|
||||||
|
origin_url,
|
||||||
|
raw_body
|
||||||
|
).await;
|
||||||
|
|
||||||
|
if let Err(e) = res {
|
||||||
|
log::error!("{e}");
|
||||||
|
return Ok(HttpResponse::InternalServerError());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Ok(HttpResponse::Ok())
|
Ok(HttpResponse::Ok())
|
||||||
|
|
|
@ -50,7 +50,7 @@ pub async fn handler(req: HttpRequest, token: web::Path<String>, body: Bytes, db
|
||||||
match event {
|
match event {
|
||||||
types::Event::Release(body) => events::release_handler(db, token, body, json).await,
|
types::Event::Release(body) => events::release_handler(db, token, body, json).await,
|
||||||
_ => {
|
_ => {
|
||||||
dbg!(json);
|
// dbg!(json);
|
||||||
Ok(HttpResponse::Ok())
|
Ok(HttpResponse::Ok())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user