* i18n/L10n updates
* superfluous whitespace removed
This commit is contained in:
parent
596d2c212a
commit
eed0b24f23
@ -47,7 +47,6 @@ if (!defined('STATUSNET')) {
|
|||||||
**/
|
**/
|
||||||
class LoggingAggregatorAction extends Action
|
class LoggingAggregatorAction extends Action
|
||||||
{
|
{
|
||||||
|
|
||||||
var $challenge = null;
|
var $challenge = null;
|
||||||
var $url = null;
|
var $url = null;
|
||||||
|
|
||||||
@ -58,7 +57,6 @@ class LoggingAggregatorAction extends Action
|
|||||||
*
|
*
|
||||||
* @return boolean false if user doesn't exist
|
* @return boolean false if user doesn't exist
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function prepare($args)
|
function prepare($args)
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
@ -79,22 +77,20 @@ class LoggingAggregatorAction extends Action
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function handle($args)
|
function handle($args)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
if (empty($this->url)) {
|
if (empty($this->url)) {
|
||||||
$this->showError('Hey, you have to provide a url parameter.');
|
$this->showError(_('A URL parameter is required.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($this->challenge)) {
|
if (!empty($this->challenge)) {
|
||||||
|
|
||||||
// must be a GET
|
// must be a GET
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] != 'GET') {
|
if ($_SERVER['REQUEST_METHOD'] != 'GET') {
|
||||||
$this->showError('This resource requires an HTTP GET.');
|
$this->showError(_m('This resource requires an HTTP GET.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,9 +100,8 @@ class LoggingAggregatorAction extends Action
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
// must be a POST
|
// must be a POST
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] != '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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +123,6 @@ class LoggingAggregatorAction extends Action
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function showError($msg)
|
function showError($msg)
|
||||||
{
|
{
|
||||||
header('HTTP/1.1 400 Bad Request');
|
header('HTTP/1.1 400 Bad Request');
|
||||||
@ -136,5 +130,4 @@ class LoggingAggregatorAction extends Action
|
|||||||
echo "<?xml version='1.0'?>\n";
|
echo "<?xml version='1.0'?>\n";
|
||||||
echo "<notifyResult success='false' msg='$msg' />\n";
|
echo "<notifyResult success='false' msg='$msg' />\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -235,6 +235,4 @@ class RSSCloudNotifier
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,10 +247,9 @@ class RSSCloudPlugin extends Plugin
|
|||||||
'rawdescription' =>
|
'rawdescription' =>
|
||||||
_m('The RSSCloud plugin enables your StatusNet instance to publish ' .
|
_m('The RSSCloud plugin enables your StatusNet instance to publish ' .
|
||||||
'real-time updates for profile RSS feeds using the ' .
|
'real-time updates for profile RSS feeds using the ' .
|
||||||
'<a href="http://rsscloud.org/">RSSCloud protocol</a>".'));
|
'<a href="http://rsscloud.org/">RSSCloud protocol</a>.'));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,4 +38,3 @@ class RSSCloudQueueHandler extends QueueHandler
|
|||||||
return $notifier->notify($profile);
|
return $notifier->notify($profile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,6 @@ if (!defined('STATUSNET')) {
|
|||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
**/
|
**/
|
||||||
|
|
||||||
class RSSCloudRequestNotifyAction extends Action
|
class RSSCloudRequestNotifyAction extends Action
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -51,7 +50,6 @@ class RSSCloudRequestNotifyAction extends Action
|
|||||||
*
|
*
|
||||||
* @return boolean false if user doesn't exist
|
* @return boolean false if user doesn't exist
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function prepare($args)
|
function prepare($args)
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
@ -84,13 +82,12 @@ class RSSCloudRequestNotifyAction extends Action
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function handle($args)
|
function handle($args)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||||
$this->showResult(false, 'Request must be POST.');
|
$this->showResult(false, _m('Request must be POST.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +104,7 @@ class RSSCloudRequestNotifyAction extends Action
|
|||||||
if (empty($this->protocol)) {
|
if (empty($this->protocol)) {
|
||||||
$missing[] = 'protocol';
|
$missing[] = 'protocol';
|
||||||
} else if (strtolower($this->protocol) != 'http-post') {
|
} 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);
|
$this->showResult(false, $msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -117,15 +114,15 @@ class RSSCloudRequestNotifyAction extends Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($missing)) {
|
if (!empty($missing)) {
|
||||||
$msg = 'The following parameters were missing from the request body: ' .
|
// TRANS: %s is a comma separated list of parameters.
|
||||||
implode(', ', $missing) . '.';
|
$msg = sprintf(_m('The following parameters were missing from the request body: %s.'),implode(', ', $missing));
|
||||||
$this->showResult(false, $msg);
|
$this->showResult(false, $msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($this->feeds)) {
|
if (empty($this->feeds)) {
|
||||||
$msg = 'You must provide at least one valid profile feed url ' .
|
$msg = _m('You must provide at least one valid profile feed url ' .
|
||||||
'(url1, url2, url3 ... urlN).';
|
'(url1, url2, url3 ... urlN).');
|
||||||
$this->showResult(false, $msg);
|
$this->showResult(false, $msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -133,7 +130,6 @@ class RSSCloudRequestNotifyAction extends Action
|
|||||||
// We have to validate everything before saving anything.
|
// We have to validate everything before saving anything.
|
||||||
// We only return one success or failure no matter how
|
// We only return one success or failure no matter how
|
||||||
// many feeds the subscriber is trying to subscribe to
|
// many feeds the subscriber is trying to subscribe to
|
||||||
|
|
||||||
foreach ($this->feeds as $feed) {
|
foreach ($this->feeds as $feed) {
|
||||||
|
|
||||||
if (!$this->validateFeed($feed)) {
|
if (!$this->validateFeed($feed)) {
|
||||||
@ -142,18 +138,17 @@ class RSSCloudRequestNotifyAction extends Action
|
|||||||
common_log(LOG_WARNING,
|
common_log(LOG_WARNING,
|
||||||
"RSSCloud plugin - $nh tried to subscribe to invalid feed: $feed");
|
"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);
|
$this->showResult(false, $msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->testNotificationHandler($feed)) {
|
if (!$this->testNotificationHandler($feed)) {
|
||||||
$msg = 'Feed subscription failed - ' .
|
$msg = _m('Feed subscription failed - ' .
|
||||||
'notification handler doesn\'t respond correctly.';
|
'notification handler doesn\'t respond correctly.');
|
||||||
$this->showResult(false, $msg);
|
$this->showResult(false, $msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->feeds as $feed) {
|
foreach ($this->feeds as $feed) {
|
||||||
@ -163,9 +158,8 @@ class RSSCloudRequestNotifyAction extends Action
|
|||||||
// XXX: What to do about deleting stale subscriptions?
|
// XXX: What to do about deleting stale subscriptions?
|
||||||
// 25 hours seems harsh. WordPress doesn't ever remove
|
// 25 hours seems harsh. WordPress doesn't ever remove
|
||||||
// subscriptions.
|
// subscriptions.
|
||||||
|
$msg = _m('Thanks for the subscription. ' .
|
||||||
$msg = 'Thanks for the subscription. ' .
|
'When the feed(s) update(s) we\'ll notify you.');
|
||||||
'When the feed(s) update(s) we\'ll notify you.';
|
|
||||||
|
|
||||||
$this->showResult(true, $msg);
|
$this->showResult(true, $msg);
|
||||||
}
|
}
|
||||||
@ -178,7 +172,6 @@ class RSSCloudRequestNotifyAction extends Action
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function validateFeed($feed)
|
function validateFeed($feed)
|
||||||
{
|
{
|
||||||
$user = $this->userFromFeed($feed);
|
$user = $this->userFromFeed($feed);
|
||||||
@ -196,7 +189,6 @@ class RSSCloudRequestNotifyAction extends Action
|
|||||||
*
|
*
|
||||||
* @return array $feeds the list of feeds
|
* @return array $feeds the list of feeds
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getFeeds()
|
function getFeeds()
|
||||||
{
|
{
|
||||||
$feeds = array();
|
$feeds = array();
|
||||||
@ -218,7 +210,6 @@ class RSSCloudRequestNotifyAction extends Action
|
|||||||
*
|
*
|
||||||
* @return boolean success result
|
* @return boolean success result
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function testNotificationHandler($feed)
|
function testNotificationHandler($feed)
|
||||||
{
|
{
|
||||||
$notifyUrl = $this->getNotifyUrl();
|
$notifyUrl = $this->getNotifyUrl();
|
||||||
@ -226,9 +217,7 @@ class RSSCloudRequestNotifyAction extends Action
|
|||||||
$notifier = new RSSCloudNotifier();
|
$notifier = new RSSCloudNotifier();
|
||||||
|
|
||||||
if (isset($this->domain)) {
|
if (isset($this->domain)) {
|
||||||
|
|
||||||
// 'domain' param set, so we have to use GET and send a challenge
|
// 'domain' param set, so we have to use GET and send a challenge
|
||||||
|
|
||||||
common_log(LOG_INFO,
|
common_log(LOG_INFO,
|
||||||
'RSSCloud plugin - Testing notification handler with challenge: ' .
|
'RSSCloud plugin - Testing notification handler with challenge: ' .
|
||||||
$notifyUrl);
|
$notifyUrl);
|
||||||
@ -248,7 +237,6 @@ class RSSCloudRequestNotifyAction extends Action
|
|||||||
*
|
*
|
||||||
* @return string notification handler url
|
* @return string notification handler url
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getNotifyUrl()
|
function getNotifyUrl()
|
||||||
{
|
{
|
||||||
if (isset($this->domain)) {
|
if (isset($this->domain)) {
|
||||||
@ -267,12 +255,10 @@ class RSSCloudRequestNotifyAction extends Action
|
|||||||
*
|
*
|
||||||
* @return boolean success
|
* @return boolean success
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function userFromFeed($feed)
|
function userFromFeed($feed)
|
||||||
{
|
{
|
||||||
// We only do canonical RSS2 profile feeds (specified by ID), e.g.:
|
// We only do canonical RSS2 profile feeds (specified by ID), e.g.:
|
||||||
// http://www.example.com/api/statuses/user_timeline/2.rss
|
// http://www.example.com/api/statuses/user_timeline/2.rss
|
||||||
|
|
||||||
$path = common_path('api/statuses/user_timeline/');
|
$path = common_path('api/statuses/user_timeline/');
|
||||||
$valid = '%^' . $path . '(?<id>.*)\.rss$%';
|
$valid = '%^' . $path . '(?<id>.*)\.rss$%';
|
||||||
|
|
||||||
@ -293,7 +279,6 @@ class RSSCloudRequestNotifyAction extends Action
|
|||||||
*
|
*
|
||||||
* @return boolean success result
|
* @return boolean success result
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function saveSubscription($feed)
|
function saveSubscription($feed)
|
||||||
{
|
{
|
||||||
$user = $this->userFromFeed($feed);
|
$user = $this->userFromFeed($feed);
|
||||||
@ -334,7 +319,6 @@ class RSSCloudRequestNotifyAction extends Action
|
|||||||
*
|
*
|
||||||
* @return boolean success result
|
* @return boolean success result
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function showResult($success, $msg)
|
function showResult($success, $msg)
|
||||||
{
|
{
|
||||||
$this->startXML();
|
$this->startXML();
|
||||||
@ -343,6 +327,4 @@ class RSSCloudRequestNotifyAction extends Action
|
|||||||
'msg' => $msg));
|
'msg' => $msg));
|
||||||
$this->endXML();
|
$this->endXML();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,5 +75,4 @@ class RSSCloudSubscription extends Memcached_DataObject {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user