aboutsummaryrefslogtreecommitdiff
path: root/src/db/models/send.rs
diff options
context:
space:
mode:
authorMathijs van Veluw <[email protected]>2024-12-14 00:55:34 +0100
committerGitHub <[email protected]>2024-12-14 00:55:34 +0100
commit9cd400db6c5da858a4f49eb883469cbd6cb7337d (patch)
tree1c1d1900c1e1ba20da64e4c2052285b2d81317e8 /src/db/models/send.rs
parentfd512300448995735961cbeedcbe4b684be1c5fd (diff)
downloadvaultwarden-9cd400db6c5da858a4f49eb883469cbd6cb7337d.tar.gz
vaultwarden-9cd400db6c5da858a4f49eb883469cbd6cb7337d.zip
Some refactoring and optimizations (#5291)
- Refactored several code to use more modern syntax - Made some checks a bit more strict - Updated crates Signed-off-by: BlackDex <[email protected]>
Diffstat (limited to 'src/db/models/send.rs')
-rw-r--r--src/db/models/send.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/db/models/send.rs b/src/db/models/send.rs
index 36944281..fb95f86b 100644
--- a/src/db/models/send.rs
+++ b/src/db/models/send.rs
@@ -268,9 +268,8 @@ impl Send {
use data_encoding::BASE64URL_NOPAD;
use uuid::Uuid;
- let uuid_vec = match BASE64URL_NOPAD.decode(access_id.as_bytes()) {
- Ok(v) => v,
- Err(_) => return None,
+ let Ok(uuid_vec) = BASE64URL_NOPAD.decode(access_id.as_bytes()) else {
+ return None;
};
let uuid = match Uuid::from_slice(&uuid_vec) {
@@ -291,6 +290,17 @@ impl Send {
}}
}
+ pub async fn find_by_uuid_and_user(uuid: &str, user_uuid: &str, conn: &mut DbConn) -> Option<Self> {
+ db_run! {conn: {
+ sends::table
+ .filter(sends::uuid.eq(uuid))
+ .filter(sends::user_uuid.eq(user_uuid))
+ .first::<SendDb>(conn)
+ .ok()
+ .from_db()
+ }}
+ }
+
pub async fn find_by_user(user_uuid: &str, conn: &mut DbConn) -> Vec<Self> {
db_run! {conn: {
sends::table