Add SoundCloud delete functionality and fixes; implement TaskManager to run background jobs
This commit is contained in:
parent
706d7db2b2
commit
3902c8c746
15 changed files with 373 additions and 127 deletions
|
@ -74,7 +74,6 @@ class ErrorController extends Zend_Controller_Action {
|
|||
* 404 error - route or controller
|
||||
*/
|
||||
public function error404Action() {
|
||||
Logging::info("404!");
|
||||
$this->_helper->viewRenderer('error-404');
|
||||
$this->getResponse()->setHttpResponseCode(404);
|
||||
$this->view->message = _('Page not found.');
|
||||
|
|
|
@ -277,13 +277,11 @@ class LibraryController extends Zend_Controller_Action
|
|||
|
||||
$serviceId = $soundcloudService->getServiceId($id);
|
||||
if (!is_null($file) && $serviceId != 0) {
|
||||
$menu["soundcloud"]["items"]["view"] = array("name" => _("View on Soundcloud"), "icon" => "soundcloud", "url" => $baseUrl."soundcloud/view-on-sound-cloud/id/{$id}");
|
||||
$text = _("Re-upload to SoundCloud");
|
||||
$menu["soundcloud"]["items"]["view"] = array("name" => _("View track"), "icon" => "soundcloud", "url" => $baseUrl."soundcloud/view-on-sound-cloud/id/{$id}");
|
||||
$menu["soundcloud"]["items"]["upload"] = array("name" => _("Remove track"), "icon" => "soundcloud", "url" => $baseUrl."soundcloud/delete/id/{$id}");
|
||||
} else {
|
||||
$text = _("Upload to SoundCloud");
|
||||
$menu["soundcloud"]["items"]["upload"] = array("name" => _("Upload track"), "icon" => "soundcloud", "url" => $baseUrl."soundcloud/upload/id/{$id}");
|
||||
}
|
||||
|
||||
$menu["soundcloud"]["items"]["upload"] = array("name" => $text, "icon" => "soundcloud", "url" => $baseUrl."soundcloud/upload/id/{$id}");
|
||||
}
|
||||
|
||||
if (empty($menu)) {
|
||||
|
|
|
@ -33,13 +33,8 @@ class SoundcloudController extends ThirdPartyController {
|
|||
$soundcloudLink = $this->_service->getLinkToFile($id);
|
||||
header('Location: ' . $soundcloudLink);
|
||||
} catch (Soundcloud\Exception\InvalidHttpResponseCodeException $e) {
|
||||
// If we end up here it means the track was removed from SoundCloud
|
||||
// or the foreign id in our database is incorrect, so we should just
|
||||
// get rid of the database record
|
||||
Logging::warn("Error retrieving track data from SoundCloud: " . $e->getMessage());
|
||||
$this->_service->removeTrackReference($id);
|
||||
// Redirect to a 404 so the user knows something went wrong
|
||||
header('Location: ' . $this->_baseUrl . 'error/error-404'); // Redirect back to the Preference page
|
||||
header('Location: ' . $this->_baseUrl . 'error/error-404');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,17 @@ abstract class ThirdPartyController extends Zend_Controller_Action {
|
|||
header('Location: ' . $auth_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the previously saved request token from the preferences
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deauthorizeAction() {
|
||||
$function = $this->_SERVICE_TOKEN_ACCESSOR;
|
||||
Application_Model_Preference::$function("");
|
||||
header('Location: ' . $this->_baseUrl . 'Preference'); // Redirect back to the Preference page
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when user successfully completes third-party authorization
|
||||
* Store the returned request token for future requests
|
||||
|
@ -67,25 +78,16 @@ abstract class ThirdPartyController extends Zend_Controller_Action {
|
|||
}
|
||||
|
||||
/**
|
||||
* Clear the previously saved request token from the preferences
|
||||
* Delete the file with the given id from a third-party service
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deauthorizeAction() {
|
||||
Application_Model_Preference::$this->_SERVICE_TOKEN_ACCESSOR("");
|
||||
header('Location: ' . $this->_baseUrl . 'Preference'); // Redirect back to the Preference page
|
||||
}
|
||||
|
||||
/**
|
||||
* Poll the task queue for completed tasks associated with this service
|
||||
* Optionally accepts a specific task name as a parameter
|
||||
*
|
||||
* @return void
|
||||
* @throws Zend_Controller_Response_Exception thrown if deletion fails for any reason
|
||||
*/
|
||||
public function pollBrokerTaskQueueAction() {
|
||||
public function deleteAction() {
|
||||
$request = $this->getRequest();
|
||||
$taskName = $request->getParam('task');
|
||||
$this->_service->pollBrokerTaskQueue($taskName);
|
||||
$id = $request->getParam('id');
|
||||
$this->_service->delete($id);
|
||||
}
|
||||
|
||||
}
|
|
@ -14,8 +14,7 @@ class UpgradeController extends Zend_Controller_Action
|
|||
}
|
||||
|
||||
try {
|
||||
$upgradeManager = new UpgradeManager();
|
||||
$didWePerformAnUpgrade = $upgradeManager->doUpgrade();
|
||||
$didWePerformAnUpgrade = UpgradeManager::doUpgrade();
|
||||
|
||||
if (!$didWePerformAnUpgrade) {
|
||||
$this->getResponse()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue