Skip to content

Commit 543d804

Browse files
committed
refactor: [#615] redirect to details url with infohash method now calls the torrent service that implements the authorization layer
1 parent f8e7570 commit 543d804

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/web/api/server/v1/contexts/torrent/handlers.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ pub async fn get_torrent_info_handler(
164164
return errors::Request::InvalidInfoHashParam.into_response();
165165
};
166166

167-
if let Some(redirect_response) = redirect_to_details_url_using_canonical_info_hash_if_needed(&app_data, &info_hash).await {
167+
if let Some(redirect_response) =
168+
redirect_to_details_url_using_canonical_info_hash_if_needed(&app_data, &info_hash, opt_user_id).await
169+
{
168170
redirect_response
169171
} else {
170172
match app_data.torrent_service.get_torrent_info(&info_hash, opt_user_id).await {
@@ -177,12 +179,9 @@ pub async fn get_torrent_info_handler(
177179
async fn redirect_to_details_url_using_canonical_info_hash_if_needed(
178180
app_data: &Arc<AppData>,
179181
info_hash: &InfoHash,
182+
opt_user_id: Option<i64>,
180183
) -> Option<Response> {
181-
match app_data
182-
.torrent_info_hash_repository
183-
.find_canonical_info_hash_for(info_hash)
184-
.await
185-
{
184+
match app_data.torrent_service.get_canonical_info_hash(info_hash, opt_user_id).await {
186185
Ok(Some(canonical_info_hash)) => {
187186
if canonical_info_hash != *info_hash {
188187
return Some(

0 commit comments

Comments
 (0)