Skip to content

Commit

Permalink
add permission to retriever query
Browse files Browse the repository at this point in the history
  • Loading branch information
vnghia committed Oct 23, 2024
1 parent ae61c33 commit e40216a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions nghe-backend/src/orm/retriever.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use diesel::prelude::*;
use diesel::SelectableHelper;
use uuid::Uuid;

use super::{albums, music_folders, permission, songs, user_music_folder_permissions};
use super::{albums, music_folders, permission, songs};

#[derive(Debug, Queryable, Selectable)]
#[diesel(table_name = songs, check_for_backend(crate::orm::Type))]
Expand All @@ -20,11 +20,11 @@ pub struct Song<'mf, 'path> {
#[auto_type]
pub fn query<'mf, 'path>(user_id: Uuid, song_id: Uuid) -> _ {
let permission_query: permission::query = permission::query(user_id);
let select_song: AsSelect<Song<'mf, 'path>, crate::orm::Type> = Song::<'mf, 'path>::as_select();
music_folders::table
.inner_join(user_music_folder_permissions::table)
.inner_join(albums::table)
.inner_join(songs::table.on(songs::album_id.eq(albums::id)))
let select_song: AsSelect<Song<'mf, 'path>, crate::orm::Type> = Song::as_select();
albums::table
.inner_join(songs::table)
.inner_join(music_folders::table)
.filter(songs::id.eq(song_id))
.filter(permission_query)
.select(select_song)
}
4 changes: 2 additions & 2 deletions nghe-backend/src/response/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl Binary {

pub async fn from_local<F: file::Mime>(
path: Utf8TypedPath<'_>,
property: Property<F>,
property: &Property<F>,
offset: impl Into<Option<u64>> + Copy,
seekable: bool,
cacheable: bool,
Expand All @@ -63,7 +63,7 @@ impl Binary {

pub fn from_async_read<F: file::Mime>(
reader: impl AsyncRead + Send + 'static,
property: Property<F>,
property: &Property<F>,
offset: impl Into<Option<u64>>,
seekable: bool,
cacheable: bool,
Expand Down

0 comments on commit e40216a

Please sign in to comment.