wizarrrr / wizarr

Wizarr is an advanced user invitation and management system for Jellyfin, Plex, Emby etc.
https://docs.wizarr.dev
MIT License
1.25k stars 86 forks source link

[Bug] | Newly created users have an empty email in Jellyseer #321

Closed Pabsilon closed 9 months ago

Pabsilon commented 9 months ago

Are you using the latest release?

Have you checked a bug report doesn't already exist?

What happened?

When inviting a new user, a new user is created in jellyfin and jellyseer, but the email address for the jellyseer user isn't set. This email is useful to send notifications about requested media.

A current workaround is to add it manually after the user creates his new account.

Virtualisation

Docker

What operating system are you seeing the problem on?

Linux

What browsers are you seeing the problem on?

Chrome

Project Location

Local

Bug Description

Whenever wizarr adds a user to jellyseer, the user doesn't have an associated email address.

Steps to Reproduce

No response

Relevant Log Output

No response

realashleybailey commented 9 months ago

Wizarr does not create users on Jellyseerr and thus does not hand emails to Jellyseerr, Wizarr triggers Jellyseerr to import Jellyfin users, this is not a bug, if this is functionality you would like I would suggest adding it over at https://features.wizarr.dev

Sarin-jacob commented 3 months ago

@Pabsilon I had the same issue, what I did at the end was use wizarr API to get the json from endpoint wizarr_base_url/api/users then extracted 'id' and 'email' from it. then post '{email: < email>}'to jellyseerr_url/api/v1/user/<id>/settings/main if id alligns. You can modify the following python code and add it as Cron job


import requests

# Jellyseerr, wizarr instance variables. MODIFY These!!
J_url=f"http://localhost:5055/api/v1/"
W_url=f"http://localhost:5690/api/"
J_apikey="123456-1234-1234-1234-123456123456dc"
W_apikey="652d4b8b-0b7b-4b7b-8b7b-0b7b4b7b8b7b"

J_header={
    'accept': 'application/json',
    'Authorization': f'Bearer {J_apikey}'
}

W_header={
    'accept': 'application/json',
    'Authorization': f'Bearer {W_apikey}'
}

users=requests.get(J_url+"users", headers=J_header).json()
J_users=[]
for user in users:
    J_users.append((user["jellyfinUsername"], user["id"]))

users=requests.get(W_url+"users", headers=W_header).json()
W_users=[]
for user in users:
    W_users.append((user["username"],user["email"]))

for user in J_users:
    for user2 in W_users:
        if user[0]==user2[0]:
            try:
                requests.post(W_url+f"user/{user[1]}/settings/main", headers=J_header, json={'email':user2[1]},timeout=8)
            except:
                print(f"Error updating user {user[0]}")

This issue is few months old, still I hope someone would benefit from this :)

NB: _I haven't tested this but it should work, unless there's some change in API. You can refer the API docs from http://wizarr_ip:5690/api/docs and jellyseerr_url/api-docs (might need to enable swagger UI in environment variables)_

JamsRepos commented 3 months ago

This issue is few months old, still I hope someone would benefit from this :)

Very handy script, thanks for your contribution. I'll be sure to post this to users in the discord.

Pabsilon commented 3 months ago

Hey, @Sarin-jacob , Thanks for your script. It didn't work on my instance, maybe because a typo on the jellyseer urls (endpoint is /users and not /user) so I modified a bit so that it just iterates on jellyseer users without email (either None, "" or equal to username, that's how newly created users show for me) and then tries to match them to wizarrrr users that do have an email.

import requests

# Jellyseerr, wizarr instance variables. MODIFY These!!
J_url=f"http://<jellyseerAddress:port>/api/v1/"
W_url=f"http://<wizarrrrAddress:port>/api/"
J_apikey="<JellySeerApiKey>" # Get it from Settings / General / API Key"
W_apikey="<WizarrrrApiKey>" # Create a new one in Admin Dasboard / Settings / API Keys / Big Red Plus button

# Header for Jellyseer
J_header={
    'accept': 'application/json',
    'X-Api-Key': f'{J_apikey}'
}

# Header for wizarrrr
W_header={
    'accept': 'application/json',
    'Authorization': f'Bearer {W_apikey}'
}

# Getting the list of users from Jellyeer that don't have a mail
users=requests.get(J_url+"user?take=50&skip=0&sort=created", headers=J_header).json()
J_users=[]
for user in users["results"]:
    # In my case, newly created user in jellyseer have the user set as email
    if user["email"] is None or user["email"]=="" or user["email"]==user["jellyfinUsername"]:
        J_users.append((user["jellyfinUsername"], user["id"]))

# Getting the list of all users user from wizarrrr that have a mail set
users=requests.get(W_url+"users", headers=W_header).json()
W_users=[]
for user in users:
    if user["email"] is not None:
        W_users.append((user["username"],user["email"]))

# Calling Jellyseer to set email // Twice because sometimes it doesn't work when it's None
for jelly_user in J_users:
    for wizarrrr_user in W_users:
        if jelly_user[0] == wizarrrr_user[0]:
            # Request Twice because when the email is set to username, it takes a couple attempts...
            req = requests.post(J_url+f"user/{jelly_user[1]}/settings/main", headers=J_header,  json={"email": wizarrrr_user[1]})
            req = requests.post(J_url+f"user/{jelly_user[1]}/settings/main", headers=J_header,  json={"email": wizarrrr_user[1]})

Again, thanks for the idea. It saves some time and avoids typing errors!