feat(dashboard): rework paperless review actions

This commit is contained in:
Fizzlepoof
2026-05-14 19:43:57 +00:00
parent c0b3a52074
commit 5bb519f895
3 changed files with 23 additions and 22 deletions

View File

@@ -76,14 +76,15 @@ class Handler(SimpleHTTPRequestHandler):
def _paperless_action(self, payload: dict):
item_id = str(payload.get('id', '')).strip()
action = str(payload.get('action', '')).strip().lower()
if not item_id or action not in {'acknowledge', 'dismiss'}:
if not item_id or action not in {'needs_attention', 'good_to_go'}:
return self._json(HTTPStatus.BAD_REQUEST, {'ok': False, 'error': 'bad_payload'})
state = load_json(PAPERLESS_STATE, {})
current = state.get(item_id, {}) if isinstance(state, dict) else {}
if action == 'acknowledge':
new_status = 'active' if current.get('status') == 'acknowledged' else 'acknowledged'
current_status = str(current.get('status') or '').lower()
if action == 'needs_attention':
new_status = 'active' if current_status == 'needs_attention' else 'needs_attention'
else:
new_status = 'dismissed'
new_status = 'good_to_go'
state[item_id] = {'status': new_status}
save_json(PAPERLESS_STATE, state)
return self._json(HTTPStatus.OK, {'ok': True, 'id': item_id, 'status': new_status})