From 2b785d3fe4044c138536daa5920b154befdd86aa Mon Sep 17 00:00:00 2001 From: ATechnoHazard Date: Thu, 2 Jul 2020 12:37:56 +0530 Subject: [PATCH] paste: Make is_url an optional parameter in JSON body Signed-off-by: ATechnoHazard --- src/core/paste/entity.rs | 2 +- src/core/paste/service.rs | 2 +- src/schema.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/paste/entity.rs b/src/core/paste/entity.rs index e41e88a..28f4d75 100644 --- a/src/core/paste/entity.rs +++ b/src/core/paste/entity.rs @@ -5,6 +5,6 @@ use crate::schema::pastes; pub struct Paste { pub id: Option, pub belongs_to: Option, - pub is_url: bool, + pub is_url: Option, pub content: String, } diff --git a/src/core/paste/service.rs b/src/core/paste/service.rs index 3f17aec..85429f0 100644 --- a/src/core/paste/service.rs +++ b/src/core/paste/service.rs @@ -5,7 +5,7 @@ use super::entity::Paste; use super::postgres; pub fn create_paste(paste: &mut Paste, conn: &PgConnection) -> Result { - paste.is_url = validator::validate_url(paste.content.clone()); + paste.is_url = Some(validator::validate_url(paste.content.clone())); postgres::create_paste(paste, conn) } diff --git a/src/schema.rs b/src/schema.rs index 74ca95f..614f666 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -2,7 +2,7 @@ table! { pastes (id) { id -> Nullable, belongs_to -> Nullable, - is_url -> Bool, + is_url -> Nullable, content -> Text, } }