feat(blog::components::check_update) impl handle_move & handle_update

This commit is contained in:
lumither committed 2025-04-13 03:15:48 -07:00
1 parent ff4245a856
commit 3c16bf5100
3 files changed
+37 -7

No files matched your search

@@ -44,15 +44,43 @@ async fn handle_delete(db: &PgPool, del: Delete) {
} }
async fn handle_move(db: &PgPool, mv: Move) { async fn handle_move(db: &PgPool, mv: Move) {
let identifier = parse_post_identifier(&mv.to).unwrap(); handle_delete(
db,
dev_consume!(db, mv, identifier); Delete {
todo!() uuid: mv.uuid,
path: mv.from,
},
)
.await;
handle_create(
db,
Create {
uuid: mv.uuid,
path: mv.to,
payload: mv.payload,
},
)
.await;
} }
async fn handle_update(db: &PgPool, update: Update) { async fn handle_update(db: &PgPool, update: Update) {
dev_consume!(db, update); handle_delete(
todo!() db,
Delete {
uuid: update.uuid,
path: update.path.clone(),
},
)
.await;
handle_create(
db,
Create {
uuid: update.uuid,
path: update.path,
payload: update.payload,
},
)
.await;
} }
async fn handle_create(db: &PgPool, create: Create) { async fn handle_create(db: &PgPool, create: Create) {
@@ -98,7 +126,7 @@ async fn handle_create(db: &PgPool, create: Create) {
.map(|t| t.as_str().unwrap()) .map(|t| t.as_str().unwrap())
.unwrap_or("Untitled"); .unwrap_or("Untitled");
let post_subtitle = meta let post_subtitle = meta
.get("sub_title") .get("subtitle")
.map(|t| t.as_str().unwrap()) .map(|t| t.as_str().unwrap())
.unwrap_or(""); .unwrap_or("");
let post_date_created = if let Some(Some(date)) = meta let post_date_created = if let Some(Some(date)) = meta
@@ -33,6 +33,7 @@ pub struct Move {
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Update { pub struct Update {
pub uuid: Uuid, pub uuid: Uuid,
pub path: PathBuf,
pub payload: MdFile, pub payload: MdFile,
} }
@@ -114,6 +114,7 @@ pub async fn fetch_deltas(
if let Some(id) = extract_post_id(&md_file) { if let Some(id) = extract_post_id(&md_file) {
changes.push(Change::Update(Update { changes.push(Change::Update(Update {
uuid: id, uuid: id,
path: file_path.clone(),
payload: md_file, payload: md_file,
})) }))
} else { } else {