diff options
-rw-r--r-- | src/db.rs | 13 | ||||
-rw-r--r-- | src/errors.rs | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/db.rs b/src/db.rs index bfbdd193c4c7..3c44172b15c2 100644 --- a/src/db.rs +++ b/src/db.rs @@ -208,6 +208,19 @@ impl Handler<CreatePost> for DbExecutor { let conn = self.0.get()?; + let closed: bool = { + use schema::threads::dsl::*; + threads.select(closed) + .find(msg.0.thread_id) + .first(&conn)? + }; + + if closed { + return Err(ConverseError::ThreadClosed { + id: msg.0.thread_id + }) + } + Ok(diesel::insert_into(posts::table) .values(&msg.0) .get_result(&conn)?) diff --git a/src/errors.rs b/src/errors.rs index c73379f0cafb..dd0e12c0450e 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -124,7 +124,7 @@ impl ResponseError for ConverseError { // Everything is mapped to internal server errors for now. match *self { ConverseError::ThreadClosed { id } => HttpResponse::SeeOther() - .header("Location", format!("/thread/{}#edit-post", id)) + .header("Location", format!("/thread/{}#post-reply", id)) .finish(), _ => HttpResponse::build(StatusCode::INTERNAL_SERVER_ERROR) .body(format!("An error occured: {}", self)) |