}
/**
-
-
-Things to consider...
-* should we purge incomplete subscriptions that never get a verification pingback?
-* when can we send subscription renewal checks?
- - at next send time probably ok
-* when can we handle trimming of subscriptions?
- - at next send time probably ok
-* should we keep a fail count?
-
-*/
-
+ * Things to consider...
+ * should we purge incomplete subscriptions that never get a verification pingback?
+ * when can we send subscription renewal checks?
+ * - at next send time probably ok
+ * when can we handle trimming of subscriptions?
+ * - at next send time probably ok
+ * should we keep a fail count?
+ */
class PushHubAction extends Action
{
function arg($arg, $def=null)
return parent::arg($arg, $def);
}
- function prepare($args)
+ protected function prepare($args)
{
StatusNet::setApi(true); // reduce exception reports to aid in debugging
return parent::prepare($args);
}
- function handle()
+ protected function handle()
{
$mode = $this->trimmed('hub.mode');
switch ($mode) {
$verify = $this->arg('hub.verify'); // @fixme may be multiple
if ($verify != 'sync' && $verify != 'async') {
- // TRANS: Client exception.
+ // TRANS: Client exception. %s is sync or async.
throw new ClientException(sprintf(_m('Invalid hub.verify "%s". It must be sync or async.'),$verify));
}
$lease = $this->arg('hub.lease_seconds', null);
if ($mode == 'subscribe' && $lease != '' && !preg_match('/^\d+$/', $lease)) {
- // TRANS: Client exception.
+ // TRANS: Client exception. %s is the invalid lease value.
throw new ClientException(sprintf(_m('Invalid hub.lease "%s". It must be empty or positive integer.'),$lease));
}
$secret = $this->arg('hub.secret', null);
if ($secret != '' && strlen($secret) >= 200) {
- // TRANS: Client exception.
+ // TRANS: Client exception. %s is the invalid hub secret.
throw new ClientException(sprintf(_m('Invalid hub.secret "%s". It must be under 200 bytes.'),$secret));
}
- $sub = HubSub::staticGet($topic, $callback);
+ $sub = HubSub::getByHashkey($topic, $callback);
if (!$sub) {
// Creating a new one!
$sub = new HubSub();
$groupFeed = common_local_url('ApiTimelineGroup', $params);
if ($feed == $userFeed) {
- $user = User::staticGet('id', $id);
+ $user = User::getKV('id', $id);
if (!$user) {
- // TRANS: Client exception.
- throw new ClientException(sprintt(_m('Invalid hub.topic "%s". User doesn\'t exist.'),$feed));
+ // TRANS: Client exception. %s is a feed URL.
+ throw new ClientException(sprintt(_m('Invalid hub.topic "%s". User does not exist.'),$feed));
} else {
return true;
}
}
if ($feed == $groupFeed) {
- $user = User_group::staticGet('id', $id);
+ $user = User_group::getKV('id', $id);
if (!$user) {
- // TRANS: Client exception.
- throw new ClientException(sprintf(_m('Invalid hub.topic "%s". Group doesn\'t exist.'),$feed));
+ // TRANS: Client exception. %s is a feed URL.
+ throw new ClientException(sprintf(_m('Invalid hub.topic "%s". Group does not exist.'),$feed));
} else {
return true;
}
$listFeed = common_local_url('ApiTimelineList', $params);
if ($feed == $listFeed) {
- $list = Profile_list::staticGet('id', $id);
- $user = User::staticGet('id', $user);
+ $list = Profile_list::getKV('id', $id);
+ $user = User::getKV('id', $user);
if (!$list || !$user || $list->tagger != $user->id) {
- throw new ClientException("Invalid hub.topic $feed; people tag doesn't exist.");
+ // TRANS: Client exception. %s is a feed URL.
+ throw new ClientException(sprintf(_m('Invalid hub.topic %s; list does not exist.'),$feed));
} else {
return true;
}
$url = $this->arg($arg);
$params = array('domain_check' => false, // otherwise breaks my local tests :P
'allowed_schemes' => array('http', 'https'));
- if (Validate::uri($url, $params)) {
+ $validate = new Validate;
+ if ($validate->uri($url, $params)) {
return $url;
} else {
// TRANS: Client exception.
*/
protected function getSub($feed, $callback)
{
- return HubSub::staticGet($feed, $callback);
+ return HubSub::getByHashkey($feed, $callback);
}
}