streams/Zotlabs/Module/Zotfeed.php

46 lines
1.1 KiB
PHP
Raw Normal View History

2016-04-19 03:38:38 +00:00
<?php
namespace Zotlabs\Module;
2019-10-10 00:34:18 +00:00
use App;
use Zotlabs\Web\Controller;
2016-04-19 03:38:38 +00:00
2019-10-10 00:34:18 +00:00
class Zotfeed extends Controller {
2016-04-19 03:38:38 +00:00
function init() {
2019-10-10 00:34:18 +00:00
$result = [ 'success' => false ];
2016-04-19 03:38:38 +00:00
$mindate = (($_REQUEST['mindate']) ? datetime_convert('UTC','UTC',$_REQUEST['mindate']) : '');
2019-10-10 00:34:18 +00:00
if (! $mindate) {
2016-04-19 03:38:38 +00:00
$mindate = datetime_convert('UTC','UTC', 'now - 14 days');
2019-10-10 00:34:18 +00:00
}
if (observer_prohibited()) {
2016-04-19 03:38:38 +00:00
$result['message'] = 'Public access denied';
json_return_and_die($result);
}
2019-10-10 00:34:18 +00:00
2016-04-19 03:38:38 +00:00
$channel_address = ((argc() > 1) ? argv(1) : '');
2019-10-10 00:34:18 +00:00
if ($channel_address) {
$channel = channelx_by_nick($channel_address);
2016-04-19 03:38:38 +00:00
}
else {
2019-10-10 00:34:18 +00:00
$channel = get_sys_channel();
2016-04-19 03:38:38 +00:00
$mindate = datetime_convert('UTC','UTC', 'now - 14 days');
}
2019-10-10 00:34:18 +00:00
if (! $channel) {
2016-04-19 03:38:38 +00:00
$result['message'] = 'Channel not found.';
json_return_and_die($result);
}
2019-10-10 00:34:18 +00:00
logger('zotfeed request: ' . $channel['channel_name'], LOGGER_DEBUG);
2016-04-19 03:38:38 +00:00
2019-08-26 00:35:14 +00:00
$result['project'] = 'Zap';
2019-10-10 00:34:18 +00:00
$result['messages'] = zot_feed($channel['channel_id'],get_observer_hash(), [ 'mindate' => $mindate ]);
2016-04-19 03:38:38 +00:00
$result['success'] = true;
json_return_and_die($result);
}
}