X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FOStatus%2Factions%2Fpushhub.php;h=c883647e681ef8768b58694cf9458ca49b81e894;hb=2729c622ff7ae8b657e6058548f863d96985b534;hp=e7716c8cd03b9c05f6eceb3c6f0f1fd38bae422c;hpb=c335db4bbc1521d45308c757ef31da9625e38ee5;p=quix0rs-gnu-social.git diff --git a/plugins/OStatus/actions/pushhub.php b/plugins/OStatus/actions/pushhub.php index e7716c8cd0..c883647e68 100644 --- a/plugins/OStatus/actions/pushhub.php +++ b/plugins/OStatus/actions/pushhub.php @@ -28,18 +28,14 @@ if (!defined('STATUSNET')) { } /** - - -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) @@ -51,13 +47,13 @@ class PushHubAction extends Action 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) { @@ -95,13 +91,13 @@ class PushHubAction extends Action $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)); } @@ -109,11 +105,11 @@ class PushHubAction extends Action $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(); @@ -159,19 +155,19 @@ class PushHubAction extends Action $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; } @@ -183,10 +179,11 @@ class PushHubAction extends Action $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; } @@ -206,7 +203,8 @@ class PushHubAction extends Action $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. @@ -224,6 +222,6 @@ class PushHubAction extends Action */ protected function getSub($feed, $callback) { - return HubSub::staticGet($feed, $callback); + return HubSub::getByHashkey($feed, $callback); } }