Move System::jsonExit to BaseModule->jsonExit
- This will ensure headers set in BaseModule->run will be carried in jsonExit scenarios - Deprecate jsonExit() method in Core\System
This commit is contained in:
parent
e424b7bacb
commit
81279dad9e
|
@ -495,4 +495,19 @@ abstract class BaseModule implements ICanHandleRequests
|
|||
|
||||
$this->httpExit($content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the response using JSON to encode the content
|
||||
*
|
||||
* @param mixed $content
|
||||
* @param string $content_type
|
||||
* @param int $options A combination of json_encode() binary flags
|
||||
* @return void
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
* @see json_encode()
|
||||
*/
|
||||
public function jsonExit($content, string $content_type = 'application/json', int $options = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)
|
||||
{
|
||||
$this->httpExit(json_encode($content, $options), ICanCreateResponses::TYPE_JSON, $content_type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -392,14 +392,12 @@ class System
|
|||
* @param mixed $content The input content
|
||||
* @param string $content_type Type of the input (Default: 'application/json')
|
||||
* @param integer $options JSON options
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws InternalServerErrorException
|
||||
* @deprecated since 2023.09 Use BaseModule->jsonExit instead
|
||||
*/
|
||||
public static function jsonExit($content, $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()->addContent(json_encode($content, $options));
|
||||
self::echoResponse(DI::apiResponse()->generate());
|
||||
|
||||
self::exit();
|
||||
public static function jsonExit($content, string $content_type = 'application/json', int $options = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)
|
||||
{
|
||||
self::httpExit(json_encode($content, $options), Response::TYPE_JSON, $content_type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -79,6 +79,6 @@ class AccountManagementControlDocument extends BaseModule
|
|||
],
|
||||
];
|
||||
|
||||
System::jsonExit($output);
|
||||
$this->jsonExit($output);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,6 @@ class Featured extends BaseModule
|
|||
|
||||
$featured = ActivityPub\Transmitter::getFeatured($owner, $page);
|
||||
|
||||
System::jsonExit($featured, 'application/activity+json');
|
||||
$this->jsonExit($featured, 'application/activity+json');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,6 @@ class Followers extends BaseModule
|
|||
|
||||
$followers = ActivityPub\Transmitter::getContacts($owner, [Contact::FOLLOWER, Contact::FRIEND], 'followers', $page, (string)HTTPSignature::getSigner('', $_SERVER));
|
||||
|
||||
System::jsonExit($followers, 'application/activity+json');
|
||||
$this->jsonExit($followers, 'application/activity+json');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,6 @@ class Following extends BaseModule
|
|||
|
||||
$following = ActivityPub\Transmitter::getContacts($owner, [Contact::SHARING, Contact::FRIEND], 'following', $page);
|
||||
|
||||
System::jsonExit($following, 'application/activity+json');
|
||||
$this->jsonExit($following, 'application/activity+json');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ class Inbox extends BaseApi
|
|||
$inbox = ActivityPub\ClientToServer::getPublicInbox($uid, $page, $request['max_id'] ?? null);
|
||||
}
|
||||
|
||||
System::jsonExit($inbox, 'application/activity+json');
|
||||
$this->jsonExit($inbox, 'application/activity+json');
|
||||
}
|
||||
|
||||
protected function post(array $request = [])
|
||||
|
|
|
@ -130,6 +130,6 @@ class Objects extends BaseModule
|
|||
// Relaxed CORS header for public items
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
|
||||
System::jsonExit($data, 'application/activity+json');
|
||||
$this->jsonExit($data, 'application/activity+json');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ class Outbox extends BaseApi
|
|||
|
||||
$outbox = ActivityPub\ClientToServer::getOutbox($owner, $uid, $page, $request['max_id'] ?? null, HTTPSignature::getSigner('', $_SERVER));
|
||||
|
||||
System::jsonExit($outbox, 'application/activity+json');
|
||||
$this->jsonExit($outbox, 'application/activity+json');
|
||||
}
|
||||
|
||||
protected function post(array $request = [])
|
||||
|
@ -79,6 +79,6 @@ class Outbox extends BaseApi
|
|||
throw new \Friendica\Network\HTTPException\BadRequestException();
|
||||
}
|
||||
|
||||
System::jsonExit(ActivityPub\ClientToServer::processActivity($activity, $uid, self::getCurrentApplication() ?? []));
|
||||
$this->jsonExit(ActivityPub\ClientToServer::processActivity($activity, $uid, self::getCurrentApplication() ?? []));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,6 +100,6 @@ class Whoami extends BaseApi
|
|||
];
|
||||
|
||||
$data['generator'] = ActivityPub\Transmitter::getService();
|
||||
System::jsonExit($data, 'application/activity+json');
|
||||
$this->jsonExit($data, 'application/activity+json');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,6 @@ class Dislike extends BaseApi
|
|||
|
||||
Item::performActivity($item['id'], 'dislike', $uid);
|
||||
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes())->toArray());
|
||||
$this->jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes())->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,6 @@ class DislikedBy extends BaseApi
|
|||
$accounts[] = DI::mstdnAccount()->createFromContactId($activity['author-id'], $uid);
|
||||
}
|
||||
|
||||
System::jsonExit($accounts);
|
||||
$this->jsonExit($accounts);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,6 @@ class Undislike extends BaseApi
|
|||
|
||||
Item::performActivity($item['id'], 'undislike', $uid);
|
||||
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes())->toArray());
|
||||
$this->jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes())->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,6 +58,6 @@ class Accounts extends BaseApi
|
|||
}
|
||||
|
||||
$account = DI::mstdnAccount()->createFromContactId($id, $uid);
|
||||
System::jsonExit($account);
|
||||
$this->jsonExit($account);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,6 @@ class Block extends BaseApi
|
|||
}
|
||||
}
|
||||
|
||||
System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
|
||||
$this->jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,6 @@ class FeaturedTags extends BaseApi
|
|||
{
|
||||
self::checkAllowedScope(self::SCOPE_READ);
|
||||
|
||||
System::jsonExit([]);
|
||||
$this->jsonExit([]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,6 @@ class Follow extends BaseApi
|
|||
|
||||
Contact::update(['notify_new_posts' => $request['notify']], ['id' => $result['cid']]);
|
||||
|
||||
System::jsonExit(DI::mstdnRelationship()->createFromContactId($result['cid'], $uid)->toArray());
|
||||
$this->jsonExit(DI::mstdnRelationship()->createFromContactId($result['cid'], $uid)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,6 +115,6 @@ class Followers extends BaseApi
|
|||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
System::jsonExit($accounts);
|
||||
$this->jsonExit($accounts);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,6 +115,6 @@ class Following extends BaseApi
|
|||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
System::jsonExit($accounts);
|
||||
$this->jsonExit($accounts);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,6 @@ class IdentityProofs extends BaseApi
|
|||
{
|
||||
self::checkAllowedScope(self::SCOPE_READ);
|
||||
|
||||
System::jsonExit([]);
|
||||
$this->jsonExit([]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,6 +60,6 @@ class Lists extends BaseApi
|
|||
DBA::close($circles);
|
||||
}
|
||||
|
||||
System::jsonExit($lists);
|
||||
$this->jsonExit($lists);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,6 @@ class Mute extends BaseApi
|
|||
|
||||
Contact\User::setIgnored($this->parameters['id'], $uid, true);
|
||||
|
||||
System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
|
||||
$this->jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,6 @@ class Note extends BaseApi
|
|||
|
||||
Contact::update(['info' => $request['comment']], ['id' => $cdata['user']]);
|
||||
|
||||
System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
|
||||
$this->jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,6 @@ class Relationships extends BaseApi
|
|||
$relationships[] = DI::mstdnRelationship()->createFromContactId($id, $uid);
|
||||
}
|
||||
|
||||
System::jsonExit($relationships);
|
||||
$this->jsonExit($relationships);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,6 +67,6 @@ class Search extends BaseApi
|
|||
DBA::close($contacts);
|
||||
}
|
||||
|
||||
System::jsonExit($accounts);
|
||||
$this->jsonExit($accounts);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,6 +122,6 @@ class Statuses extends BaseApi
|
|||
}
|
||||
|
||||
self::setLinkHeader($request['friendica_order'] != TimelineOrderByTypes::ID);
|
||||
System::jsonExit($statuses);
|
||||
$this->jsonExit($statuses);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,6 @@ class Unblock extends BaseApi
|
|||
|
||||
Contact\User::setBlocked($this->parameters['id'], $uid, false);
|
||||
|
||||
System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
|
||||
$this->jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,6 @@ class Unfollow extends BaseApi
|
|||
|
||||
Contact::unfollow($contact);
|
||||
|
||||
System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
|
||||
$this->jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,6 @@ class Unmute extends BaseApi
|
|||
|
||||
Contact\User::setIgnored($this->parameters['id'], $uid, false);
|
||||
|
||||
System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
|
||||
$this->jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,6 @@ class Announcements extends BaseApi
|
|||
self::checkAllowedScope(self::SCOPE_READ);
|
||||
|
||||
// @todo Possibly use the message from the pageheader addon for this
|
||||
System::jsonExit([]);
|
||||
$this->jsonExit([]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,6 +95,6 @@ class Apps extends BaseApi
|
|||
DI::mstdnError()->InternalError();
|
||||
}
|
||||
|
||||
System::jsonExit(DI::mstdnApplication()->createFromApplicationId(DBA::lastInsertId())->toArray());
|
||||
$this->jsonExit(DI::mstdnApplication()->createFromApplicationId(DBA::lastInsertId())->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,6 @@ class VerifyCredentials extends BaseApi
|
|||
DI::mstdnError()->Unauthorized();
|
||||
}
|
||||
|
||||
System::jsonExit(DI::mstdnApplication()->createFromApplicationId($application['id']));
|
||||
$this->jsonExit(DI::mstdnApplication()->createFromApplicationId($application['id']));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,6 +77,6 @@ class Blocks extends BaseApi
|
|||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
System::jsonExit($accounts);
|
||||
$this->jsonExit($accounts);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,6 +88,6 @@ class Bookmarks extends BaseApi
|
|||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
System::jsonExit($statuses);
|
||||
$this->jsonExit($statuses);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ class Conversations extends BaseApi
|
|||
DBA::delete('conv', ['id' => $this->parameters['id'], 'uid' => $uid]);
|
||||
DBA::delete('mail', ['convid' => $this->parameters['id'], 'uid' => $uid]);
|
||||
|
||||
System::jsonExit([]);
|
||||
$this->jsonExit([]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,6 +95,6 @@ class Conversations extends BaseApi
|
|||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
System::jsonExit($conversations);
|
||||
$this->jsonExit($conversations);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,6 @@ class Read extends BaseApi
|
|||
|
||||
DBA::update('mail', ['seen' => true], ['convid' => $this->parameters['id'], 'uid' => $uid]);
|
||||
|
||||
System::jsonExit(DI::mstdnConversation()->createFromConvId($this->parameters['id'])->toArray());
|
||||
$this->jsonExit(DI::mstdnConversation()->createFromConvId($this->parameters['id'])->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,6 @@ class CustomEmojis extends BaseApi
|
|||
{
|
||||
$emojis = DI::mstdnEmoji()->createCollectionFromSmilies(Smilies::getList());
|
||||
|
||||
System::jsonExit($emojis->getArrayCopy());
|
||||
$this->jsonExit($emojis->getArrayCopy());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,6 +68,6 @@ class Directory extends BaseApi
|
|||
}
|
||||
DBA::close($contacts);
|
||||
|
||||
System::jsonExit($accounts);
|
||||
$this->jsonExit($accounts);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,6 @@ class Endorsements extends BaseApi
|
|||
*/
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
System::jsonExit([]);
|
||||
$this->jsonExit([]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,6 +90,6 @@ class Favourited extends BaseApi
|
|||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
System::jsonExit($statuses);
|
||||
$this->jsonExit($statuses);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,6 @@ class Filters extends BaseApi
|
|||
{
|
||||
self::checkAllowedScope(self::SCOPE_READ);
|
||||
|
||||
System::jsonExit([]);
|
||||
$this->jsonExit([]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ class FollowRequests extends BaseApi
|
|||
throw new HTTPException\BadRequestException('Unexpected action parameter, expecting "authorize", "ignore" or "reject"');
|
||||
}
|
||||
|
||||
System::jsonExit($relationship);
|
||||
$this->jsonExit($relationship);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -115,6 +115,6 @@ class FollowRequests extends BaseApi
|
|||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
System::jsonExit($return);
|
||||
$this->jsonExit($return);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,6 +77,6 @@ class FollowedTags extends BaseApi
|
|||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
System::jsonExit($return);
|
||||
$this->jsonExit($return);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,6 +59,6 @@ class Instance extends BaseApi
|
|||
*/
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
System::jsonExit(new InstanceEntity($this->config, $this->baseUrl, $this->database, System::getRules()));
|
||||
$this->jsonExit(new InstanceEntity($this->config, $this->baseUrl, $this->database, System::getRules()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,6 @@ class Peers extends BaseApi
|
|||
}
|
||||
DBA::close($instances);
|
||||
|
||||
System::jsonExit($return);
|
||||
$this->jsonExit($return);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,6 @@ class Rules extends BaseApi
|
|||
*/
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
System::jsonExit(System::getRules());
|
||||
$this->jsonExit(System::getRules());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ class InstanceV2 extends BaseApi
|
|||
$contact = $this->buildContactInfo();
|
||||
$friendica_extensions = $this->buildFriendicaExtensionInfo();
|
||||
$rules = System::getRules();
|
||||
System::jsonExit(new InstanceEntity(
|
||||
$this->jsonExit(new InstanceEntity(
|
||||
$domain,
|
||||
$title,
|
||||
$version,
|
||||
|
|
|
@ -48,7 +48,7 @@ class Lists extends BaseApi
|
|||
DI::mstdnError()->InternalError();
|
||||
}
|
||||
|
||||
System::jsonExit([]);
|
||||
$this->jsonExit([]);
|
||||
}
|
||||
|
||||
protected function post(array $request = [])
|
||||
|
@ -71,7 +71,7 @@ class Lists extends BaseApi
|
|||
DI::mstdnError()->InternalError();
|
||||
}
|
||||
|
||||
System::jsonExit(DI::mstdnList()->createFromCircleId($id));
|
||||
$this->jsonExit(DI::mstdnList()->createFromCircleId($id));
|
||||
}
|
||||
|
||||
public function put(array $request = [])
|
||||
|
@ -111,6 +111,6 @@ class Lists extends BaseApi
|
|||
$lists = DI::mstdnList()->createFromCircleId($id);
|
||||
}
|
||||
|
||||
System::jsonExit($lists);
|
||||
$this->jsonExit($lists);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,6 +127,6 @@ class Accounts extends BaseApi
|
|||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
System::jsonExit($accounts);
|
||||
$this->jsonExit($accounts);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ class Markers extends BaseApi
|
|||
|
||||
$fields = ['last_read_id' => $last_read_id, 'version' => $version, 'updated_at' => DateTimeFormat::utcNow()];
|
||||
DBA::update('application-marker', $fields, $condition, true);
|
||||
System::jsonExit($this->fetchTimelines($application['id'], $uid));
|
||||
$this->jsonExit($this->fetchTimelines($application['id'], $uid));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,7 +73,7 @@ class Markers extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
$application = self::getCurrentApplication();
|
||||
|
||||
System::jsonExit($this->fetchTimelines($application['id'], $uid));
|
||||
$this->jsonExit($this->fetchTimelines($application['id'], $uid));
|
||||
}
|
||||
|
||||
private function fetchTimelines(int $application_id, int $uid)
|
||||
|
|
|
@ -58,7 +58,7 @@ class Media extends BaseApi
|
|||
|
||||
Logger::info('Uploaded photo', ['media' => $media]);
|
||||
|
||||
System::jsonExit(DI::mstdnAttachment()->createFromPhoto($media['id']));
|
||||
$this->jsonExit(DI::mstdnAttachment()->createFromPhoto($media['id']));
|
||||
}
|
||||
|
||||
public function put(array $request = [])
|
||||
|
@ -87,12 +87,12 @@ class Media extends BaseApi
|
|||
DI::mstdnError()->RecordNotFound();
|
||||
}
|
||||
Post\Media::updateById(['description' => $request['description']], $this->parameters['id']);
|
||||
System::jsonExit(DI::mstdnAttachment()->createFromId($this->parameters['id']));
|
||||
$this->jsonExit(DI::mstdnAttachment()->createFromId($this->parameters['id']));
|
||||
}
|
||||
|
||||
Photo::update(['desc' => $request['description']], ['resource-id' => $photo['resource-id']]);
|
||||
|
||||
System::jsonExit(DI::mstdnAttachment()->createFromPhoto($this->parameters['id']));
|
||||
$this->jsonExit(DI::mstdnAttachment()->createFromPhoto($this->parameters['id']));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -112,6 +112,6 @@ class Media extends BaseApi
|
|||
DI::mstdnError()->RecordNotFound();
|
||||
}
|
||||
|
||||
System::jsonExit(DI::mstdnAttachment()->createFromPhoto($id));
|
||||
$this->jsonExit(DI::mstdnAttachment()->createFromPhoto($id));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,6 +85,6 @@ class Mutes extends BaseApi
|
|||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
System::jsonExit($accounts);
|
||||
$this->jsonExit($accounts);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ class Notifications extends BaseApi
|
|||
$id = $this->parameters['id'];
|
||||
try {
|
||||
$notification = DI::notification()->selectOneForUser($uid, ['id' => $id]);
|
||||
System::jsonExit(DI::mstdnNotification()->createFromNotification($notification, self::appSupportsQuotes()));
|
||||
$this->jsonExit(DI::mstdnNotification()->createFromNotification($notification, self::appSupportsQuotes()));
|
||||
} catch (\Exception $e) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ class Notifications extends BaseApi
|
|||
|
||||
if ($request['summary']) {
|
||||
$count = DI::notification()->countForUser($uid, $condition);
|
||||
System::jsonExit(['count' => $count]);
|
||||
$this->jsonExit(['count' => $count]);
|
||||
} else {
|
||||
$mstdnNotifications = [];
|
||||
|
||||
|
@ -154,7 +154,7 @@ class Notifications extends BaseApi
|
|||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
System::jsonExit($mstdnNotifications);
|
||||
$this->jsonExit($mstdnNotifications);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,6 @@ class Clear extends BaseApi
|
|||
|
||||
DI::notification()->setAllDismissedForUser($uid);
|
||||
|
||||
System::jsonExit([]);
|
||||
$this->jsonExit([]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,6 @@ class Dismiss extends BaseApi
|
|||
$Notification->setDismissed();
|
||||
DI::notification()->save($Notification);
|
||||
|
||||
System::jsonExit([]);
|
||||
$this->jsonExit([]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,6 @@ class Polls extends BaseApi
|
|||
DI::mstdnError()->UnprocessableEntity();
|
||||
}
|
||||
|
||||
System::jsonExit(DI::mstdnPoll()->createFromId($this->parameters['id'], $uid));
|
||||
$this->jsonExit(DI::mstdnPoll()->createFromId($this->parameters['id'], $uid));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,6 +55,6 @@ class Preferences extends BaseApi
|
|||
|
||||
$preferences = new \Friendica\Object\Api\Mastodon\Preferences($visibility, $sensitive, $language, $media, $spoilers);
|
||||
|
||||
System::jsonExit($preferences);
|
||||
$this->jsonExit($preferences);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,6 +82,6 @@ class Reports extends BaseApi
|
|||
|
||||
$this->reportRepo->save($report);
|
||||
|
||||
System::jsonExit([]);
|
||||
$this->jsonExit([]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ class ScheduledStatuses extends BaseApi
|
|||
|
||||
Post\Delayed::deleteById($this->parameters['id']);
|
||||
|
||||
System::jsonExit([]);
|
||||
$this->jsonExit([]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,7 +68,7 @@ class ScheduledStatuses extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (isset($this->parameters['id'])) {
|
||||
System::jsonExit(DI::mstdnScheduledStatus()->createFromDelayedPostId($this->parameters['id'], $uid)->toArray());
|
||||
$this->jsonExit(DI::mstdnScheduledStatus()->createFromDelayedPostId($this->parameters['id'], $uid)->toArray());
|
||||
}
|
||||
|
||||
$request = $this->getRequest([
|
||||
|
@ -109,6 +109,6 @@ class ScheduledStatuses extends BaseApi
|
|||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
System::jsonExit($statuses);
|
||||
$this->jsonExit($statuses);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ class Search extends BaseApi
|
|||
$result['hashtags'] = self::searchHashtags($request['q'], $request['exclude_unreviewed'], $limit, $request['offset'], $this->parameters['version']);
|
||||
}
|
||||
|
||||
System::jsonExit($result);
|
||||
$this->jsonExit($result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -159,7 +159,7 @@ class Statuses extends BaseApi
|
|||
|
||||
Item::updateDisplayCache($post['uri-id']);
|
||||
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($post['uri-id'], $uid, self::appSupportsQuotes()));
|
||||
$this->jsonExit(DI::mstdnStatus()->createFromUriId($post['uri-id'], $uid, self::appSupportsQuotes()));
|
||||
}
|
||||
|
||||
protected function post(array $request = [])
|
||||
|
@ -299,14 +299,14 @@ class Statuses extends BaseApi
|
|||
if (empty($id)) {
|
||||
DI::mstdnError()->InternalError();
|
||||
}
|
||||
System::jsonExit(DI::mstdnScheduledStatus()->createFromDelayedPostId($id, $uid)->toArray());
|
||||
$this->jsonExit(DI::mstdnScheduledStatus()->createFromDelayedPostId($id, $uid)->toArray());
|
||||
}
|
||||
|
||||
$id = Item::insert($item, true);
|
||||
if (!empty($id)) {
|
||||
$item = Post::selectFirst(['uri-id'], ['id' => $id]);
|
||||
if (!empty($item['uri-id'])) {
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, self::appSupportsQuotes()));
|
||||
$this->jsonExit(DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, self::appSupportsQuotes()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -331,7 +331,7 @@ class Statuses extends BaseApi
|
|||
DI::mstdnError()->RecordNotFound();
|
||||
}
|
||||
|
||||
System::jsonExit([]);
|
||||
$this->jsonExit([]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -345,7 +345,7 @@ class Statuses extends BaseApi
|
|||
DI::mstdnError()->UnprocessableEntity();
|
||||
}
|
||||
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), false));
|
||||
$this->jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), false));
|
||||
}
|
||||
|
||||
private function getApp(): string
|
||||
|
|
|
@ -70,6 +70,6 @@ class Bookmark extends BaseApi
|
|||
// Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350
|
||||
$isReblog = $item['uri-id'] != $this->parameters['id'];
|
||||
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
$this->jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,6 @@ class Card extends BaseApi
|
|||
|
||||
$card = DI::mstdnCard()->createFromUriId($post['uri-id']);
|
||||
|
||||
System::jsonExit($card->toArray());
|
||||
$this->jsonExit($card->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ class Context extends BaseApi
|
|||
$statuses['descendants'][] = DI::mstdnStatus()->createFromUriId($descendant, $uid, $display_quotes);
|
||||
}
|
||||
|
||||
System::jsonExit($statuses);
|
||||
$this->jsonExit($statuses);
|
||||
}
|
||||
|
||||
private static function getParents(int $id, array $parents, array $list = [])
|
||||
|
|
|
@ -54,6 +54,6 @@ class Favourite extends BaseApi
|
|||
// Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350
|
||||
$isReblog = $item['uri-id'] != $this->parameters['id'];
|
||||
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
$this->jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,6 @@ class FavouritedBy extends BaseApi
|
|||
$accounts[] = DI::mstdnAccount()->createFromContactId($activity['author-id'], $uid);
|
||||
}
|
||||
|
||||
System::jsonExit($accounts);
|
||||
$this->jsonExit($accounts);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,6 +58,6 @@ class Mute extends BaseApi
|
|||
// Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350
|
||||
$isReblog = $item['uri-id'] != $this->parameters['id'];
|
||||
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
$this->jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,6 @@ class Pin extends BaseApi
|
|||
// Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350
|
||||
$isReblog = $item['uri-id'] != $this->parameters['id'];
|
||||
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(),$isReblog)->toArray());
|
||||
$this->jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(),$isReblog)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,6 @@ class Reblog extends BaseApi
|
|||
// Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350
|
||||
$isReblog = $item['uri-id'] != $this->parameters['id'];
|
||||
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
$this->jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,6 @@ class RebloggedBy extends BaseApi
|
|||
$accounts[] = DI::mstdnAccount()->createFromContactId($activity['author-id'], $uid);
|
||||
}
|
||||
|
||||
System::jsonExit($accounts);
|
||||
$this->jsonExit($accounts);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,6 @@ class Source extends BaseApi
|
|||
|
||||
$source = DI::mstdnStatusSource()->createFromUriId($id, $uid);
|
||||
|
||||
System::jsonExit($source->toArray());
|
||||
$this->jsonExit($source->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,6 +70,6 @@ class Unbookmark extends BaseApi
|
|||
// Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350
|
||||
$isReblog = $item['uri-id'] != $this->parameters['id'];
|
||||
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
$this->jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,6 @@ class Unfavourite extends BaseApi
|
|||
// Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350
|
||||
$isReblog = $item['uri-id'] != $this->parameters['id'];
|
||||
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
$this->jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,6 +58,6 @@ class Unmute extends BaseApi
|
|||
// Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350
|
||||
$isReblog = $item['uri-id'] != $this->parameters['id'];
|
||||
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
$this->jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,6 @@ class Unpin extends BaseApi
|
|||
// Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350
|
||||
$isReblog = $item['uri-id'] != $this->parameters['id'];
|
||||
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
$this->jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,6 +69,6 @@ class Unreblog extends BaseApi
|
|||
// Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350
|
||||
$isReblog = $item['uri-id'] != $this->parameters['id'];
|
||||
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
$this->jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,6 @@ class Suggestions extends BaseApi
|
|||
];
|
||||
}
|
||||
|
||||
System::jsonExit($accounts);
|
||||
$this->jsonExit($accounts);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,6 @@ class Tags extends BaseApi
|
|||
$following = DBA::exists('search', ['uid' => $uid, 'term' => '#' . $tag]);
|
||||
|
||||
$hashtag = new \Friendica\Object\Api\Mastodon\Tag($this->baseUrl, ['name' => $tag], [], $following);
|
||||
System::jsonExit($hashtag->toArray());
|
||||
$this->jsonExit($hashtag->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,6 @@ class Follow extends BaseApi
|
|||
}
|
||||
|
||||
$hashtag = new \Friendica\Object\Api\Mastodon\Tag($this->baseUrl, ['name' => ltrim($this->parameters['hashtag'])], [], true);
|
||||
System::jsonExit($hashtag->toArray());
|
||||
$this->jsonExit($hashtag->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,6 @@ class Unfollow extends BaseApi
|
|||
DBA::delete('search', $term);
|
||||
|
||||
$hashtag = new \Friendica\Object\Api\Mastodon\Tag($this->baseUrl, ['name' => ltrim($this->parameters['hashtag'])], [], false);
|
||||
System::jsonExit($hashtag->toArray());
|
||||
$this->jsonExit($hashtag->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,6 +86,6 @@ class Direct extends BaseApi
|
|||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
System::jsonExit($statuses);
|
||||
$this->jsonExit($statuses);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,6 +101,6 @@ class Home extends BaseApi
|
|||
|
||||
|
||||
self::setLinkHeader($request['friendica_order'] != TimelineOrderByTypes::ID);
|
||||
System::jsonExit($statuses);
|
||||
$this->jsonExit($statuses);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,6 +105,6 @@ class ListTimeline extends BaseApi
|
|||
}
|
||||
|
||||
self::setLinkHeader($request['friendica_order'] != TimelineOrderByTypes::ID);
|
||||
System::jsonExit($statuses);
|
||||
$this->jsonExit($statuses);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,6 +102,6 @@ class PublicTimeline extends BaseApi
|
|||
}
|
||||
|
||||
self::setLinkHeader($request['friendica_order'] != TimelineOrderByTypes::ID);
|
||||
System::jsonExit($statuses);
|
||||
$this->jsonExit($statuses);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -131,6 +131,6 @@ class Tag extends BaseApi
|
|||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
System::jsonExit($statuses);
|
||||
$this->jsonExit($statuses);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,6 +60,6 @@ class Links extends BaseApi
|
|||
self::setLinkHeaderByOffsetLimit($request['offset'], $request['limit']);
|
||||
}
|
||||
|
||||
System::jsonExit($trending);
|
||||
$this->jsonExit($trending);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,6 +67,6 @@ class Statuses extends BaseApi
|
|||
self::setLinkHeaderByOffsetLimit($request['offset'], $request['limit']);
|
||||
}
|
||||
|
||||
System::jsonExit($trending);
|
||||
$this->jsonExit($trending);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,6 +60,6 @@ class Tags extends BaseApi
|
|||
self::setLinkHeaderByOffsetLimit($request['offset'], $request['limit']);
|
||||
}
|
||||
|
||||
System::jsonExit($trending);
|
||||
$this->jsonExit($trending);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,6 +83,6 @@ class Ids extends ContactEndpoint
|
|||
|
||||
self::setLinkHeader();
|
||||
|
||||
System::jsonExit($return);
|
||||
$this->jsonExit($return);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,6 +114,6 @@ class Ids extends ContactEndpoint
|
|||
|
||||
self::setLinkHeader();
|
||||
|
||||
System::jsonExit($return);
|
||||
$this->jsonExit($return);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,6 +114,6 @@ class Ids extends ContactEndpoint
|
|||
|
||||
self::setLinkHeader();
|
||||
|
||||
System::jsonExit($return);
|
||||
$this->jsonExit($return);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ abstract class BaseNotifications extends BaseModule
|
|||
'page' => $pager->getPage(),
|
||||
];
|
||||
|
||||
System::jsonExit($notifications);
|
||||
$this->jsonExit($notifications);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -69,7 +69,7 @@ class Get extends \Friendica\BaseModule
|
|||
$events = Event::getListByDate($owner['uid'], $request['start'] ?? '', $request['end'] ?? '');
|
||||
}
|
||||
|
||||
System::jsonExit($events ? self::map($events) : []);
|
||||
$this->jsonExit($events ? self::map($events) : []);
|
||||
}
|
||||
|
||||
private static function map(array $events): array
|
||||
|
|
|
@ -132,7 +132,7 @@ class Circle extends BaseModule
|
|||
}
|
||||
|
||||
DI::sysmsg()->addInfo($message);
|
||||
System::jsonExit(['status' => 'OK', 'message' => $message]);
|
||||
$this->jsonExit(['status' => 'OK', 'message' => $message]);
|
||||
} catch (\Exception $e) {
|
||||
DI::sysmsg()->addNotice($e->getMessage());
|
||||
System::jsonError($e->getCode(), ['status' => 'error', 'message' => $e->getMessage()]);
|
||||
|
|
|
@ -142,7 +142,7 @@ class Friendica extends BaseModule
|
|||
$data = ActivityPub\Transmitter::getProfile(0);
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Cache-Control: max-age=23200, stale-while-revalidate=23200');
|
||||
System::jsonExit($data, 'application/activity+json');
|
||||
$this->jsonExit($data, 'application/activity+json');
|
||||
} catch (HTTPException\NotFoundException $e) {
|
||||
System::jsonError(404, ['error' => 'Record not found']);
|
||||
}
|
||||
|
@ -200,6 +200,6 @@ class Friendica extends BaseModule
|
|||
'no_scrape_url' => $this->baseUrl . '/noscrape',
|
||||
];
|
||||
|
||||
System::jsonExit($data);
|
||||
$this->jsonExit($data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ class Hashtag extends BaseModule
|
|||
$result = [];
|
||||
|
||||
if (empty($request['t'])) {
|
||||
System::jsonExit($result);
|
||||
$this->jsonExit($result);
|
||||
}
|
||||
|
||||
$taglist = DBA::select(
|
||||
|
@ -50,6 +50,6 @@ class Hashtag extends BaseModule
|
|||
}
|
||||
DBA::close($taglist);
|
||||
|
||||
System::jsonExit($result);
|
||||
$this->jsonExit($result);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,6 +89,6 @@ class Activity extends BaseModule
|
|||
'state' => 1,
|
||||
];
|
||||
|
||||
System::jsonExit($return);
|
||||
$this->jsonExit($return);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,6 +71,6 @@ class Follow extends BaseModule
|
|||
'state' => 1
|
||||
];
|
||||
|
||||
System::jsonExit($return);
|
||||
$this->jsonExit($return);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,6 +82,6 @@ class Ignore extends BaseModule
|
|||
'state' => $ignored,
|
||||
];
|
||||
|
||||
System::jsonExit($return);
|
||||
$this->jsonExit($return);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,6 +84,6 @@ class Pin extends BaseModule
|
|||
'state' => (int)$pinned,
|
||||
];
|
||||
|
||||
System::jsonExit($return);
|
||||
$this->jsonExit($return);
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user