1
0
Fork 1
Spiegel von https://github.com/dani-garcia/vaultwarden.git synchronisiert 2024-11-26 05:50:29 +01:00

Updated modified date when saving and removed hardcoded attachment domain

Dieser Commit ist enthalten in:
Daniel García 2018-02-15 01:07:57 +01:00
Ursprung 31bf2bc2b1
Commit 912901780e
6 geänderte Dateien mit 14 neuen und 19 gelöschten Zeilen

Datei anzeigen

@ -41,7 +41,7 @@ fn post_folders(data: Json<Value>, headers: Headers, conn: DbConn) -> Result<Jso
err!("Invalid name") 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); folder.save(&conn);

Datei anzeigen

@ -32,10 +32,7 @@ impl Attachment {
pub fn to_json(&self) -> JsonValue { pub fn to_json(&self) -> JsonValue {
use util::get_display_size; use util::get_display_size;
// TODO: Change all references to localhost (maybe put it in .env?) let web_path = format!("/attachments/{}/{}", self.cipher_uuid, self.id);
let host = "http://localhost:8000";
let web_path = format!("{}/attachments/{}/{}", host, self.cipher_uuid, self.id);
let display_size = get_display_size(self.file_size); let display_size = get_display_size(self.file_size);
json!({ json!({
@ -57,8 +54,6 @@ use db::schema::attachments;
/// Database methods /// Database methods
impl Attachment { impl Attachment {
pub fn save(&self, conn: &DbConn) -> bool { pub fn save(&self, conn: &DbConn) -> bool {
// TODO: Update modified date
match diesel::replace_into(attachments::table) match diesel::replace_into(attachments::table)
.values(self) .values(self)
.execute(&**conn) { .execute(&**conn) {

Datei anzeigen

@ -82,11 +82,11 @@ impl Cipher {
}) })
} }
pub fn save(&self, conn: &DbConn) -> bool { pub fn save(&mut self, conn: &DbConn) -> bool {
// TODO: Update modified date self.updated_at = Utc::now().naive_utc();
match diesel::replace_into(ciphers::table) match diesel::replace_into(ciphers::table)
.values(self) .values(&*self)
.execute(&**conn) { .execute(&**conn) {
Ok(1) => true, // One row inserted Ok(1) => true, // One row inserted
_ => false, _ => false,

Datei anzeigen

@ -82,11 +82,11 @@ use db::schema::devices;
/// Database methods /// Database methods
impl Device { impl Device {
pub fn save(&self, conn: &DbConn) -> bool { pub fn save(&mut self, conn: &DbConn) -> bool {
// TODO: Update modified date self.updated_at = Utc::now().naive_utc();
match diesel::replace_into(devices::table) match diesel::replace_into(devices::table)
.values(self) .values(&*self)
.execute(&**conn) { .execute(&**conn) {
Ok(1) => true, // One row inserted Ok(1) => true, // One row inserted
_ => false, _ => false,

Datei anzeigen

@ -51,11 +51,11 @@ use db::schema::folders;
/// Database methods /// Database methods
impl Folder { impl Folder {
pub fn save(&self, conn: &DbConn) -> bool { pub fn save(&mut self, conn: &DbConn) -> bool {
// TODO: Update modified date self.updated_at = Utc::now().naive_utc();
match diesel::replace_into(folders::table) match diesel::replace_into(folders::table)
.values(self) .values(&*self)
.execute(&**conn) { .execute(&**conn) {
Ok(1) => true, // One row inserted Ok(1) => true, // One row inserted
_ => false, _ => false,

Datei anzeigen

@ -138,11 +138,11 @@ use db::schema::users;
/// Database methods /// Database methods
impl User { impl User {
pub fn save(&self, conn: &DbConn) -> bool { pub fn save(&mut self, conn: &DbConn) -> bool {
// TODO: Update modified date self.updated_at = Utc::now().naive_utc();
match diesel::replace_into(users::table) // Insert or update match diesel::replace_into(users::table) // Insert or update
.values(self) .values(&*self)
.execute(&**conn) { .execute(&**conn) {
Ok(1) => true, // One row inserted Ok(1) => true, // One row inserted
_ => false, _ => false,