diff options
Diffstat (limited to 'src/db/models/send.rs')
-rw-r--r-- | src/db/models/send.rs | 16 |
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 |