cleanup export file disposition

This commit is contained in:
Mike Macgirvin 2024-06-30 20:59:39 +10:00
parent c648458151
commit 92e2271268

View file

@ -34,20 +34,23 @@ class Uexport extends Controller
} }
header('content-type: application/json'); header('content-type: application/json');
header('Content-Disposition: attachment; filename="' . $channel['channel_address'] . (($year) ? '-' . $year : '') . (($month) ? '-' . $month : '') . (($_REQUEST['sections']) ? '-' . $_REQUEST['sections'] : '') . '.json"');
$flags = JSON_INVALID_UTF8_SUBSTITUTE; $flags = JSON_INVALID_UTF8_SUBSTITUTE;
if (argc() > 1 && argv(1) === 'activitypub') { if (argc() > 1 && argv(1) === 'activitypub') {
header('Content-Disposition: attachment; filename="' . $channel['channel_address'] . '.did' . '.json"');
echo json_encode(Activity::actorEncode($channel, extended: true, activitypub: true, export: true, legacy: false), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); echo json_encode(Activity::actorEncode($channel, extended: true, activitypub: true, export: true, legacy: false), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
killme(); killme();
} }
if (argc() > 1 && argv(1) === 'identity-key') { if (argc() > 1 && argv(1) === 'identity-key') {
echo (new Multibase())->secretKey($channel['channel_eprvkey']); header('Content-Disposition: attachment; filename="' . $channel['channel_address'] . '.identity-key.txt"');
echo json_encode([ 'privateKeyMultibase' => (new Multibase())->secretKey($channel['channel_eprvkey'])], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
killme(); killme();
} }
header('Content-Disposition: attachment; filename="' . $channel['channel_address'] . (($year) ? '-' . $year : '') . (($month) ? '-' . $month : '') . (($_REQUEST['sections']) ? '-' . $_REQUEST['sections'] : '') . '.json"');
if ($year) { if ($year) {
echo json_encode(Channel::export_year(local_channel(), $year, $month), $flags); echo json_encode(Channel::export_year(local_channel(), $year, $month), $flags);
killme(); killme();