summaryrefslogtreecommitdiffstats
path: root/rust
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-05-17 00:09:57 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-05-17 00:09:57 -0700
commit828969d73e0261b7348af7a842851a89a780ddf4 (patch)
treea14036510f2ee9191de2114c35bf7b69950d3e89 /rust
parent6aee40ac9538f9391c9e630efddf4b39fdad5a50 (diff)
downloadfatcat-828969d73e0261b7348af7a842851a89a780ddf4.tar.gz
fatcat-828969d73e0261b7348af7a842851a89a780ddf4.zip
editgroup post
Diffstat (limited to 'rust')
-rw-r--r--rust/src/api_server.rs25
1 files changed, 19 insertions, 6 deletions
diff --git a/rust/src/api_server.rs b/rust/src/api_server.rs
index 52e9501f..2a744525 100644
--- a/rust/src/api_server.rs
+++ b/rust/src/api_server.rs
@@ -626,14 +626,27 @@ impl Api for Server {
fn editgroup_post(
&self,
+ body: models::Editgroup,
context: &Context,
) -> Box<Future<Item = EditgroupPostResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "editgroup_post() - X-Span-ID: {:?}",
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
+ let conn = self.db_pool.get().expect("db_pool error");
+
+ let row: EditgroupRow = insert_into(editgroup::table)
+ .values((
+ editgroup::editor_id.eq(body.editor_id as i64),
+ editgroup::description.eq(body.description)
+ ))
+ .get_result(&conn)
+ .expect("error creating edit group");
+
+ let new_eg = Editgroup {
+ id: Some(row.id as isize),
+ editor_id: row.editor_id as isize,
+ description: row.description,
+ };
+ Box::new(futures::done(Ok(EditgroupPostResponse::SuccessfullyCreated(
+ new_eg,
+ ))))
}
fn editor_username_changelog_get(