summaryrefslogtreecommitdiffstats
path: root/server/src/api/post.rs
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-02-06 13:10:43 -0500
committerDessalines <tyhou13@gmx.com>2020-02-06 13:10:43 -0500
commit65a6e7731c632313f539d232dec4f6f6c8a49084 (patch)
treea0ba5c7c77ae9add2bf5caea2b4865a74677fee1 /server/src/api/post.rs
parent898ea8d3ca79f14df8d25e5cc51a1b46b4468f98 (diff)
Increasing post title length limit to 200. Fixes #515
Diffstat (limited to 'server/src/api/post.rs')
-rw-r--r--server/src/api/post.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/server/src/api/post.rs b/server/src/api/post.rs
index bd276be5..00bf8e11 100644
--- a/server/src/api/post.rs
+++ b/server/src/api/post.rs
@@ -126,7 +126,15 @@ impl Perform<PostResponse> for Oper<CreatePost> {
let inserted_post = match Post::create(&conn, &post_form) {
Ok(post) => post,
- Err(_e) => return Err(APIError::err("couldnt_create_post").into()),
+ Err(e) => {
+ let err_type = if e.to_string() == "value too long for type character varying(200)" {
+ "post_title_too_long"
+ } else {
+ "couldnt_create_post"
+ };
+
+ return Err(APIError::err(err_type).into());
+ }
};
// They like their own post by default
@@ -361,7 +369,15 @@ impl Perform<PostResponse> for Oper<EditPost> {
let _updated_post = match Post::update(&conn, data.edit_id, &post_form) {
Ok(post) => post,
- Err(_e) => return Err(APIError::err("couldnt_update_post").into()),
+ Err(e) => {
+ let err_type = if e.to_string() == "value too long for type character varying(200)" {
+ "post_title_too_long"
+ } else {
+ "couldnt_update_post"
+ };
+
+ return Err(APIError::err(err_type).into());
+ }
};
// Mod tables