Skip to content
Snippets Groups Projects
Unverified Commit 84810f2b authored by Daniel García's avatar Daniel García
Browse files

Remove unnecessary fields from send access

parent a71359f6
No related branches found
No related tags found
No related merge requests found
......@@ -231,7 +231,7 @@ fn post_access(access_id: String, data: JsonUpcase<SendAccessData>, conn: DbConn
send.save(&conn)?;
Ok(Json(send.to_json()))
Ok(Json(send.to_json_access()))
}
#[post("/sends/<send_id>/access/file/<file_id>", data = "<data>")]
......
......@@ -130,6 +130,24 @@ impl Send {
"Object": "send",
})
}
pub fn to_json_access(&self) -> Value {
use crate::util::format_date;
let data: Value = serde_json::from_str(&self.data).unwrap_or_default();
json!({
"Id": self.uuid,
"Type": self.atype,
"Name": self.name,
"Text": if self.atype == SendType::Text as i32 { Some(&data) } else { None },
"File": if self.atype == SendType::File as i32 { Some(&data) } else { None },
"ExpirationDate": self.expiration_date.as_ref().map(format_date),
"Object": "send-access",
})
}
}
use crate::db::DbConn;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment