about summary refs log tree commit diff
path: root/src/handlers.rs
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@gmail.com>2018-04-14T14·33+0200
committerVincent Ambo <tazjin@gmail.com>2018-04-14T14·33+0200
commit8c30ef92f652f411679408344031706745346f02 (patch)
treef15ab0ebead519c105c03c128ae7f04c4194074b /src/handlers.rs
parenta90d1cc1a41e405ea397b06a3bc1907291c98b65 (diff)
refactor(db): Store thread body in the posts table
This is a simplification over the previous approach. The OP of a
thread is just a normal post like any other in this model, which
allows some code simplifications (and future query convenience).
Diffstat (limited to 'src/handlers.rs')
-rw-r--r--src/handlers.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/handlers.rs b/src/handlers.rs
index c97e677311..c866f7a140 100644
--- a/src/handlers.rs
+++ b/src/handlers.rs
@@ -105,12 +105,16 @@ pub fn submit_thread(state: State<AppState>,
 
     let new_thread = NewThread {
         title: input.0.title,
-        body: input.0.body,
         author_name: author.name,
         author_email: author.email,
     };
 
-    state.db.send(CreateThread(new_thread))
+    let msg = CreateThread {
+        new_thread,
+        body: input.0.body,
+    };
+
+    state.db.send(msg)
         .from_err()
         .and_then(move |res| {
             let thread = res?;