**/
class LoggingAggregatorAction extends Action
{
-
var $challenge = null;
var $url = null;
*
* @return boolean false if user doesn't exist
*/
-
function prepare($args)
{
parent::prepare($args);
*
* @return void
*/
-
function handle($args)
{
parent::handle($args);
if (empty($this->url)) {
- $this->showError('Hey, you have to provide a url parameter.');
+ $this->showError(_('A URL parameter is required.'));
return;
}
if (!empty($this->challenge)) {
// must be a GET
-
if ($_SERVER['REQUEST_METHOD'] != 'GET') {
- $this->showError('This resource requires an HTTP GET.');
+ $this->showError(_m('This resource requires an HTTP GET.'));
return;
}
} else {
// must be a POST
-
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
- $this->showError('This resource requires an HTTP POST.');
+ $this->showError(_m('This resource requires an HTTP POST.'));
return;
}
*
* @return void
*/
-
function showError($msg)
{
header('HTTP/1.1 400 Bad Request');
echo "<?xml version='1.0'?>\n";
echo "<notifyResult success='false' msg='$msg' />\n";
}
-
-}
\ No newline at end of file
+}
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
**/
-
class RSSCloudRequestNotifyAction extends Action
{
/**
*
* @return boolean false if user doesn't exist
*/
-
function prepare($args)
{
parent::prepare($args);
*
* @return void
*/
-
function handle($args)
{
parent::handle($args);
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
- $this->showResult(false, 'Request must be POST.');
+ $this->showResult(false, _m('Request must be POST.'));
return;
}
if (empty($this->protocol)) {
$missing[] = 'protocol';
} else if (strtolower($this->protocol) != 'http-post') {
- $msg = 'Only http-post notifications are supported at this time.';
+ $msg = _m('Only http-post notifications are supported at this time.');
$this->showResult(false, $msg);
return;
}
}
if (!empty($missing)) {
- $msg = 'The following parameters were missing from the request body: ' .
- implode(', ', $missing) . '.';
+ // TRANS: %s is a comma separated list of parameters.
+ $msg = sprintf(_m('The following parameters were missing from the request body: %s.'),implode(', ', $missing));
$this->showResult(false, $msg);
return;
}
if (empty($this->feeds)) {
- $msg = 'You must provide at least one valid profile feed url ' .
- '(url1, url2, url3 ... urlN).';
+ $msg = _m('You must provide at least one valid profile feed url ' .
+ '(url1, url2, url3 ... urlN).');
$this->showResult(false, $msg);
return;
}
// We have to validate everything before saving anything.
// We only return one success or failure no matter how
// many feeds the subscriber is trying to subscribe to
-
foreach ($this->feeds as $feed) {
if (!$this->validateFeed($feed)) {
common_log(LOG_WARNING,
"RSSCloud plugin - $nh tried to subscribe to invalid feed: $feed");
- $msg = 'Feed subscription failed - Not a valid feed.';
+ $msg = _m('Feed subscription failed - Not a valid feed.');
$this->showResult(false, $msg);
return;
}
if (!$this->testNotificationHandler($feed)) {
- $msg = 'Feed subscription failed - ' .
- 'notification handler doesn\'t respond correctly.';
+ $msg = _m('Feed subscription failed - ' .
+ 'notification handler doesn\'t respond correctly.');
$this->showResult(false, $msg);
return;
}
-
}
foreach ($this->feeds as $feed) {
// XXX: What to do about deleting stale subscriptions?
// 25 hours seems harsh. WordPress doesn't ever remove
// subscriptions.
-
- $msg = 'Thanks for the subscription. ' .
- 'When the feed(s) update(s) we\'ll notify you.';
+ $msg = _m('Thanks for the subscription. ' .
+ 'When the feed(s) update(s) we\'ll notify you.');
$this->showResult(true, $msg);
}
*
* @return void
*/
-
function validateFeed($feed)
{
$user = $this->userFromFeed($feed);
*
* @return array $feeds the list of feeds
*/
-
function getFeeds()
{
$feeds = array();
*
* @return boolean success result
*/
-
function testNotificationHandler($feed)
{
$notifyUrl = $this->getNotifyUrl();
$notifier = new RSSCloudNotifier();
if (isset($this->domain)) {
-
// 'domain' param set, so we have to use GET and send a challenge
-
common_log(LOG_INFO,
'RSSCloud plugin - Testing notification handler with challenge: ' .
$notifyUrl);
*
* @return string notification handler url
*/
-
function getNotifyUrl()
{
if (isset($this->domain)) {
*
* @return boolean success
*/
-
function userFromFeed($feed)
{
// We only do canonical RSS2 profile feeds (specified by ID), e.g.:
// http://www.example.com/api/statuses/user_timeline/2.rss
-
$path = common_path('api/statuses/user_timeline/');
$valid = '%^' . $path . '(?<id>.*)\.rss$%';
*
* @return boolean success result
*/
-
function saveSubscription($feed)
{
$user = $this->userFromFeed($feed);
*
* @return boolean success result
*/
-
function showResult($success, $msg)
{
$this->startXML();
'msg' => $msg));
$this->endXML();
}
-
}
-