streams/Code/Module/Ap_probe.php

50 lines
1.3 KiB
PHP
Raw Normal View History

2018-08-20 03:41:32 +00:00
<?php
2021-12-03 03:01:39 +00:00
2022-02-16 04:08:28 +00:00
namespace Code\Module;
2018-08-20 03:41:32 +00:00
2019-05-28 03:50:05 +00:00
use App;
2022-02-16 04:08:28 +00:00
use Code\Web\Controller;
use Code\Web\HTTPSig;
use Code\Lib\ActivityStreams;
use Code\Lib\Activity;
use Code\Lib\Yaml;
use Code\Lib\Channel;
use Code\Render\Theme;
2022-02-12 20:43:29 +00:00
2018-08-20 03:41:32 +00:00
2021-12-02 23:02:31 +00:00
class Ap_probe extends Controller
{
2018-08-20 03:41:32 +00:00
2021-12-02 23:02:31 +00:00
public function get()
{
2018-08-20 03:41:32 +00:00
2021-12-02 23:02:31 +00:00
$channel = null;
2019-05-28 03:50:05 +00:00
2022-02-12 20:43:29 +00:00
$o = replace_macros(Theme::get_template('ap_probe.tpl'), [
2021-12-02 23:02:31 +00:00
'$page_title' => t('ActivityPub Probe Diagnostic'),
'$resource' => ['resource', t('Object URL'), $_REQUEST['resource'], EMPTY_STR],
'$authf' => ['authf', t('Authenticated fetch'), $_REQUEST['authf'], EMPTY_STR, [t('No'), t('Yes')]],
'$submit' => t('Submit')
]);
2019-05-28 03:50:05 +00:00
2021-12-02 23:02:31 +00:00
if (x($_REQUEST, 'resource')) {
$resource = $_REQUEST['resource'];
if ($_REQUEST['authf']) {
$channel = App::get_channel();
if (!$channel) {
2022-01-25 01:26:12 +00:00
$channel = Channel::get_system();
2021-12-02 23:02:31 +00:00
}
}
2018-08-20 03:41:32 +00:00
2021-12-02 23:02:31 +00:00
$x = Activity::fetch($resource, $channel, null, true);
2018-08-20 03:41:32 +00:00
2021-12-02 23:02:31 +00:00
if ($x) {
$o .= '<pre>' . str_replace('\\n', "\n", htmlspecialchars(json_encode($x, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT))) . '</pre>';
2022-01-07 09:37:56 +00:00
$o .= '<pre>' . str_replace('\\n', "\n", htmlspecialchars(Yaml::encode($x))) . '</pre>';
2021-12-02 23:02:31 +00:00
}
}
return $o;
}
2018-08-20 03:41:32 +00:00
}