SAAS-853 - Celery backend for SoundCloud uploads
This commit is contained in:
parent
f031d13867
commit
626489bb3b
27 changed files with 813 additions and 250 deletions
|
@ -10,6 +10,16 @@ abstract class ThirdPartyController extends Zend_Controller_Action {
|
|||
*/
|
||||
protected $_baseUrl;
|
||||
|
||||
/**
|
||||
* @var ThirdPartyService third party service object
|
||||
*/
|
||||
protected $_service;
|
||||
|
||||
/**
|
||||
* @var string Application_Model_Preference service request token accessor function name
|
||||
*/
|
||||
protected $_SERVICE_TOKEN_ACCESSOR;
|
||||
|
||||
/**
|
||||
* Disable controller rendering and initialize
|
||||
*/
|
||||
|
@ -17,8 +27,8 @@ abstract class ThirdPartyController extends Zend_Controller_Action {
|
|||
$CC_CONFIG = Config::getConfig();
|
||||
$this->_baseUrl = 'http://' . $CC_CONFIG['baseUrl'] . ":" . $CC_CONFIG['basePort'] . "/";
|
||||
|
||||
$this->view->layout()->disableLayout(); // Don't inject the standard Now Playing header.
|
||||
$this->_helper->viewRenderer->setNoRender(true); // Don't use (phtml) templates
|
||||
$this->view->layout()->disableLayout(); // Don't inject the standard Now Playing header.
|
||||
$this->_helper->viewRenderer->setNoRender(true); // Don't use (phtml) templates
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,30 +36,56 @@ abstract class ThirdPartyController extends Zend_Controller_Action {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract function authorizeAction();
|
||||
public function authorizeAction() {
|
||||
$auth_url = $this->_service->getAuthorizeUrl();
|
||||
header('Location: ' . $auth_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when user successfully completes third-party authorization.
|
||||
* Store the returned request token for future requests.
|
||||
* Called when user successfully completes third-party authorization
|
||||
* Store the returned request token for future requests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract function redirectAction();
|
||||
public function redirectAction() {
|
||||
$code = $_GET['code'];
|
||||
$this->_service->requestNewAccessToken($code);
|
||||
header('Location: ' . $this->_baseUrl . 'Preference'); // Redirect back to the Preference page
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload the file with the given id to a third-party service.
|
||||
* Upload the file with the given id to a third-party service
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws Zend_Controller_Response_Exception thrown if upload fails for any reason
|
||||
*/
|
||||
abstract function uploadAction();
|
||||
public function uploadAction() {
|
||||
$request = $this->getRequest();
|
||||
$id = $request->getParam('id');
|
||||
$this->_service->upload($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the previously saved request token from the preferences.
|
||||
* Clear the previously saved request token from the preferences
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract function deauthorizeAction();
|
||||
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
|
||||
*/
|
||||
public function pollBrokerTaskQueueAction() {
|
||||
$request = $this->getRequest();
|
||||
$taskName = $request->getParam('task');
|
||||
$this->_service->pollBrokerTaskQueue($taskName);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue