diff options
author | Vincent Ambo <mail@tazj.in> | 2018-05-27T12·12+0200 |
---|---|---|
committer | Vincent Ambo <github@tazj.in> | 2018-05-27T13·00+0200 |
commit | 8901d5d73a50ce2d426aece1f8ab0ff0216278ef (patch) | |
tree | b2de277f94a230910c114afbe3565045be27d352 /src/db.rs | |
parent | a14ece6af3a2d0f03af072c337ef50e311a79066 (diff) |
feat(db): Prevent responses to closed threads
This concludes the thread-closing implementation!
Diffstat (limited to 'src/db.rs')
-rw-r--r-- | src/db.rs | 13 |
1 files changed, 13 insertions, 0 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)?) |