mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 01:15:13 +00:00
Merge pull request 'dev' (#2) from streams/streams:dev into dev
Reviewed-on: https://codeberg.org/elvecio/streams/pulls/2
This commit is contained in:
commit
3e75868e17
7 changed files with 52 additions and 15 deletions
|
@ -122,8 +122,16 @@ class Activity
|
|||
|
||||
logger('fetch_actual: ' . $url, LOGGER_DEBUG);
|
||||
|
||||
$default_accept_header = 'application/activity+json, application/x-zot-activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"';
|
||||
|
||||
if ($channel) {
|
||||
$accept_header = PConfig::Get($channel['channel_id'],'system','accept_header');
|
||||
}
|
||||
if (!$accept_header) {
|
||||
$accept_header = Config::Get('system', 'accept_header', $default_accept_header);
|
||||
}
|
||||
$headers = [
|
||||
'Accept' => 'application/activity+json, application/x-zot-activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
|
||||
'Accept' => $accept_header,
|
||||
'Host' => $parsed['host'],
|
||||
'Date' => datetime_convert('UTC', 'UTC', 'now', 'D, d M Y H:i:s \\G\\M\\T'),
|
||||
'(request-target)' => 'get ' . get_request_string($url)
|
||||
|
|
|
@ -508,13 +508,26 @@ class ActivityStreams
|
|||
|
||||
public static function is_as_request() : bool
|
||||
{
|
||||
$x = getBestSupportedMimeType([
|
||||
'application/ld+json;profile="https://www.w3.org/ns/activitystreams"',
|
||||
'application/activity+json',
|
||||
'application/ld+json;profile="http://www.w3.org/ns/activitystreams"',
|
||||
'application/ld+json',
|
||||
'application/x-zot-activity+json'
|
||||
]);
|
||||
$default_accept_header = 'application/activity+json, application/x-zot-activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"';
|
||||
|
||||
if ($channel) {
|
||||
$accept_header = PConfig::Get($channel['channel_id'],'system','accept_header');
|
||||
}
|
||||
if (!$accept_header) {
|
||||
$accept_header = Config::Get('system', 'accept_header', $default_accept_header);
|
||||
}
|
||||
|
||||
$x = getBestSupportedMimeType(explode(',', $accept_header));
|
||||
|
||||
if (! $x) {
|
||||
$x = getBestSupportedMimeType([
|
||||
'application/ld+json;profile="https://www.w3.org/ns/activitystreams"',
|
||||
'application/activity+json',
|
||||
'application/ld+json;profile="http://www.w3.org/ns/activitystreams"',
|
||||
'application/ld+json',
|
||||
'application/x-zot-activity+json'
|
||||
]);
|
||||
}
|
||||
|
||||
return (bool)$x;
|
||||
}
|
||||
|
|
|
@ -3238,10 +3238,22 @@ class Libzot
|
|||
|
||||
public static function is_nomad_request()
|
||||
{
|
||||
$x = getBestSupportedMimeType([ 'application/x-zot+json', 'application/x-nomad+json' ]);
|
||||
$supportedTypes = explode(',', self::getAccepts());
|
||||
$x = getBestSupportedMimeType($supportedTypes);
|
||||
return (($x) ? true : false);
|
||||
}
|
||||
|
||||
public static function getAccepts() {
|
||||
$default_accept_header = 'application/x-zot+json,application/x-nomad+json';
|
||||
|
||||
if ($channel) {
|
||||
$accept_header = PConfig::Get($channel['channel_id'],'system','nomad_accept_header');
|
||||
}
|
||||
if (!$accept_header) {
|
||||
$accept_header = Config::Get('system', 'nomad_accept_header', $default_accept_header);
|
||||
}
|
||||
return $accept_header;
|
||||
}
|
||||
|
||||
public static function zot_record_preferred($arr, $check = 'hubloc_network')
|
||||
{
|
||||
|
|
|
@ -25,9 +25,10 @@ class Zotfinger
|
|||
|
||||
$data = json_encode(['zot_token' => random_string()]);
|
||||
|
||||
$accepts = Libzot::getAccepts();
|
||||
if ($channel && $m) {
|
||||
$headers = [
|
||||
'Accept' => 'application/x-nomad+json, application/x-zot+json',
|
||||
'Accept' => $accepts,
|
||||
'Content-Type' => 'application/x-nomad+json',
|
||||
'X-Zot-Token' => random_string(),
|
||||
'Digest' => HTTPSig::generate_digest_header($data),
|
||||
|
@ -37,7 +38,7 @@ class Zotfinger
|
|||
$h = HTTPSig::create_sig($headers, $channel['channel_prvkey'], Channel::url($channel), false);
|
||||
}
|
||||
else {
|
||||
$h = ['Accept: application/x-nomad+json, application/x-zot+json'];
|
||||
$h = ['Accept: ' . $accepts];
|
||||
}
|
||||
|
||||
$result = [];
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Code\Module\Dev;
|
||||
|
||||
use App;
|
||||
use Code\Lib\Libzot;
|
||||
use Code\Lib\Url;
|
||||
use Code\Lib\Zotfinger;
|
||||
use Code\Web\Controller;
|
||||
|
@ -31,7 +32,8 @@ class Zot_probe extends Controller
|
|||
|
||||
$o .= '<pre>' . htmlspecialchars(print_array($x)) . '</pre>';
|
||||
|
||||
$headers = 'Accept: application/x-nomad+json, application/x-zot+json, application/jrd+json, application/json';
|
||||
$accepts = Libzot::getAccepts() . ', application/jrd+json, application/json';
|
||||
$headers = 'Accept: ' . $accepts;
|
||||
|
||||
$x = Url::get($resource, ['headers' => [$headers]]);
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Code\Module;
|
||||
|
||||
use App;
|
||||
use Code\Lib\Libzot;
|
||||
use Code\Web\Controller;
|
||||
use Code\Web\HTTPSig;
|
||||
use Code\Lib\SConfig;
|
||||
|
@ -95,7 +96,7 @@ class Magic extends Controller
|
|||
$dest = strip_query_param($dest, 'f');
|
||||
|
||||
$headers = [];
|
||||
$headers['Accept'] = 'application/x-nomad+json, application/x-zot+json';
|
||||
$headers['Accept'] = Libzot::getAccepts();
|
||||
$headers['Content-Type'] = 'application/x-nomad+json';
|
||||
$headers['X-Open-Web-Auth'] = random_string();
|
||||
$headers['Host'] = $parsed['host'];
|
||||
|
|
|
@ -99,7 +99,7 @@ class Rpost extends Controller
|
|||
|
||||
$url = z_root() . '/cloud/' . $channel['channel_address'] . '/' . $r['data']['display_path'];
|
||||
|
||||
if (strpos($r['data']['filetype'], 'video') === 0) {
|
||||
if (str_starts_with($r['data']['filetype'], 'video')) {
|
||||
for ($n = 0; $n < 15; $n++) {
|
||||
$thumb = Linkinfo::get_video_poster($url);
|
||||
if ($thumb) {
|
||||
|
@ -114,7 +114,7 @@ class Rpost extends Controller
|
|||
$s .= "\n\n" . '[zvideo]' . $url . '[/zvideo]' . "\n\n";
|
||||
}
|
||||
}
|
||||
if (strpos($r['data']['filetype'], 'audio') === 0) {
|
||||
if (str_starts_with($r['data']['filetype'], 'audio')) {
|
||||
$s .= "\n\n" . '[zaudio]' . $url . '[/zaudio]' . "\n\n";
|
||||
}
|
||||
if ($r['data']['filetype'] === 'image/svg+xml') {
|
||||
|
|
Loading…
Reference in a new issue