Show imported Seerr accounts while preserving linked-user deduplication
Magent CI/CD / verify (push) Successful in 10m42s
Magent CI/CD / deploy-prod (push) Skipped
Magent CI/CD / deploy-beta (push) Skipped

This commit is contained in:
2026-09-07 15:20:10 +12:00
parent 697fc235ee
commit 0637860b95
2 changed files with 20 additions and 11 deletions
+3 -11
View File
@@ -1223,9 +1223,8 @@ def get_all_users() -> list[Dict[str, Any]]:
"is_expired": _is_datetime_in_past(row[12]), "is_expired": _is_datetime_in_past(row[12]),
} }
) )
# Admin user management uses Jellyfin as the source of truth for non-admin # Imported Seerr accounts must remain manageable. Prefer a Jellyfin/local
# user objects. Seerr rows are treated as enrichment-only and hidden # account when a linked duplicate exists, without hiding Seerr-only users.
# from admin/user-management views to avoid duplicate accounts in the UI.
def _provider_rank(user: Dict[str, Any]) -> int: def _provider_rank(user: Dict[str, Any]) -> int:
provider = str(user.get("auth_provider") or "local").strip().lower() provider = str(user.get("auth_provider") or "local").strip().lower()
if provider == "jellyfin": if provider == "jellyfin":
@@ -1236,14 +1235,7 @@ def get_all_users() -> list[Dict[str, Any]]:
return 2 return 2
return 2 return 2
visible_candidates = [ visible_candidates = all_rows
user
for user in all_rows
if not (
str(user.get("auth_provider") or "local").strip().lower() == "jellyseerr"
and str(user.get("role") or "user").strip().lower() != "admin"
)
]
visible_candidates.sort( visible_candidates.sort(
key=lambda user: ( key=lambda user: (
@@ -0,0 +1,17 @@
import unittest
from backend.app import db
from backend.tests.test_backend_quality import TempDatabaseMixin
class SeerrUserVisibilityTests(TempDatabaseMixin, unittest.TestCase):
def test_seerr_only_users_are_visible(self):
db.create_user('local-admin', 'test-password', role='admin')
db.create_user('imported-member', 'jellyseerr-user', auth_provider='jellyseerr', jellyseerr_user_id=42)
self.assertEqual({u['username'] for u in db.get_all_users()}, {'local-admin', 'imported-member'})
def test_linked_duplicate_prefers_jellyfin(self):
db.create_user('member@example.com', 'jellyseerr-user', auth_provider='jellyseerr', jellyseerr_user_id=42)
db.create_user('member', 'jellyfin-user', auth_provider='jellyfin', jellyseerr_user_id=42)
users = db.get_all_users()
self.assertEqual(len(users), 1)
self.assertEqual(users[0]['username'], 'member')