aboutsummaryrefslogtreecommitdiffstats
path: root/rust/src/editing.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-05-14 17:09:50 -0700
committerBryan Newbold <bnewbold@robocracy.org>2019-05-14 17:09:50 -0700
commit822df2600ed7463ad23640559bcc51ecf9908456 (patch)
tree499ff34e5c50de9733cc1a9d488350328ab288e2 /rust/src/editing.rs
parent43ebd22582c33e95479572c213657a781e1eca3f (diff)
downloadfatcat-822df2600ed7463ad23640559bcc51ecf9908456.tar.gz
fatcat-822df2600ed7463ad23640559bcc51ecf9908456.zip
rust impl endpoint changes
Diffstat (limited to 'rust/src/editing.rs')
-rw-r--r--rust/src/editing.rs30
1 files changed, 2 insertions, 28 deletions
diff --git a/rust/src/editing.rs b/rust/src/editing.rs
index c17e5964..65cd5bb8 100644
--- a/rust/src/editing.rs
+++ b/rust/src/editing.rs
@@ -5,7 +5,6 @@
use crate::database_models::*;
use crate::database_schema::*;
-use crate::editing_crud::EditgroupCrud;
use crate::entity_crud::EntityCrud;
use crate::errors::{FatcatError, Result};
use crate::identifiers::FatcatId;
@@ -37,37 +36,12 @@ impl EditContext {
}
}
+// This function used to be more complex, and take a database response.
pub fn make_edit_context(
- conn: &DbConn,
editor_id: FatcatId,
- editgroup_id: Option<FatcatId>,
+ editgroup_id: FatcatId,
autoaccept: bool,
- description: Option<String>,
- extra: Option<serde_json::Value>,
) -> Result<EditContext> {
- // *either* autoaccept is false and editgroup_id is Some, *or* autoaccept is true and
- // editgroup_id is None
- let editgroup_id: FatcatId = match (editgroup_id, autoaccept) {
- (Some(eg), false) => eg,
- (None, true) => {
- let eg = Editgroup {
- editgroup_id: None,
- editor_id: Some(editor_id.to_string()),
- editor: None,
- changelog_index: None,
- submitted: None,
- description: description,
- extra: extra,
- annotations: None,
- edits: None,
- };
- let row = eg.db_create(conn, autoaccept)?;
- FatcatId::from_uuid(&row.id)
- }
- _ => Err(FatcatError::BadRequest(
- "unsupported batch editgroup/accept combination".to_string(),
- ))?,
- };
Ok(EditContext {
editor_id,
editgroup_id,