Subsonic API: added user management commands

This commit is contained in:
emeric
2019-08-02 14:56:08 +02:00
parent 8409184511
commit 61032e5292
6 changed files with 462 additions and 257 deletions
File diff suppressed because it is too large Load Diff
+11 -5
View File
@@ -77,14 +77,20 @@ CustomTypeToString(Error::CustomType type)
{
switch (type)
{
case Error::CustomType::BadId:
return "Bad id";
case Error::CustomType::NotImplemented:
return "Not implemented";
case Error::CustomType::InternalError:
case Error::CustomType::BadIdFormat:
return "Bad id format";
case Error::CustomType::BadPasswordFormat:
return "Internal error";
case Error::CustomType::InternalError:
return "Bad password format";
case Error::CustomType::LoginThrottled:
return "Login throttled, too many attempts";
case Error::CustomType::NotImplemented:
return "Not implemented";
case Error::CustomType::PasswordTooWeak:
return "Password too weak";
case Error::CustomType::UserAlreadyExists:
return "User already exists";
}
return "Unknown custom error";
+6 -3
View File
@@ -48,10 +48,13 @@ class Error
enum class CustomType
{
BadId,
NotImplemented,
LoginThrottled,
BadIdFormat,
BadPasswordFormat,
InternalError,
LoginThrottled,
NotImplemented,
PasswordTooWeak,
UserAlreadyExists,
};
Error(Code code);
+12 -2
View File
@@ -147,9 +147,19 @@ User::setAudioTranscodeBitrate(Bitrate bitrate)
}
void
User::setMaxAudioTranscodeBitrate(Bitrate bitrate)
User::setMaxAudioTranscodeBitrate(Bitrate requestedBitrate)
{
_maxAudioTranscodeBitrate = std::min(bitrate, *audioTranscodeAllowedBitrates.rbegin());
Bitrate bitrate {*audioTranscodeAllowedBitrates.begin()};
for (auto allowedBitrate : audioTranscodeAllowedBitrates)
{
if (requestedBitrate < allowedBitrate)
break;
bitrate = allowedBitrate;
}
_maxAudioTranscodeBitrate = bitrate;
if (_audioTranscodeBitrate > _maxAudioTranscodeBitrate)
_audioTranscodeBitrate = _maxAudioTranscodeBitrate;
}
+6
View File
@@ -97,6 +97,12 @@ stringTrimEnd(const std::string& str, const std::string& whitespace)
return str.substr(0, str.find_last_not_of(whitespace)+1);
}
std::string
stringToLower(const std::string& str)
{
return boost::algorithm::to_lower_copy(str);
}
std::string
bufferToString(const std::vector<unsigned char>& data)
{
+3
View File
@@ -46,6 +46,9 @@ stringTrim(const std::string& str, const std::string& whitespaces = " \t");
std::string
stringTrimEnd(const std::string& str, const std::string& whitespaces = " \t");
std::string
stringToLower(const std::string& str);
std::string
bufferToString(const std::vector<unsigned char>& data);