mirror of
https://github.com/friendica/friendica
synced 2025-04-19 10:30:10 +00:00
Unified JSON exit
This commit is contained in:
parent
344e12c4fc
commit
d15023fe4b
21 changed files with 61 additions and 80 deletions
|
@ -22,6 +22,7 @@
|
|||
namespace Friendica\Module;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\System;
|
||||
|
||||
/**
|
||||
* Static definition for the Firefox Account Manager
|
||||
|
@ -78,7 +79,6 @@ class AccountManagementControlDocument extends BaseModule
|
|||
],
|
||||
];
|
||||
|
||||
echo json_encode($output);
|
||||
exit();
|
||||
System::jsonExit($output);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,8 @@ class Featured extends BaseModule
|
|||
|
||||
$page = $request['page'] ?? null;
|
||||
|
||||
$outbox = ActivityPub\Transmitter::getFeatured($owner, $page);
|
||||
System::jsonExit($outbox, 'application/activity+json');
|
||||
$featured = ActivityPub\Transmitter::getFeatured($owner, $page);
|
||||
|
||||
System::jsonExit($featured, 'application/activity+json');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
namespace Friendica\Module\ActivityPub;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\User;
|
||||
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));
|
||||
|
||||
header('Content-Type: application/activity+json');
|
||||
echo json_encode($followers);
|
||||
exit();
|
||||
System::jsonExit($followers, 'application/activity+json');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
namespace Friendica\Module\ActivityPub;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
|
@ -46,8 +47,6 @@ class Following extends BaseModule
|
|||
|
||||
$following = ActivityPub\Transmitter::getContacts($owner, [Contact::SHARING, Contact::FRIEND], 'following', $page);
|
||||
|
||||
header('Content-Type: application/activity+json');
|
||||
echo json_encode($following);
|
||||
exit();
|
||||
System::jsonExit($following, 'application/activity+json');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ class Inbox extends BaseModule
|
|||
$filename = 'failed-activitypub';
|
||||
}
|
||||
$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]);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ use Friendica\Model\Item;
|
|||
use Friendica\Model\Post;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Security\PermissionSet\Repository\PermissionSet;
|
||||
use Friendica\Util\HTTPSignature;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Strings;
|
||||
|
@ -130,6 +129,7 @@ class Objects extends BaseModule
|
|||
|
||||
// Relaxed CORS header for public items
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
|
||||
System::jsonExit($data, 'application/activity+json');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
namespace Friendica\Module\ActivityPub;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Util\HTTPSignature;
|
||||
|
@ -46,8 +47,7 @@ class Outbox extends BaseModule
|
|||
|
||||
$requester = HTTPSignature::getSigner('', $_SERVER);
|
||||
$outbox = ActivityPub\Transmitter::getOutbox($owner, $page, $requester);
|
||||
header('Content-Type: application/activity+json');
|
||||
echo json_encode($outbox);
|
||||
exit();
|
||||
|
||||
System::jsonExit($outbox, 'application/activity+json');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
namespace Friendica\Module\Events;
|
||||
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Event;
|
||||
|
@ -94,9 +95,7 @@ class Json extends \Friendica\BaseModule
|
|||
$events = self::map($events);
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($events);
|
||||
exit();
|
||||
System::jsonExit($events);
|
||||
}
|
||||
|
||||
private static function map(array $events): array
|
||||
|
|
|
@ -182,8 +182,6 @@ class Friendica extends BaseModule
|
|||
'no_scrape_url' => DI::baseUrl()->get() . '/noscrape',
|
||||
];
|
||||
|
||||
header('Content-type: application/json; charset=utf-8');
|
||||
echo json_encode($data);
|
||||
exit();
|
||||
System::jsonExit($data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ use Friendica\Core\Hook;
|
|||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Search;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -61,8 +62,7 @@ class Acl extends BaseModule
|
|||
$o = self::regularContactSearch($type);
|
||||
}
|
||||
|
||||
echo json_encode($o);
|
||||
exit;
|
||||
System::jsonExit($o);
|
||||
}
|
||||
|
||||
private static function globalContactSearch()
|
||||
|
|
|
@ -26,6 +26,7 @@ use Friendica\BaseModule;
|
|||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Network\HTTPException\NotFoundException;
|
||||
use Friendica\Util\Profiler;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
@ -78,9 +79,7 @@ class Statistics extends BaseModule
|
|||
'services' => $services,
|
||||
], $services);
|
||||
|
||||
header("Content-Type: application/json");
|
||||
echo json_encode($statistics, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
||||
$this->logger->debug("statistics.", ['statistics' => $statistics]);
|
||||
exit();
|
||||
System::jsonExit($statistics);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
namespace Friendica\Module;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Theme;
|
||||
|
||||
/**
|
||||
|
@ -40,7 +41,7 @@ class ThemeDetails extends BaseModule
|
|||
$version = $info['version'] ?? '';
|
||||
$credits = $info['credits'] ?? '';
|
||||
|
||||
echo json_encode([
|
||||
System::jsonExit([
|
||||
'img' => Theme::getScreenshot($theme),
|
||||
'desc' => $description,
|
||||
'version' => $version,
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
namespace Friendica\Module\WellKnown;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
|
||||
/**
|
||||
|
@ -51,8 +52,6 @@ class NodeInfo extends BaseModule
|
|||
]
|
||||
];
|
||||
|
||||
header('Content-type: application/json; charset=utf-8');
|
||||
echo json_encode($nodeinfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
||||
exit;
|
||||
System::jsonExit($nodeinfo);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
namespace Friendica\Module\WellKnown;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Search;
|
||||
use Friendica\Protocol\Relay;
|
||||
|
@ -76,8 +77,6 @@ class XSocialRelay extends BaseModule
|
|||
$relay['protocols']['diaspora'] = ['receive' => DI::baseUrl()->get() . '/receive/public'];
|
||||
}
|
||||
|
||||
header('Content-type: application/json; charset=utf-8');
|
||||
echo json_encode($relay, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
||||
exit;
|
||||
System::jsonExit($relay);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue