vw_small

Hardened fork of Vaultwarden (https://github.com/dani-garcia/vaultwarden) with fewer features.
git clone https://git.philomathiclife.com/repos/vw_small
Log | Files | Refs | README

commit 912901780eb2585ac0b182e72a0a05a30c3cdb96
parent 31bf2bc2b19850da0ef12c63da04f1adf074e292
Author: Daniel GarcĂ­a <dani-garcia@users.noreply.github.com>
Date:   Thu, 15 Feb 2018 01:07:57 +0100

Updated modified date when saving and removed hardcoded attachment domain

Diffstat:
Msrc/api/core/folders.rs | 2+-
Msrc/db/models/attachment.rs | 7+------
Msrc/db/models/cipher.rs | 6+++---
Msrc/db/models/device.rs | 6+++---
Msrc/db/models/folder.rs | 6+++---
Msrc/db/models/user.rs | 6+++---
6 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/src/api/core/folders.rs b/src/api/core/folders.rs @@ -41,7 +41,7 @@ fn post_folders(data: Json<Value>, headers: Headers, conn: DbConn) -> Result<Jso err!("Invalid name") } - let folder = Folder::new(headers.user.uuid.clone(), name.unwrap().into()); + let mut folder = Folder::new(headers.user.uuid.clone(), name.unwrap().into()); folder.save(&conn); diff --git a/src/db/models/attachment.rs b/src/db/models/attachment.rs @@ -32,10 +32,7 @@ impl Attachment { pub fn to_json(&self) -> JsonValue { use util::get_display_size; - // TODO: Change all references to localhost (maybe put it in .env?) - let host = "http://localhost:8000"; - - let web_path = format!("{}/attachments/{}/{}", host, self.cipher_uuid, self.id); + let web_path = format!("/attachments/{}/{}", self.cipher_uuid, self.id); let display_size = get_display_size(self.file_size); json!({ @@ -57,8 +54,6 @@ use db::schema::attachments; /// Database methods impl Attachment { pub fn save(&self, conn: &DbConn) -> bool { - // TODO: Update modified date - match diesel::replace_into(attachments::table) .values(self) .execute(&**conn) { diff --git a/src/db/models/cipher.rs b/src/db/models/cipher.rs @@ -82,11 +82,11 @@ impl Cipher { }) } - pub fn save(&self, conn: &DbConn) -> bool { - // TODO: Update modified date + pub fn save(&mut self, conn: &DbConn) -> bool { + self.updated_at = Utc::now().naive_utc(); match diesel::replace_into(ciphers::table) - .values(self) + .values(&*self) .execute(&**conn) { Ok(1) => true, // One row inserted _ => false, diff --git a/src/db/models/device.rs b/src/db/models/device.rs @@ -82,11 +82,11 @@ use db::schema::devices; /// Database methods impl Device { - pub fn save(&self, conn: &DbConn) -> bool { - // TODO: Update modified date + pub fn save(&mut self, conn: &DbConn) -> bool { + self.updated_at = Utc::now().naive_utc(); match diesel::replace_into(devices::table) - .values(self) + .values(&*self) .execute(&**conn) { Ok(1) => true, // One row inserted _ => false, diff --git a/src/db/models/folder.rs b/src/db/models/folder.rs @@ -51,11 +51,11 @@ use db::schema::folders; /// Database methods impl Folder { - pub fn save(&self, conn: &DbConn) -> bool { - // TODO: Update modified date + pub fn save(&mut self, conn: &DbConn) -> bool { + self.updated_at = Utc::now().naive_utc(); match diesel::replace_into(folders::table) - .values(self) + .values(&*self) .execute(&**conn) { Ok(1) => true, // One row inserted _ => false, diff --git a/src/db/models/user.rs b/src/db/models/user.rs @@ -138,11 +138,11 @@ use db::schema::users; /// Database methods impl User { - pub fn save(&self, conn: &DbConn) -> bool { - // TODO: Update modified date + pub fn save(&mut self, conn: &DbConn) -> bool { + self.updated_at = Utc::now().naive_utc(); match diesel::replace_into(users::table) // Insert or update - .values(self) + .values(&*self) .execute(&**conn) { Ok(1) => true, // One row inserted _ => false,