mirror of
https://github.com/friendica/friendica
synced 2024-11-09 16:22:56 +00:00
Rename ApipResponse->exit* methods to better show their meaning
This commit is contained in:
parent
960171c4e0
commit
642baa1f2a
68 changed files with 88 additions and 88 deletions
|
@ -210,7 +210,7 @@ class ApiResponse extends Response
|
|||
|
||||
$this->setHeader(($this->server['SERVER_PROTOCOL'] ?? 'HTTP/1.1') . ' ' . $code . ' ' . $description);
|
||||
|
||||
$this->exit('status', ['status' => $error], $format);
|
||||
$this->addFormattedContent('status', ['status' => $error], $format);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -224,7 +224,7 @@ class ApiResponse extends Response
|
|||
* @return void
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function exit(string $root_element, array $data, string $format = null, int $cid = 0)
|
||||
public function addFormattedContent(string $root_element, array $data, string $format = null, int $cid = 0)
|
||||
{
|
||||
$format = $format ?? 'json';
|
||||
|
||||
|
@ -259,16 +259,16 @@ class ApiResponse extends Response
|
|||
}
|
||||
|
||||
/**
|
||||
* Wrapper around exit() for JSON only responses
|
||||
* Wrapper around addFormattedContent() for JSON only responses
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return void
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function exitWithJson(array $data)
|
||||
public function addJsonContent(array $data)
|
||||
{
|
||||
$this->exit('content', ['content' => $data], static::TYPE_JSON);
|
||||
$this->addFormattedContent('content', ['content' => $data], static::TYPE_JSON);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -60,7 +60,7 @@ class Activity extends BaseApi
|
|||
|
||||
if ($res) {
|
||||
$status_info = DI::twitterStatus()->createFromUriId($request['id'], $uid)->toArray();
|
||||
$this->response->exit('status', ['status' => $status_info], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('status', ['status' => $status_info], $this->parameters['extension'] ?? null);
|
||||
} else {
|
||||
$this->response->error(500, 'Error adding activity', '', $this->parameters['extension'] ?? null);
|
||||
}
|
||||
|
|
|
@ -82,6 +82,6 @@ class Create extends BaseApi
|
|||
|
||||
$result = ['success' => true, 'gid' => $gid, 'name' => $name, 'status' => $status, 'wrong users' => $errorusers];
|
||||
|
||||
$this->response->exit('group_create', ['$result' => $result], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('group_create', ['$result' => $result], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ class Delete extends BaseApi
|
|||
if ($ret) {
|
||||
// return success
|
||||
$success = ['success' => $ret, 'gid' => $request['gid'], 'name' => $request['name'], 'status' => 'deleted', 'wrong users' => []];
|
||||
$this->response->exit('group_delete', ['$result' => $success], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('group_delete', ['$result' => $success], $this->parameters['extension'] ?? null);
|
||||
} else {
|
||||
throw new BadRequestException('other API error');
|
||||
}
|
||||
|
|
|
@ -75,6 +75,6 @@ class Show extends BaseApi
|
|||
$grps[] = ['name' => $circle['name'], 'gid' => $circle['id'], $user_element => $users];
|
||||
}
|
||||
|
||||
$this->response->exit('group_update', ['group' => $grps], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('group_update', ['group' => $grps], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,6 +84,6 @@ class Update extends BaseApi
|
|||
// return success message incl. missing users in array
|
||||
$status = ($erroraddinguser ? 'missing user' : 'ok');
|
||||
$success = ['success' => true, 'gid' => $gid, 'name' => $name, 'status' => $status, 'wrong users' => $errorusers];
|
||||
$this->response->exit('group_update', ['$result' => $success], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('group_update', ['$result' => $success], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ class Search extends BaseApi
|
|||
// error if no searchstring specified
|
||||
if ($request['searchstring'] == '') {
|
||||
$answer = ['result' => 'error', 'message' => 'searchstring not specified'];
|
||||
$this->response->exit('direct_message_search', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('direct_message_search', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,6 @@ class Search extends BaseApi
|
|||
$success = ['success' => true, 'search_results' => $ret];
|
||||
}
|
||||
|
||||
$this->response->exit('direct_message_search', ['$result' => $success], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('direct_message_search', ['$result' => $success], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,14 +42,14 @@ class Setseen extends BaseApi
|
|||
// return error if id is zero
|
||||
if (empty($request['id'])) {
|
||||
$answer = ['result' => 'error', 'message' => 'message id not specified'];
|
||||
$this->response->exit('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||
return;
|
||||
}
|
||||
|
||||
// error message if specified id is not in database
|
||||
if (!DBA::exists('mail', ['id' => $request['id'], 'uid' => $uid])) {
|
||||
$answer = ['result' => 'error', 'message' => 'message id not in database'];
|
||||
$this->response->exit('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,6 @@ class Setseen extends BaseApi
|
|||
$answer = ['result' => 'error', 'message' => 'unknown error'];
|
||||
}
|
||||
|
||||
$this->response->exit('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,6 +110,6 @@ class Create extends BaseApi
|
|||
|
||||
$result = ['success' => true, 'event_id' => $event_id, 'event' => $event];
|
||||
|
||||
$this->response->exit('event_create', ['$result' => $result], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('event_create', ['$result' => $result], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,6 +59,6 @@ class Delete extends BaseApi
|
|||
Event::delete($eventid);
|
||||
|
||||
$success = ['id' => $eventid, 'status' => 'deleted'];
|
||||
$this->response->exit('event_delete', ['$result' => $success], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('event_delete', ['$result' => $success], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,6 +69,6 @@ class Index extends BaseApi
|
|||
];
|
||||
}
|
||||
|
||||
$this->response->exit('events', ['events' => $items], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('events', ['events' => $items], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,6 @@ class Notification extends BaseApi
|
|||
$result = false;
|
||||
}
|
||||
|
||||
$this->response->exit('notes', ['note' => $result], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('notes', ['note' => $result], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,13 +70,13 @@ class Seen extends BaseApi
|
|||
// we found the item, return it to the user
|
||||
$ret = [DI::twitterStatus()->createFromUriId($item['uri-id'], $item['uid'], $include_entities)->toArray()];
|
||||
$data = ['status' => $ret];
|
||||
$this->response->exit('statuses', $data, $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('statuses', $data, $this->parameters['extension'] ?? null);
|
||||
return;
|
||||
}
|
||||
// the item can't be found, but we set the notification as seen, so we count this as a success
|
||||
}
|
||||
|
||||
$this->response->exit('statuses', ['result' => 'success'], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('statuses', ['result' => 'success'], $this->parameters['extension'] ?? null);
|
||||
} catch (NotFoundException $e) {
|
||||
throw new BadRequestException('Invalid argument', $e);
|
||||
} catch (Exception $e) {
|
||||
|
|
|
@ -60,6 +60,6 @@ class Photo extends BaseApi
|
|||
// prepare json/xml output with data from database for the requested photo
|
||||
$data = ['photo' => $this->friendicaPhoto->createFromId($photo_id, $scale, $uid, $type)];
|
||||
|
||||
$this->response->exit('statuses', $data, $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
$this->response->addFormattedContent('statuses', $data, $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ class Create extends BaseApi
|
|||
if (!empty($photo)) {
|
||||
Photo::clearAlbumCache($uid);
|
||||
$data = ['photo' => $this->friendicaPhoto->createFromId($photo['resource_id'], null, $uid, $type)];
|
||||
$this->response->exit('photo_create', $data, $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('photo_create', $data, $this->parameters['extension'] ?? null);
|
||||
} else {
|
||||
throw new HTTPException\InternalServerErrorException('unknown error - uploading photo failed, see Friendica log for more information');
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ class Delete extends BaseApi
|
|||
Item::deleteForUser($condition, $uid);
|
||||
Photo::clearAlbumCache($uid);
|
||||
$result = ['result' => 'deleted', 'message' => 'photo with id `' . $request['photo_id'] . '` has been deleted from server.'];
|
||||
$this->response->exit('photo_delete', ['$result' => $result], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('photo_delete', ['$result' => $result], $this->parameters['extension'] ?? null);
|
||||
} else {
|
||||
throw new InternalServerErrorException("unknown error on deleting photo from database table");
|
||||
}
|
||||
|
|
|
@ -77,6 +77,6 @@ class Lists extends BaseApi
|
|||
}
|
||||
}
|
||||
|
||||
$this->response->exit('statuses', $data, $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
$this->response->addFormattedContent('statuses', $data, $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ class Update extends BaseApi
|
|||
$photo = Photo::upload($uid, $_FILES['media'], $album, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc, $photo_id);
|
||||
if (!empty($photo)) {
|
||||
$data = ['photo' => $this->friendicaPhoto->createFromId($photo['resource_id'], null, $uid, $type)];
|
||||
$this->response->exit('photo_update', $data, $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('photo_update', $data, $this->parameters['extension'] ?? null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -137,12 +137,12 @@ class Update extends BaseApi
|
|||
if ($result) {
|
||||
Photo::clearAlbumCache($uid);
|
||||
$answer = ['result' => 'updated', 'message' => 'Image id `' . $photo_id . '` has been updated.'];
|
||||
$this->response->exit('photo_update', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('photo_update', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||
return;
|
||||
} else {
|
||||
if ($nothingtodo) {
|
||||
$answer = ['result' => 'cancelled', 'message' => 'Nothing to update for image id `' . $photo_id . '`.'];
|
||||
$this->response->exit('photo_update', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('photo_update', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||
return;
|
||||
}
|
||||
throw new HTTPException\InternalServerErrorException('unknown error - update photo entry in database failed');
|
||||
|
|
|
@ -68,7 +68,7 @@ class Delete extends BaseApi
|
|||
if ($result) {
|
||||
Photo::clearAlbumCache($uid);
|
||||
$answer = ['result' => 'deleted', 'message' => 'album `' . $request['album'] . '` with all containing photos has been deleted.'];
|
||||
$this->response->exit('photoalbum_delete', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('photoalbum_delete', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||
} else {
|
||||
throw new InternalServerErrorException("unknown error - deleting from database failed");
|
||||
}
|
||||
|
|
|
@ -47,6 +47,6 @@ class Index extends BaseApi
|
|||
];
|
||||
}
|
||||
|
||||
$this->response->exit('albums', ['albums' => $items], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('albums', ['albums' => $items], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,6 +104,6 @@ class Show extends BaseApi
|
|||
}
|
||||
}
|
||||
|
||||
$this->response->exit('statuses', $data, $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
$this->response->addFormattedContent('statuses', $data, $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ class Update extends BaseApi
|
|||
if ($result) {
|
||||
Photo::clearAlbumCache($uid);
|
||||
$answer = ['result' => 'updated', 'message' => 'album `' . $request['album'] . '` with all containing photos has been renamed to `' . $request['album_new'] . '`.'];
|
||||
$this->response->exit('photoalbum_update', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('photoalbum_update', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||
} else {
|
||||
throw new InternalServerErrorException("unknown error - updating in database failed");
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ class Show extends BaseApi
|
|||
'profiles' => $profiles
|
||||
];
|
||||
|
||||
$this->response->exit('friendica_profiles', ['$result' => $result], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('friendica_profiles', ['$result' => $result], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -61,6 +61,6 @@ class Config extends BaseApi
|
|||
],
|
||||
];
|
||||
|
||||
$this->response->exit('config', ['config' => $config], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('config', ['config' => $config], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,6 @@ class Version extends BaseApi
|
|||
{
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$this->response->exit('version', ['version' => '0.9.7'], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('version', ['version' => '0.9.7'], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,6 @@ class Test extends BaseApi
|
|||
$ok = 'ok';
|
||||
}
|
||||
|
||||
$this->response->exit('ok', ['ok' => $ok], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('ok', ['ok' => $ok], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,6 +90,6 @@ class Conversation extends BaseApi
|
|||
}
|
||||
DBA::close($statuses);
|
||||
|
||||
$this->response->exit('statuses', ['status' => $ret], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
$this->response->addFormattedContent('statuses', ['status' => $ret], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,6 +105,6 @@ class UpdateCredentials extends BaseApi
|
|||
}
|
||||
|
||||
$account = DI::mstdnAccount()->createFromContactId($cdata['user'], $uid);
|
||||
$this->response->exitWithJson($account->toArray());
|
||||
$this->response->addJsonContent($account->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,6 @@ class VerifyCredentials extends BaseApi
|
|||
|
||||
// @todo Support the source property,
|
||||
$account = DI::mstdnAccount()->createFromContactId($cdata['user'], $uid);
|
||||
$this->response->exitWithJson($account->toArray());
|
||||
$this->response->addJsonContent($account->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ class PushSubscription extends BaseApi
|
|||
$this->logger->info('Subscription stored', ['ret' => $ret, 'subscription' => $subscription]);
|
||||
|
||||
$subscriptionObj = $this->subscriptionFac->createForApplicationIdAndUserId($application['id'], $uid);
|
||||
$this->response->exitWithJson($subscriptionObj->toArray());
|
||||
$this->response->addJsonContent($subscriptionObj->toArray());
|
||||
}
|
||||
|
||||
public function put(array $request = []): void
|
||||
|
@ -120,7 +120,7 @@ class PushSubscription extends BaseApi
|
|||
]);
|
||||
|
||||
$subscriptionObj = $this->subscriptionFac->createForApplicationIdAndUserId($application['id'], $uid);
|
||||
$this->response->exitWithJson($subscriptionObj->toArray());
|
||||
$this->response->addJsonContent($subscriptionObj->toArray());
|
||||
}
|
||||
|
||||
protected function delete(array $request = []): void
|
||||
|
@ -137,7 +137,7 @@ class PushSubscription extends BaseApi
|
|||
'uid' => $uid,
|
||||
]);
|
||||
|
||||
$this->response->exitWithJson([]);
|
||||
$this->response->addJsonContent([]);
|
||||
}
|
||||
|
||||
protected function rawContent(array $request = []): void
|
||||
|
@ -154,6 +154,6 @@ class PushSubscription extends BaseApi
|
|||
$this->logger->info('Fetch subscription', ['application-id' => $application['id'], 'uid' => $uid]);
|
||||
|
||||
$subscriptionObj = $this->subscriptionFac->createForApplicationIdAndUserId($application['id'], $uid);
|
||||
$this->response->exitWithJson($subscriptionObj->toArray());
|
||||
$this->response->addJsonContent($subscriptionObj->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,6 @@ class RateLimitStatus extends BaseApi
|
|||
];
|
||||
}
|
||||
|
||||
$this->response->exit('hash', ['hash' => $hash], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('hash', ['hash' => $hash], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,6 @@ class UpdateProfile extends BaseApi
|
|||
// "uid" is only needed for some internal stuff, so remove it from here
|
||||
unset($user_info['uid']);
|
||||
|
||||
$this->response->exit('user', ['user' => $user_info], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('user', ['user' => $user_info], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,6 +67,6 @@ class UpdateProfileImage extends BaseApi
|
|||
// "uid" is only needed for some internal stuff, so remove it from here
|
||||
unset($user_info['uid']);
|
||||
|
||||
$this->response->exit('user', ['user' => $user_info], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('user', ['user' => $user_info], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,6 @@ class VerifyCredentials extends BaseApi
|
|||
// "uid" is only needed for some internal stuff, so remove it from here
|
||||
unset($user_info['uid']);
|
||||
|
||||
$this->response->exit('user', ['user' => $user_info], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('user', ['user' => $user_info], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,6 +84,6 @@ class Lists extends ContactEndpoint
|
|||
|
||||
self::setLinkHeader();
|
||||
|
||||
$this->response->exit('lists', ['lists' => $return]);
|
||||
$this->response->addFormattedContent('lists', ['lists' => $return]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ class Destroy extends BaseApi
|
|||
// error if no id or parenturi specified (for clients posting parent-uri as well)
|
||||
if ($verbose && $id == 0 && $parenturi == "") {
|
||||
$answer = ['result' => 'error', 'message' => 'message id or parenturi not specified'];
|
||||
$this->response->exit('direct_messages_delete', ['direct_messages_delete' => $answer], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('direct_messages_delete', ['direct_messages_delete' => $answer], $this->parameters['extension'] ?? null);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ class Destroy extends BaseApi
|
|||
if (!$this->dba->exists('mail', ["`uid` = ? AND `id` = ? " . $sql_extra, $uid, $id])) {
|
||||
if ($verbose) {
|
||||
$answer = ['result' => 'error', 'message' => 'message id not in database'];
|
||||
$this->response->exit('direct_messages_delete', ['direct_messages_delete' => $answer], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('direct_messages_delete', ['direct_messages_delete' => $answer], $this->parameters['extension'] ?? null);
|
||||
return;
|
||||
}
|
||||
throw new BadRequestException('message id not in database');
|
||||
|
@ -85,10 +85,10 @@ class Destroy extends BaseApi
|
|||
if ($result) {
|
||||
// return success
|
||||
$answer = ['result' => 'ok', 'message' => 'message deleted'];
|
||||
$this->response->exit('direct_messages_delete', ['direct_messages_delete' => $answer], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('direct_messages_delete', ['direct_messages_delete' => $answer], $this->parameters['extension'] ?? null);
|
||||
} else {
|
||||
$answer = ['result' => 'error', 'message' => 'unknown error'];
|
||||
$this->response->exit('direct_messages_delete', ['direct_messages_delete' => $answer], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('direct_messages_delete', ['direct_messages_delete' => $answer], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,6 +91,6 @@ class NewDM extends BaseApi
|
|||
$ret = ['error' => $id];
|
||||
}
|
||||
|
||||
$this->response->exit('direct-messages', ['direct_message' => $ret], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
$this->response->addFormattedContent('direct-messages', ['direct_message' => $ret], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ abstract class DirectMessagesEndpoint extends BaseApi
|
|||
$mails = $this->dba->selectToArray('mail', ['id'], $condition, $params);
|
||||
if ($verbose && !DBA::isResult($mails)) {
|
||||
$answer = ['result' => 'error', 'message' => 'no mails available'];
|
||||
$this->response->exit('direct-messages', ['direct_message' => $answer], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('direct-messages', ['direct_message' => $answer], $this->parameters['extension'] ?? null);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -116,6 +116,6 @@ abstract class DirectMessagesEndpoint extends BaseApi
|
|||
|
||||
self::setLinkHeader();
|
||||
|
||||
$this->response->exit('direct-messages', ['direct_message' => $ret], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
$this->response->addFormattedContent('direct-messages', ['direct_message' => $ret], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,6 +72,6 @@ class Favorites extends BaseApi
|
|||
}
|
||||
DBA::close($statuses);
|
||||
|
||||
$this->response->exit('statuses', ['status' => $ret], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
$this->response->addFormattedContent('statuses', ['status' => $ret], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,6 @@ class Create extends BaseApi
|
|||
|
||||
$status_info = DI::twitterStatus()->createFromUriId($id, $uid)->toArray();
|
||||
|
||||
$this->response->exit('status', ['status' => $status_info], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('status', ['status' => $status_info], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,6 @@ class Destroy extends BaseApi
|
|||
|
||||
$status_info = DI::twitterStatus()->createFromUriId($id, $uid)->toArray();
|
||||
|
||||
$this->response->exit('status', ['status' => $status_info], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('status', ['status' => $status_info], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,6 +114,6 @@ class Lists extends ContactEndpoint
|
|||
|
||||
$this->response->setHeader(self::getLinkHeader());
|
||||
|
||||
$this->response->exit('lists', ['lists' => $return]);
|
||||
$this->response->addFormattedContent('lists', ['lists' => $return]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,6 +114,6 @@ class Lists extends ContactEndpoint
|
|||
|
||||
$this->response->setHeader(self::getLinkHeader());
|
||||
|
||||
$this->response->exit('lists', ['lists' => $return]);
|
||||
$this->response->addFormattedContent('lists', ['lists' => $return]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,6 +87,6 @@ class Destroy extends ContactEndpoint
|
|||
throw new HTTPException\InternalServerErrorException('Unable to unfollow this contact, please contact your administrator');
|
||||
}
|
||||
|
||||
$this->response->exit('friendships', ['user' => $user], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('friendships', ['user' => $user], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,6 +82,6 @@ class Incoming extends ContactEndpoint
|
|||
|
||||
$this->response->setHeader(self::getLinkHeader());
|
||||
|
||||
$this->response->exit('incoming', ['incoming' => $return]);
|
||||
$this->response->addFormattedContent('incoming', ['incoming' => $return]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,6 +112,6 @@ class Show extends ContactEndpoint
|
|||
]
|
||||
];
|
||||
|
||||
DI::apiResponse()->exit('relationship', ['relationship' => $relationship], $this->parameters['extension'] ?? null);
|
||||
DI::apiResponse()->addFormattedContent('relationship', ['relationship' => $relationship], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,6 +80,6 @@ class Create extends BaseApi
|
|||
|
||||
$grp = $this->friendicaCircle->createFromId($gid);
|
||||
|
||||
$this->response->exit('statuses', ['lists' => ['lists' => $grp]], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
$this->response->addFormattedContent('statuses', ['lists' => ['lists' => $grp]], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ class Destroy extends BaseApi
|
|||
$list = $this->friendicaCircle->createFromId($gid);
|
||||
|
||||
if (Circle::remove($gid)) {
|
||||
$this->response->exit('statuses', ['lists' => ['lists' => $list]], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
$this->response->addFormattedContent('statuses', ['lists' => ['lists' => $list]], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,6 @@ class Lists extends BaseApi
|
|||
|
||||
// This is a dummy endpoint
|
||||
$ret = [];
|
||||
$this->response->exit('statuses', ["lists_list" => $ret], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
$this->response->addFormattedContent('statuses', ["lists_list" => $ret], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,6 +64,6 @@ class Ownership extends BaseApi
|
|||
$lists[] = $this->friendicaCircle->createFromId($circle['id']);
|
||||
}
|
||||
|
||||
$this->response->exit('statuses', ['lists' => ['lists' => $lists]], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
$this->response->addFormattedContent('statuses', ['lists' => ['lists' => $lists]], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,6 +103,6 @@ class Statuses extends BaseApi
|
|||
}
|
||||
$this->dba->close($statuses);
|
||||
|
||||
$this->response->exit('statuses', ['status' => $items], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
$this->response->addFormattedContent('statuses', ['status' => $items], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ class Update extends BaseApi
|
|||
if (Circle::update($gid, $name)) {
|
||||
$list = $this->friendicaCircle->createFromId($gid);
|
||||
|
||||
$this->response->exit('statuses', ['lists' => ['lists' => $list]], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
$this->response->addFormattedContent('statuses', ['lists' => ['lists' => $list]], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,6 +65,6 @@ class Upload extends BaseApi
|
|||
|
||||
Logger::info('Media uploaded', ['return' => $returndata]);
|
||||
|
||||
$this->response->exit('media', ['media' => $returndata], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('media', ['media' => $returndata], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,6 @@ class SavedSearches extends BaseApi
|
|||
|
||||
DBA::close($terms);
|
||||
|
||||
$this->response->exit('terms', ['terms' => $result], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('terms', ['terms' => $result], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ class Tweets extends BaseApi
|
|||
DBA::close($tags);
|
||||
|
||||
if (empty($uriids)) {
|
||||
$this->response->exit('statuses', $data, $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
$this->response->addFormattedContent('statuses', $data, $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -116,6 +116,6 @@ class Tweets extends BaseApi
|
|||
}
|
||||
DBA::close($statuses);
|
||||
|
||||
$this->response->exit('statuses', ['status' => $ret], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
$this->response->addFormattedContent('statuses', ['status' => $ret], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,6 +59,6 @@ class Destroy extends BaseApi
|
|||
|
||||
Item::deleteForUser(['id' => $post['id']], $uid);
|
||||
|
||||
$this->response->exit('status', ['status' => $ret], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
$this->response->addFormattedContent('status', ['status' => $ret], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,6 +87,6 @@ class HomeTimeline extends BaseApi
|
|||
}
|
||||
}
|
||||
|
||||
$this->response->exit('statuses', ['status' => $ret], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
$this->response->addFormattedContent('statuses', ['status' => $ret], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,6 +80,6 @@ class Mentions extends BaseApi
|
|||
}
|
||||
DBA::close($statuses);
|
||||
|
||||
$this->response->exit('statuses', ['status' => $ret], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
$this->response->addFormattedContent('statuses', ['status' => $ret], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,6 @@ class NetworkPublicTimeline extends BaseApi
|
|||
}
|
||||
DBA::close($statuses);
|
||||
|
||||
$this->response->exit('statuses', ['status' => $ret], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
$this->response->addFormattedContent('statuses', ['status' => $ret], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,6 +85,6 @@ class PublicTimeline extends BaseApi
|
|||
}
|
||||
DBA::close($statuses);
|
||||
|
||||
$this->response->exit('statuses', ['status' => $ret], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
$this->response->addFormattedContent('statuses', ['status' => $ret], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,6 +69,6 @@ class Retweet extends BaseApi
|
|||
|
||||
$status_info = DI::twitterStatus()->createFromItemId($item_id, $uid)->toArray();
|
||||
|
||||
DI::apiResponse()->exit('statuses', ['status' => $status_info], $this->parameters['extension'] ?? null);
|
||||
DI::apiResponse()->addFormattedContent('statuses', ['status' => $status_info], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,10 +85,10 @@ class Show extends BaseApi
|
|||
|
||||
if ($conversation) {
|
||||
$data = ['status' => $ret];
|
||||
$this->response->exit('statuses', $data, $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
$this->response->addFormattedContent('statuses', $data, $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
} else {
|
||||
$data = ['status' => $ret[0]];
|
||||
$this->response->exit('status', $data, $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
$this->response->addFormattedContent('status', $data, $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ class Update extends BaseApi
|
|||
if (!empty($item['uri-id'])) {
|
||||
// output the post that we just posted.
|
||||
$status_info = DI::twitterStatus()->createFromUriId($item['uri-id'], $uid, $request['include_entities'])->toArray();
|
||||
DI::apiResponse()->exit('status', ['status' => $status_info], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
DI::apiResponse()->addFormattedContent('status', ['status' => $status_info], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,6 +80,6 @@ class UserTimeline extends BaseApi
|
|||
}
|
||||
DBA::close($statuses);
|
||||
|
||||
$this->response->exit('statuses', ['status' => $ret], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
$this->response->addFormattedContent('statuses', ['status' => $ret], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,6 @@ class Lookup extends BaseApi
|
|||
throw new NotFoundException();
|
||||
}
|
||||
|
||||
$this->response->exit('users', ['user' => $users], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('users', ['user' => $users], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,6 +69,6 @@ class Search extends BaseApi
|
|||
throw new BadRequestException('No search term specified.');
|
||||
}
|
||||
|
||||
$this->response->exit('users', $userlist, $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('users', $userlist, $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,6 @@ class Show extends BaseApi
|
|||
// "uid" is only needed for some internal stuff, so remove it from here
|
||||
unset($user_info['uid']);
|
||||
|
||||
$this->response->exit('user', ['user' => $user_info], $this->parameters['extension'] ?? null);
|
||||
$this->response->addFormattedContent('user', ['user' => $user_info], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -285,7 +285,7 @@ class ApiResponseTest extends MockedTest
|
|||
$twitterUser = \Mockery::mock(User::class);
|
||||
|
||||
$response = new ApiResponse($l10n, $args, new NullLogger(), $baseUrl, $twitterUser);
|
||||
$response->exitWithJson(['some_data']);
|
||||
$response->addJsonContent(['some_data']);
|
||||
|
||||
self::assertEquals('["some_data"]', $response->getContent());
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ class ApiResponseTest extends MockedTest
|
|||
$twitterUser = \Mockery::mock(User::class);
|
||||
|
||||
$response = new ApiResponse($l10n, $args, new NullLogger(), $baseUrl, $twitterUser, [], 'JsonPCallback');
|
||||
$response->exitWithJson(['some_data']);
|
||||
$response->addJsonContent(['some_data']);
|
||||
|
||||
self::assertEquals('JsonPCallback(["some_data"])', $response->getContent());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue