Fix sending null fields to SoundCloud
This commit is contained in:
parent
e44e0de534
commit
adff664e87
1 changed files with 27 additions and 5 deletions
|
@ -69,12 +69,9 @@ class SoundcloudService extends ThirdPartyCeleryService implements OAuth2 {
|
||||||
*/
|
*/
|
||||||
protected function _getUploadData($file) {
|
protected function _getUploadData($file) {
|
||||||
$file = $file->getPropelOrm();
|
$file = $file->getPropelOrm();
|
||||||
|
Logging::info($file);
|
||||||
// TODO: Move this into a proper serializer
|
// TODO: Move this into a proper serializer
|
||||||
$trackArray = array(
|
$trackArray = $this->_serializeTrack($file);
|
||||||
'title' => $file->getDbName(),
|
|
||||||
'genre' => $file->getDbGenre(),
|
|
||||||
'bpm' => $file->getDbBpm(),
|
|
||||||
);
|
|
||||||
foreach (self::$_SOUNDCLOUD_PREF_FUNCTIONS as $func => $param) {
|
foreach (self::$_SOUNDCLOUD_PREF_FUNCTIONS as $func => $param) {
|
||||||
$val = Application_Model_Preference::$func();
|
$val = Application_Model_Preference::$func();
|
||||||
if (!empty($val)) {
|
if (!empty($val)) {
|
||||||
|
@ -85,6 +82,31 @@ class SoundcloudService extends ThirdPartyCeleryService implements OAuth2 {
|
||||||
return $trackArray;
|
return $trackArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Serialize Airtime file data to send to SoundCloud
|
||||||
|
*
|
||||||
|
* Ignores any null fields, as these will cause the upload to throw a 422
|
||||||
|
* Unprocessable Entity error
|
||||||
|
*
|
||||||
|
* @param $file CcFiles file object
|
||||||
|
*
|
||||||
|
* @return array the serialized data
|
||||||
|
*/
|
||||||
|
protected function _serializeTrack($file) {
|
||||||
|
$fileData = array(
|
||||||
|
'title' => $file->getDbTrackTitle(),
|
||||||
|
'genre' => $file->getDbGenre(),
|
||||||
|
'bpm' => $file->getDbBpm(),
|
||||||
|
);
|
||||||
|
$trackArray = array();
|
||||||
|
foreach ($fileData as $k => $v) {
|
||||||
|
if (!empty($v)) {
|
||||||
|
$trackArray[$k] = $v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $trackArray;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a ThirdPartyTrackReferences object for a completed upload
|
* Update a ThirdPartyTrackReferences object for a completed upload
|
||||||
* TODO: should we have a database layer class to handle Propel operations?
|
* TODO: should we have a database layer class to handle Propel operations?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue