From 153c5f42baafd825105d1fb7eeebcdc0b26b5d1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alban=20F=C3=A9ron?= Date: Fri, 30 Dec 2022 16:55:20 +0100 Subject: [PATCH] Porting supysonic.api.user --- supysonic/api/user.py | 11 ++++------- supysonic/db.py | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/supysonic/api/user.py b/supysonic/api/user.py index df51e88..4b4edf7 100644 --- a/supysonic/api/user.py +++ b/supysonic/api/user.py @@ -1,7 +1,7 @@ # This file is part of Supysonic. # Supysonic is a Python implementation of the Subsonic server API. # -# Copyright (C) 2013-2020 Alban 'spl0k' Féron +# Copyright (C) 2013-2022 Alban 'spl0k' Féron # # Distributed under terms of the GNU AGPLv3 license. @@ -12,7 +12,7 @@ from ..db import User from ..managers.user import UserManager from . import decode_password, api_routing -from .exceptions import Forbidden, NotFound +from .exceptions import Forbidden def admin_only(f): @@ -33,9 +33,6 @@ def user_info(): raise Forbidden() user = User.get(name=username) - if user is None: - raise NotFound("User") - return request.formatter("user", user.as_subsonic_user()) @@ -99,8 +96,6 @@ def user_changepass(): def user_edit(): username = request.values["username"] user = User.get(name=username) - if user is None: - raise NotFound("User") if "password" in request.values: password = decode_password(request.values["password"]) @@ -120,4 +115,6 @@ def user_edit(): jukebox = jukebox in (True, "True", "true", 1, "1") user.jukebox = jukebox + user.save() + return request.formatter.empty diff --git a/supysonic/db.py b/supysonic/db.py index 05a227d..841b6bd 100644 --- a/supysonic/db.py +++ b/supysonic/db.py @@ -401,7 +401,7 @@ class User(_Model): def as_subsonic_user(self): return { "username": self.name, - "email": self.mail, + "email": self.mail or "", "scrobblingEnabled": self.lastfm_session is not None and self.lastfm_status, "adminRole": self.admin, "settingsRole": True,