From 595a15cfd3b3bd1e06d13f6274867616bea61ef0 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Fri, 14 Dec 2018 22:01:14 +0800 Subject: many redirect implementations Probably should have split this commit up, it's huge: - accept the state of "redirect to a deletion", where redirect_id is Some but rev_id is None. call this a "redirect"; previously this was an invalid state. - GET for a deleted entity returns a 200 and a stub entity, not a 404 - to PUT a redirect, or to "revert" an entity to point at a specific pre-existing revision, PUT a stub entity. things are getting messy here... to detect this state, ensure the 'state' field is blank/none (this is for API usage ergonomics, where results from a GET are often re-used in a PUT or even POST) - rustfmt - maybe even more small tweaks along the way? mystery meat! Tests are in python, not rust (and a future commit) --- rust/src/database_models.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'rust/src/database_models.rs') diff --git a/rust/src/database_models.rs b/rust/src/database_models.rs index a7076e09..82088f28 100644 --- a/rust/src/database_models.rs +++ b/rust/src/database_models.rs @@ -14,7 +14,7 @@ use uuid::Uuid; pub enum EntityState { WorkInProgress, Active(Uuid), - Redirect(Uuid, Uuid), + Redirect(Uuid, Option), Deleted, } @@ -111,7 +111,7 @@ macro_rules! entity_structs { } match (self.redirect_id, self.rev_id) { (None, None) => Ok(EntityState::Deleted), - (Some(redir), Some(rev)) => Ok(EntityState::Redirect(redir, rev)), + (Some(redir), rev) => Ok(EntityState::Redirect(redir, rev)), (None, Some(rev)) => Ok(EntityState::Active(rev)), _ => bail!("Invalid EntityIdentRow state"), } -- cgit v1.2.3