Fallenbagel / jellyseerr

Fork of overseerr for jellyfin support.
https://docs.jellyseerr.dev/
MIT License
3.52k stars 218 forks source link

[Feature Request] Option to automatically delete Jellyseer users when the corresponding Jellyfin user is deleted #90

Open cmbarba opened 2 years ago

cmbarba commented 2 years ago

Description

At moment, when Jellyfin users are deleted from Jellyfin through the Jellyfin>Dashboard>Users page or through something like jfa-go, the Jellyseer accounts that were made from those Jellyfin users remain and must be manually deleted. Adding a way to automatically deal with orphaned users would make the Fin/Seer experience more seamless. This is really just a quality of life issue and might be more of general Overseerr accounts issue and thus out of the scope of this project anyway, but I thought to bring it up since it deals with Jellyfin.

Desired Behavior

Add a togglable option under Jellyseer>Settings (Admin)>Users to allow Jellyfin user deletions to trigger Jellyseer user deletions, matched by user name. Possibly also add a function on the Jellyseer>Users (Admin) page that purges all orphaned users.

Fallenbagel commented 2 years ago

Hey so while we are working on implementing this, you might be interested in this script someone (MattrixM) in discord wrote for this:

#Hostname or IP:port
$URL = ""

#Jellyseerr API Key
$APIKey = ""

$a = Invoke-RestMethod -uri "http://$URL/api/v1/settings/jellyfin/users" -method Get -Headers @{"x-api-key" = "$APIKey"} -ContentType "application/json"

$b = Invoke-RestMethod -uri "http://$URL/api/v1/user?take=200&skip=0&sort=displayname" -method Get -Headers @{"x-api-key" = "$APIKey"} -ContentType "application/json"

$EmbyUsers = $a | select username

$SeerUsers = $b.results | select jellyfinusername, id

ForEach($Item in $SeerUsers)
{
    If($EmbyUsers.username -notcontains $Item.jellyfinUsername)
    {
    $ID = $item.id
    Invoke-RestMethod -uri "http://$URL/api/v1/user/$ID" -method Delete -Headers @{"x-api-key" = "$APIKey"} -ContentType "application/json"
    } 
}