2011-07-13 19:47:40 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* StatusNet - the distributed open-source microblogging tool
|
|
|
|
* Copyright (C) 2011, StatusNet, Inc.
|
|
|
|
*
|
|
|
|
* action periodically pinged by a page to keep a channel alive
|
2019-04-26 00:34:17 +01:00
|
|
|
*
|
2011-07-13 19:47:40 +01:00
|
|
|
* PHP version 5
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* @category Realtime
|
|
|
|
* @package StatusNet
|
|
|
|
* @author Evan Prodromou <evan@status.net>
|
|
|
|
* @copyright 2011 StatusNet, Inc.
|
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
|
|
|
* @link http://status.net/
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!defined('STATUSNET')) {
|
|
|
|
// This check helps protect against security problems;
|
|
|
|
// your code file can't be executed directly from the web.
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Action periodically pinged by a page to keep a channel alive
|
|
|
|
*
|
|
|
|
* @category Realtime
|
|
|
|
* @package StatusNet
|
|
|
|
* @author Evan Prodromou <evan@status.net>
|
|
|
|
* @copyright 2011 StatusNet, Inc.
|
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
|
|
|
* @link http://status.net/
|
|
|
|
*/
|
|
|
|
class KeepalivechannelAction extends Action
|
|
|
|
{
|
|
|
|
protected $channelKey = null;
|
2019-04-26 00:34:17 +01:00
|
|
|
protected $channel = null;
|
2011-07-13 19:47:40 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* For initializing members of the class.
|
|
|
|
*
|
2019-04-26 00:34:17 +01:00
|
|
|
* @param array $args misc. arguments
|
2011-07-13 19:47:40 +01:00
|
|
|
*
|
|
|
|
* @return boolean true
|
2019-04-26 00:34:17 +01:00
|
|
|
* @throws ClientException
|
2011-07-13 19:47:40 +01:00
|
|
|
*/
|
2019-04-26 00:34:17 +01:00
|
|
|
function prepare(array $args = [])
|
2011-07-13 19:47:40 +01:00
|
|
|
{
|
2019-04-26 00:34:17 +01:00
|
|
|
parent::prepare($args);
|
2011-07-13 19:47:40 +01:00
|
|
|
|
|
|
|
if (!$this->isPost()) {
|
2011-08-19 16:11:29 +01:00
|
|
|
// TRANS: Client exception. Do not translate POST.
|
2011-07-13 19:47:40 +01:00
|
|
|
throw new ClientException(_m('You have to POST it.'));
|
|
|
|
}
|
|
|
|
|
2011-07-13 21:10:08 +01:00
|
|
|
$this->channelKey = $this->trimmed('channelkey');
|
2011-07-13 19:47:40 +01:00
|
|
|
|
|
|
|
if (empty($this->channelKey)) {
|
2011-08-19 16:11:29 +01:00
|
|
|
// TRANS: Client exception thrown when the channel key argument is missing.
|
2011-07-13 19:47:40 +01:00
|
|
|
throw new ClientException(_m('No channel key argument.'));
|
|
|
|
}
|
|
|
|
|
2013-08-18 12:04:58 +01:00
|
|
|
$this->channel = Realtime_channel::getKV('channel_key', $this->channelKey);
|
2011-07-13 19:47:40 +01:00
|
|
|
|
|
|
|
if (empty($this->channel)) {
|
2011-08-19 16:11:29 +01:00
|
|
|
// TRANS: Client exception thrown when referring to a non-existing channel.
|
2011-07-13 19:47:40 +01:00
|
|
|
throw new ClientException(_m('No such channel.'));
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handler method
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2019-04-26 00:34:17 +01:00
|
|
|
function handle()
|
2011-07-13 19:47:40 +01:00
|
|
|
{
|
|
|
|
$this->channel->touch();
|
|
|
|
|
|
|
|
header('HTTP/1.1 204 No Content');
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if read only.
|
|
|
|
*
|
|
|
|
* MAY override
|
|
|
|
*
|
|
|
|
* @param array $args other arguments
|
|
|
|
*
|
|
|
|
* @return boolean is read only action?
|
|
|
|
*/
|
|
|
|
function isReadOnly($args)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|