A lot of updates for 1.4.12
This commit is contained in:
@@ -447,41 +447,41 @@ command_result ConnectedClient::handleCommandPlaylistEdit(ts::Command &cmd) {
|
||||
if(auto perr = playlist->client_has_permissions(this->ref(), permission::i_playlist_needed_modify_power, permission::i_playlist_modify_power); perr)
|
||||
return command_result{perr};
|
||||
|
||||
deque<pair<shared_ptr<property::PropertyDescription>, string>> properties;
|
||||
deque<pair<const property::PropertyDescription*, string>> properties;
|
||||
|
||||
for(const auto& key : cmd[0].keys()) {
|
||||
if(key == "playlist_id") continue;
|
||||
if(key == "return_code") continue;
|
||||
|
||||
auto property = property::info<property::PlaylistProperties>(key);
|
||||
if(*property == property::PLAYLIST_UNDEFINED) {
|
||||
const auto& property = property::find<property::PlaylistProperties>(key);
|
||||
if(property == property::PLAYLIST_UNDEFINED) {
|
||||
logError(this->getServerId(), R"([{}] Tried to edit a not existing playlist property "{}" to "{}")", CLIENT_STR_LOG_PREFIX, key, cmd[key].string());
|
||||
continue;
|
||||
}
|
||||
|
||||
if((property->flags & property::FLAG_USER_EDITABLE) == 0) {
|
||||
if((property.flags & property::FLAG_USER_EDITABLE) == 0) {
|
||||
logError(this->getServerId(), "[{}] Tried to change a playlist property which is not changeable. (Key: {}, Value: \"{}\")", CLIENT_STR_LOG_PREFIX, key, cmd[key].string());
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!property->validate_input(cmd[key].as<string>())) {
|
||||
if(!property.validate_input(cmd[key].as<string>())) {
|
||||
logError(this->getServerId(), "[{}] Tried to change a playlist property to an invalid value. (Key: {}, Value: \"{}\")", CLIENT_STR_LOG_PREFIX, key, cmd[key].string());
|
||||
continue;
|
||||
}
|
||||
|
||||
if(*property == property::PLAYLIST_CURRENT_SONG_ID) {
|
||||
if(property == property::PLAYLIST_CURRENT_SONG_ID) {
|
||||
auto song_id = cmd[key].as<SongId>();
|
||||
auto song = song_id > 0 ? playlist->find_song(song_id) : nullptr;
|
||||
if(song_id != 0 && !song)
|
||||
return command_result{error::playlist_invalid_song_id};
|
||||
} else if(*property == property::PLAYLIST_MAX_SONGS) {
|
||||
} else if(property == property::PLAYLIST_MAX_SONGS) {
|
||||
auto value = cmd[key].as<int32_t>();
|
||||
auto max_value = this->calculate_permission(permission::i_max_playlist_size, this->getChannelId());
|
||||
if(max_value.has_value && !permission::v2::permission_granted(value, max_value))
|
||||
return command_result{permission::i_max_playlist_size};
|
||||
}
|
||||
|
||||
properties.emplace_back(property, key);
|
||||
properties.emplace_back(&property, key);
|
||||
}
|
||||
for(const auto& property : properties) {
|
||||
if(*property.first == property::PLAYLIST_CURRENT_SONG_ID) {
|
||||
|
||||
Reference in New Issue
Block a user