Unified JSON exit

This commit is contained in:
Michael 2022-04-09 11:58:01 +00:00
parent 344e12c4fc
commit d15023fe4b
21 changed files with 61 additions and 80 deletions

View File

@ -28,6 +28,7 @@ use Friendica\Content\Nav;
use Friendica\Content\Widget; use Friendica\Content\Widget;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Event; use Friendica\Model\Event;
@ -216,8 +217,7 @@ function cal_content(App $a)
$events = Event::prepareListForTemplate($r); $events = Event::prepareListForTemplate($r);
if (!empty(DI::args()->getArgv()[2]) && (DI::args()->getArgv()[2] === 'json')) { if (!empty(DI::args()->getArgv()[2]) && (DI::args()->getArgv()[2] === 'json')) {
echo json_encode($events); System::jsonExit($events);
exit();
} }
// links: array('href', 'text', 'extra css classes', 'title') // links: array('href', 'text', 'extra css classes', 'title')

View File

@ -20,6 +20,7 @@
*/ */
use Friendica\App; use Friendica\App;
use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\User; use Friendica\Model\User;
@ -37,8 +38,7 @@ function msearch_post(App $a)
if (!strlen($search)) { if (!strlen($search)) {
$output = ['total' => 0, 'items_page' => $perpage, 'page' => $page, 'results' => $results]; $output = ['total' => 0, 'items_page' => $perpage, 'page' => $page, 'results' => $results];
echo json_encode($output); System::jsonExit($output);
exit();
} }
$total = 0; $total = 0;
@ -60,7 +60,5 @@ function msearch_post(App $a)
$output = ['total' => $total, 'items_page' => $perpage, 'page' => $page, 'results' => $results]; $output = ['total' => $total, 'items_page' => $perpage, 'page' => $page, 'results' => $results];
echo json_encode($output); System::jsonExit($output);
exit();
} }

View File

@ -25,10 +25,10 @@ use Friendica\Content\Text\BBCode;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Strings;
use Friendica\Util\XML; use Friendica\Util\XML;
function poco_init(App $a) { function poco_init(App $a) {
@ -234,9 +234,7 @@ function poco_init(App $a) {
exit(); exit();
} }
if ($format === 'json') { if ($format === 'json') {
header('Content-type: application/json'); System::jsonExit($ret);
echo json_encode($ret);
exit();
} else { } else {
throw new \Friendica\Network\HTTPException\InternalServerErrorException(); throw new \Friendica\Network\HTTPException\InternalServerErrorException();
} }

View File

@ -21,6 +21,7 @@
use Friendica\App; use Friendica\App;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Attach; use Friendica\Model\Attach;
@ -36,15 +37,13 @@ function wall_attach_post(App $a) {
$owner = User::getOwnerDataByNick($nick); $owner = User::getOwnerDataByNick($nick);
if (!DBA::isResult($owner)) { if (!DBA::isResult($owner)) {
if ($r_json) { if ($r_json) {
echo json_encode(['error' => DI::l10n()->t('Invalid request.')]); System::jsonExit(['error' => DI::l10n()->t('Invalid request.')]);
exit();
} }
return; return;
} }
} else { } else {
if ($r_json) { if ($r_json) {
echo json_encode(['error' => DI::l10n()->t('Invalid request.')]); System::jsonExit(['error' => DI::l10n()->t('Invalid request.')]);
exit();
} }
return; return;
@ -65,8 +64,7 @@ function wall_attach_post(App $a) {
if (!$can_post) { if (!$can_post) {
if ($r_json) { if ($r_json) {
echo json_encode(['error' => DI::l10n()->t('Permission denied.')]); System::jsonExit(['error' => DI::l10n()->t('Permission denied.')]);
exit();
} }
notice(DI::l10n()->t('Permission denied.') . EOL ); notice(DI::l10n()->t('Permission denied.') . EOL );
exit(); exit();
@ -74,7 +72,7 @@ function wall_attach_post(App $a) {
if (empty($_FILES['userfile'])) { if (empty($_FILES['userfile'])) {
if ($r_json) { if ($r_json) {
echo json_encode(['error' => DI::l10n()->t('Invalid request.')]); System::jsonExit(['error' => DI::l10n()->t('Invalid request.')]);
} }
exit(); exit();
} }
@ -93,23 +91,23 @@ function wall_attach_post(App $a) {
if ($filesize <= 0) { if ($filesize <= 0) {
$msg = DI::l10n()->t('Sorry, maybe your upload is bigger than the PHP configuration allows') . EOL .(DI::l10n()->t('Or - did you try to upload an empty file?')); $msg = DI::l10n()->t('Sorry, maybe your upload is bigger than the PHP configuration allows') . EOL .(DI::l10n()->t('Or - did you try to upload an empty file?'));
@unlink($src);
if ($r_json) { if ($r_json) {
echo json_encode(['error' => $msg]); System::jsonExit(['error' => $msg]);
} else { } else {
notice($msg); notice($msg);
} }
@unlink($src);
exit(); exit();
} }
if ($maxfilesize && $filesize > $maxfilesize) { if ($maxfilesize && $filesize > $maxfilesize) {
$msg = DI::l10n()->t('File exceeds size limit of %s', Strings::formatBytes($maxfilesize)); $msg = DI::l10n()->t('File exceeds size limit of %s', Strings::formatBytes($maxfilesize));
@unlink($src);
if ($r_json) { if ($r_json) {
echo json_encode(['error' => $msg]); System::jsonExit(['error' => $msg]);
} else { } else {
echo $msg . EOL; echo $msg . EOL;
} }
@unlink($src);
exit(); exit();
} }
@ -120,7 +118,7 @@ function wall_attach_post(App $a) {
if ($newid === false) { if ($newid === false) {
$msg = DI::l10n()->t('File upload failed.'); $msg = DI::l10n()->t('File upload failed.');
if ($r_json) { if ($r_json) {
echo json_encode(['error' => $msg]); System::jsonExit(['error' => $msg]);
} else { } else {
echo $msg . EOL; echo $msg . EOL;
} }
@ -128,8 +126,7 @@ function wall_attach_post(App $a) {
} }
if ($r_json) { if ($r_json) {
echo json_encode(['ok' => true, 'id' => $newid]); System::jsonExit(['ok' => true, 'id' => $newid]);
exit();
} }
$lf = "\n"; $lf = "\n";

View File

@ -28,6 +28,7 @@
use Friendica\App; use Friendica\App;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Photo; use Friendica\Model\Photo;
@ -50,8 +51,7 @@ function wall_upload_post(App $a, $desktopmode = true)
$user = DBA::selectFirst('owner-view', ['id', 'uid', 'nickname', 'page-flags'], ['nickname' => $nick, 'blocked' => false]); $user = DBA::selectFirst('owner-view', ['id', 'uid', 'nickname', 'page-flags'], ['nickname' => $nick, 'blocked' => false]);
if (!DBA::isResult($user)) { if (!DBA::isResult($user)) {
if ($r_json) { if ($r_json) {
echo json_encode(['error' => DI::l10n()->t('Invalid request.')]); System::jsonExit(['error' => DI::l10n()->t('Invalid request.')]);
exit();
} }
return; return;
} }
@ -60,8 +60,7 @@ function wall_upload_post(App $a, $desktopmode = true)
} }
} else { } else {
if ($r_json) { if ($r_json) {
echo json_encode(['error' => DI::l10n()->t('Invalid request.')]); System::jsonExit(['error' => DI::l10n()->t('Invalid request.')]);
exit();
} }
return; return;
} }
@ -87,8 +86,7 @@ function wall_upload_post(App $a, $desktopmode = true)
if (!$can_post) { if (!$can_post) {
if ($r_json) { if ($r_json) {
echo json_encode(['error' => DI::l10n()->t('Permission denied.')]); System::jsonExit(['error' => DI::l10n()->t('Permission denied.')]);
exit();
} }
notice(DI::l10n()->t('Permission denied.')); notice(DI::l10n()->t('Permission denied.'));
exit(); exit();
@ -96,7 +94,7 @@ function wall_upload_post(App $a, $desktopmode = true)
if (empty($_FILES['userfile']) && empty($_FILES['media'])) { if (empty($_FILES['userfile']) && empty($_FILES['media'])) {
if ($r_json) { if ($r_json) {
echo json_encode(['error' => DI::l10n()->t('Invalid request.')]); System::jsonExit(['error' => DI::l10n()->t('Invalid request.')]);
} }
exit(); exit();
} }
@ -147,8 +145,7 @@ function wall_upload_post(App $a, $desktopmode = true)
if ($src == "") { if ($src == "") {
if ($r_json) { if ($r_json) {
echo json_encode(['error' => DI::l10n()->t('Invalid request.')]); System::jsonExit(['error' => DI::l10n()->t('Invalid request.')]);
exit();
} }
notice(DI::l10n()->t('Invalid request.')); notice(DI::l10n()->t('Invalid request.'));
exit(); exit();
@ -164,12 +161,12 @@ function wall_upload_post(App $a, $desktopmode = true)
if (!$Image->isValid()) { if (!$Image->isValid()) {
$msg = DI::l10n()->t('Unable to process image.'); $msg = DI::l10n()->t('Unable to process image.');
@unlink($src);
if ($r_json) { if ($r_json) {
echo json_encode(['error' => $msg]); System::jsonExit(['error' => $msg]);
} else { } else {
echo $msg. EOL; echo $msg. EOL;
} }
@unlink($src);
exit(); exit();
} }
@ -202,12 +199,12 @@ function wall_upload_post(App $a, $desktopmode = true)
if ($filesize > $maximagesize) { if ($filesize > $maximagesize) {
Logger::notice('Image size is too big', ['size' => $filesize, 'max' => $maximagesize]); Logger::notice('Image size is too big', ['size' => $filesize, 'max' => $maximagesize]);
$msg = DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize)); $msg = DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize));
@unlink($src);
if ($r_json) { if ($r_json) {
echo json_encode(['error' => $msg]); System::jsonExit(['error' => $msg]);
} else { } else {
echo $msg. EOL; echo $msg. EOL;
} }
@unlink($src);
exit(); exit();
} }
} }
@ -228,7 +225,7 @@ function wall_upload_post(App $a, $desktopmode = true)
if (!$r) { if (!$r) {
$msg = DI::l10n()->t('Image upload failed.'); $msg = DI::l10n()->t('Image upload failed.');
if ($r_json) { if ($r_json) {
echo json_encode(['error' => $msg]); System::jsonExit(['error' => $msg]);
} else { } else {
echo $msg. EOL; echo $msg. EOL;
} }
@ -255,8 +252,7 @@ function wall_upload_post(App $a, $desktopmode = true)
$photo = Photo::selectFirst(['id', 'datasize', 'width', 'height', 'type'], ['resource-id' => $resource_id], ['order' => ['width']]); $photo = Photo::selectFirst(['id', 'datasize', 'width', 'height', 'type'], ['resource-id' => $resource_id], ['order' => ['width']]);
if (!$photo) { if (!$photo) {
if ($r_json) { if ($r_json) {
echo json_encode(['error' => '']); System::jsonExit(['error' => '']);
exit();
} }
return false; return false;
} }
@ -272,8 +268,7 @@ function wall_upload_post(App $a, $desktopmode = true)
$picture["preview"] = DI::baseUrl() . "/photo/{$resource_id}-{$smallest}." . $Image->getExt(); $picture["preview"] = DI::baseUrl() . "/photo/{$resource_id}-{$smallest}." . $Image->getExt();
if ($r_json) { if ($r_json) {
echo json_encode(['picture' => $picture]); System::jsonExit(['picture' => $picture]);
exit();
} }
Logger::info("upload done"); Logger::info("upload done");
return $picture; return $picture;
@ -282,8 +277,7 @@ function wall_upload_post(App $a, $desktopmode = true)
Logger::info("upload done"); Logger::info("upload done");
if ($r_json) { if ($r_json) {
echo json_encode(['ok' => true]); System::jsonExit(['ok' => true]);
exit();
} }
echo "\n\n" . '[url=' . DI::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $resource_id . '][img]' . DI::baseUrl() . "/photo/{$resource_id}-{$smallest}.".$Image->getExt()."[/img][/url]\n\n"; echo "\n\n" . '[url=' . DI::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $resource_id . '][img]' . DI::baseUrl() . "/photo/{$resource_id}-{$smallest}.".$Image->getExt()."[/img][/url]\n\n";

View File

@ -339,7 +339,7 @@ class System
* @param integer $options JSON options * @param integer $options JSON options
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function jsonExit($x, $content_type = 'application/json', int $options = 0) { public static function jsonExit($x, $content_type = 'application/json', int $options = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT) {
DI::apiResponse()->setType(Response::TYPE_JSON, $content_type); DI::apiResponse()->setType(Response::TYPE_JSON, $content_type);
DI::apiResponse()->addContent(json_encode($x, $options)); DI::apiResponse()->addContent(json_encode($x, $options));
DI::page()->exit(DI::apiResponse()->generate()); DI::page()->exit(DI::apiResponse()->generate());

View File

@ -22,6 +22,7 @@
namespace Friendica\Module; namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\System;
/** /**
* Static definition for the Firefox Account Manager * Static definition for the Firefox Account Manager
@ -78,7 +79,6 @@ class AccountManagementControlDocument extends BaseModule
], ],
]; ];
echo json_encode($output); System::jsonExit($output);
exit();
} }
} }

View File

@ -44,7 +44,8 @@ class Featured extends BaseModule
$page = $request['page'] ?? null; $page = $request['page'] ?? null;
$outbox = ActivityPub\Transmitter::getFeatured($owner, $page); $featured = ActivityPub\Transmitter::getFeatured($owner, $page);
System::jsonExit($outbox, 'application/activity+json');
System::jsonExit($featured, 'application/activity+json');
} }
} }

View File

@ -22,6 +22,7 @@
namespace Friendica\Module\ActivityPub; namespace Friendica\Module\ActivityPub;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\System;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Protocol\ActivityPub; use Friendica\Protocol\ActivityPub;
@ -48,8 +49,6 @@ class Followers extends BaseModule
$followers = ActivityPub\Transmitter::getContacts($owner, [Contact::FOLLOWER, Contact::FRIEND], 'followers', $page, (string)HTTPSignature::getSigner('', $_SERVER)); $followers = ActivityPub\Transmitter::getContacts($owner, [Contact::FOLLOWER, Contact::FRIEND], 'followers', $page, (string)HTTPSignature::getSigner('', $_SERVER));
header('Content-Type: application/activity+json'); System::jsonExit($followers, 'application/activity+json');
echo json_encode($followers);
exit();
} }
} }

View File

@ -22,6 +22,7 @@
namespace Friendica\Module\ActivityPub; namespace Friendica\Module\ActivityPub;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\System;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Protocol\ActivityPub; use Friendica\Protocol\ActivityPub;
@ -46,8 +47,6 @@ class Following extends BaseModule
$following = ActivityPub\Transmitter::getContacts($owner, [Contact::SHARING, Contact::FRIEND], 'following', $page); $following = ActivityPub\Transmitter::getContacts($owner, [Contact::SHARING, Contact::FRIEND], 'following', $page);
header('Content-Type: application/activity+json'); System::jsonExit($following, 'application/activity+json');
echo json_encode($following);
exit();
} }
} }

View File

@ -50,7 +50,7 @@ class Inbox extends BaseModule
$filename = 'failed-activitypub'; $filename = 'failed-activitypub';
} }
$tempfile = tempnam(System::getTempPath(), $filename); $tempfile = tempnam(System::getTempPath(), $filename);
file_put_contents($tempfile, json_encode(['parameters' => $this->parameters, 'header' => $_SERVER, 'body' => $postdata], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); file_put_contents($tempfile, json_encode(['parameters' => $this->parameters, 'header' => $_SERVER, 'body' => $postdata], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
Logger::notice('Incoming message stored', ['file' => $tempfile]); Logger::notice('Incoming message stored', ['file' => $tempfile]);
} }

View File

@ -31,7 +31,6 @@ use Friendica\Model\Item;
use Friendica\Model\Post; use Friendica\Model\Post;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
use Friendica\Protocol\ActivityPub; use Friendica\Protocol\ActivityPub;
use Friendica\Security\PermissionSet\Repository\PermissionSet;
use Friendica\Util\HTTPSignature; use Friendica\Util\HTTPSignature;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -130,6 +129,7 @@ class Objects extends BaseModule
// Relaxed CORS header for public items // Relaxed CORS header for public items
header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Origin: *');
System::jsonExit($data, 'application/activity+json'); System::jsonExit($data, 'application/activity+json');
} }
} }

View File

@ -22,6 +22,7 @@
namespace Friendica\Module\ActivityPub; namespace Friendica\Module\ActivityPub;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\System;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Protocol\ActivityPub; use Friendica\Protocol\ActivityPub;
use Friendica\Util\HTTPSignature; use Friendica\Util\HTTPSignature;
@ -46,8 +47,7 @@ class Outbox extends BaseModule
$requester = HTTPSignature::getSigner('', $_SERVER); $requester = HTTPSignature::getSigner('', $_SERVER);
$outbox = ActivityPub\Transmitter::getOutbox($owner, $page, $requester); $outbox = ActivityPub\Transmitter::getOutbox($owner, $page, $requester);
header('Content-Type: application/activity+json');
echo json_encode($outbox); System::jsonExit($outbox, 'application/activity+json');
exit();
} }
} }

View File

@ -21,6 +21,7 @@
namespace Friendica\Module\Events; namespace Friendica\Module\Events;
use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Event; use Friendica\Model\Event;
@ -94,9 +95,7 @@ class Json extends \Friendica\BaseModule
$events = self::map($events); $events = self::map($events);
} }
header('Content-Type: application/json'); System::jsonExit($events);
echo json_encode($events);
exit();
} }
private static function map(array $events): array private static function map(array $events): array

View File

@ -182,8 +182,6 @@ class Friendica extends BaseModule
'no_scrape_url' => DI::baseUrl()->get() . '/noscrape', 'no_scrape_url' => DI::baseUrl()->get() . '/noscrape',
]; ];
header('Content-type: application/json; charset=utf-8'); System::jsonExit($data);
echo json_encode($data);
exit();
} }
} }

View File

@ -27,6 +27,7 @@ use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\Search; use Friendica\Core\Search;
use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
@ -61,8 +62,7 @@ class Acl extends BaseModule
$o = self::regularContactSearch($type); $o = self::regularContactSearch($type);
} }
echo json_encode($o); System::jsonExit($o);
exit;
} }
private static function globalContactSearch() private static function globalContactSearch()

View File

@ -26,6 +26,7 @@ use Friendica\BaseModule;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Network\HTTPException\NotFoundException; use Friendica\Network\HTTPException\NotFoundException;
use Friendica\Util\Profiler; use Friendica\Util\Profiler;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
@ -78,9 +79,7 @@ class Statistics extends BaseModule
'services' => $services, 'services' => $services,
], $services); ], $services);
header("Content-Type: application/json");
echo json_encode($statistics, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
$this->logger->debug("statistics.", ['statistics' => $statistics]); $this->logger->debug("statistics.", ['statistics' => $statistics]);
exit(); System::jsonExit($statistics);
} }
} }

View File

@ -22,6 +22,7 @@
namespace Friendica\Module; namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\System;
use Friendica\Core\Theme; use Friendica\Core\Theme;
/** /**
@ -40,7 +41,7 @@ class ThemeDetails extends BaseModule
$version = $info['version'] ?? ''; $version = $info['version'] ?? '';
$credits = $info['credits'] ?? ''; $credits = $info['credits'] ?? '';
echo json_encode([ System::jsonExit([
'img' => Theme::getScreenshot($theme), 'img' => Theme::getScreenshot($theme),
'desc' => $description, 'desc' => $description,
'version' => $version, 'version' => $version,

View File

@ -22,6 +22,7 @@
namespace Friendica\Module\WellKnown; namespace Friendica\Module\WellKnown;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\System;
use Friendica\DI; use Friendica\DI;
/** /**
@ -51,8 +52,6 @@ class NodeInfo extends BaseModule
] ]
]; ];
header('Content-type: application/json; charset=utf-8'); System::jsonExit($nodeinfo);
echo json_encode($nodeinfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
exit;
} }
} }

View File

@ -22,6 +22,7 @@
namespace Friendica\Module\WellKnown; namespace Friendica\Module\WellKnown;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\System;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Search; use Friendica\Model\Search;
use Friendica\Protocol\Relay; use Friendica\Protocol\Relay;
@ -76,8 +77,6 @@ class XSocialRelay extends BaseModule
$relay['protocols']['diaspora'] = ['receive' => DI::baseUrl()->get() . '/receive/public']; $relay['protocols']['diaspora'] = ['receive' => DI::baseUrl()->get() . '/receive/public'];
} }
header('Content-type: application/json; charset=utf-8'); System::jsonExit($relay);
echo json_encode($relay, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
exit;
} }
} }

View File

@ -802,7 +802,7 @@ class Receiver
} }
$tempfile = tempnam(System::getTempPath(), $file); $tempfile = tempnam(System::getTempPath(), $file);
file_put_contents($tempfile, json_encode(['activity' => $activity, 'body' => $body, 'uid' => $uid, 'trust_source' => $trust_source, 'push' => $push, 'signer' => $signer, 'object_data' => $object_data], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); file_put_contents($tempfile, json_encode(['activity' => $activity, 'body' => $body, 'uid' => $uid, 'trust_source' => $trust_source, 'push' => $push, 'signer' => $signer, 'object_data' => $object_data], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
Logger::notice('Unknown activity stored', ['type' => $type, 'object_type' => $object_data['object_type'], $object_data['object_object_type'] ?? '', 'file' => $tempfile]); Logger::notice('Unknown activity stored', ['type' => $type, 'object_type' => $object_data['object_type'], $object_data['object_object_type'] ?? '', 'file' => $tempfile]);
} }