chore: standardize security and quality foundations
This commit is contained in:
@@ -20,6 +20,7 @@ from ..clients.sonarr import SonarrClient
|
||||
from ..clients.bazarr import BazarrClient
|
||||
from ..ai.triage import triage_snapshot
|
||||
from ..auth import get_current_user
|
||||
from ..api_models import COMMON_ERROR_RESPONSES
|
||||
from ..runtime import get_runtime_settings
|
||||
from .images import cache_tmdb_image, is_tmdb_cached
|
||||
from ..db import (
|
||||
@@ -30,7 +31,6 @@ from ..db import (
|
||||
save_action,
|
||||
get_recent_actions,
|
||||
get_recent_snapshots,
|
||||
get_cached_requests,
|
||||
get_cached_requests_since,
|
||||
get_cached_request_by_media_id,
|
||||
get_request_cache_lookup,
|
||||
@@ -62,6 +62,7 @@ from ..db import (
|
||||
)
|
||||
from ..services.media_repair import current_cycle_torrents
|
||||
from ..services.download_labels import label_episode_downloads
|
||||
from ..services.arr import RootFolderNotFoundError, resolve_root_folder_path
|
||||
from ..models import Snapshot, TriageResult, RequestType
|
||||
from ..services.snapshot import (
|
||||
_summarize_qbit,
|
||||
@@ -70,7 +71,12 @@ from ..services.snapshot import (
|
||||
jellyfin_item_matches_request,
|
||||
)
|
||||
|
||||
router = APIRouter(prefix="/requests", tags=["requests"], dependencies=[Depends(get_current_user), Depends(require_request_access)])
|
||||
router = APIRouter(
|
||||
prefix="/requests",
|
||||
tags=["requests"],
|
||||
dependencies=[Depends(get_current_user), Depends(require_request_access)],
|
||||
responses=COMMON_ERROR_RESPONSES,
|
||||
)
|
||||
|
||||
CACHE_TTL_SECONDS = 600
|
||||
_detail_cache: Dict[str, Tuple[float, Dict[str, Any]]] = {}
|
||||
@@ -1753,7 +1759,6 @@ def _filter_arr_release_results(results: Any, include_rejected: bool = False) ->
|
||||
"approved": accepted,
|
||||
"rejected": item.get("rejected"),
|
||||
"temporarilyRejected": item.get("temporarilyRejected"),
|
||||
"rejections": item.get("rejections"),
|
||||
"downloadAllowed": item.get("downloadAllowed"),
|
||||
"fullSeason": item.get("fullSeason"),
|
||||
"seasonNumber": item.get("seasonNumber"),
|
||||
@@ -1971,16 +1976,10 @@ def _issue_season_payloads(episodes: List[Dict[str, Any]]) -> List[Dict[str, Any
|
||||
|
||||
|
||||
async def _resolve_root_folder_path(client: Any, root_folder: str, service_name: str) -> str:
|
||||
if root_folder.isdigit():
|
||||
folders = await client.get_root_folders()
|
||||
if isinstance(folders, list):
|
||||
for folder in folders:
|
||||
if folder.get("id") == int(root_folder):
|
||||
path = folder.get("path")
|
||||
if isinstance(path, str) and path:
|
||||
return path
|
||||
raise HTTPException(status_code=400, detail=f"{service_name} root folder id {root_folder} not found")
|
||||
return root_folder
|
||||
try:
|
||||
return await resolve_root_folder_path(client, root_folder, service_name)
|
||||
except RootFolderNotFoundError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
|
||||
|
||||
@router.get("/{request_id}/issue-options")
|
||||
@@ -2979,7 +2978,6 @@ async def recent_requests(
|
||||
) -> dict:
|
||||
runtime = get_runtime_settings()
|
||||
client = JellyseerrClient(runtime.jellyseerr_base_url, runtime.jellyseerr_api_key)
|
||||
mode = (runtime.requests_data_source or "prefer_cache").lower()
|
||||
# Browsing is always local. Synchronization is owned by background workers.
|
||||
allow_remote = False
|
||||
username_norm = _normalize_username(user.get("username", ""))
|
||||
@@ -3007,8 +3005,6 @@ async def recent_requests(
|
||||
allow_title_hydrate = False
|
||||
allow_artwork_hydrate = False
|
||||
stage_cache = await asyncio.to_thread(get_request_stage_cache)
|
||||
jellyfin = JellyfinClient(runtime.jellyfin_base_url, runtime.jellyfin_api_key)
|
||||
jellyfin_cache: Dict[str, bool] = {}
|
||||
results = []
|
||||
for row in rows:
|
||||
status = row.get("status")
|
||||
@@ -3946,7 +3942,7 @@ async def action_grab(
|
||||
release_title = receipt.get('title')
|
||||
arr_error: Optional[str] = None
|
||||
try:
|
||||
response = await arr_client.grab_release(str(guid), arr_indexer_id)
|
||||
await arr_client.grab_release(str(guid), arr_indexer_id)
|
||||
action_message = (
|
||||
f"{release_title or 'Selected release'} was sent through {service_label} for download and import."
|
||||
+ (' Profile limits explicitly overridden: ' + '; '.join(receipt['rejections']) if receipt['override'] else '')
|
||||
|
||||
Reference in New Issue
Block a user