mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-10 09:04:26 +02: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
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue