mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-12 01:54:26 +02:00
Inherit ApiResponse
from Response
This commit is contained in:
parent
561aba18e3
commit
537b74f307
46 changed files with 326 additions and 277 deletions
|
@ -57,9 +57,9 @@ class Activity extends BaseApi
|
|||
} else {
|
||||
$ok = 'ok';
|
||||
}
|
||||
DI::apiResponse()->exit('ok', ['ok' => $ok], $this->parameters['extension'] ?? null);
|
||||
$this->response->exit('ok', ['ok' => $ok], $this->parameters['extension'] ?? null);
|
||||
} else {
|
||||
DI::apiResponse()->error(500, 'Error adding activity', '', $this->parameters['extension'] ?? null);
|
||||
$this->response->error(500, 'Error adding activity', '', $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,13 +42,15 @@ class Setseen extends BaseApi
|
|||
// return error if id is zero
|
||||
if (empty($request['id'])) {
|
||||
$answer = ['result' => 'error', 'message' => 'message id not specified'];
|
||||
DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||
$this->response->exit('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'];
|
||||
DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||
$this->response->exit('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||
return;
|
||||
}
|
||||
|
||||
// update seen indicator
|
||||
|
@ -58,6 +60,6 @@ class Setseen extends BaseApi
|
|||
$answer = ['result' => 'error', 'message' => 'unknown error'];
|
||||
}
|
||||
|
||||
DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||
$this->response->exit('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,6 +70,6 @@ class Index extends BaseApi
|
|||
];
|
||||
}
|
||||
|
||||
DI::apiResponse()->exit('events', ['events' => $items], $this->parameters['extension'] ?? null);
|
||||
$this->response->exit('events', ['events' => $items], $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' => []];
|
||||
DI::apiResponse()->exit('group_delete', ['$result' => $success], $parameters['extension'] ?? null);
|
||||
$this->response->exit('group_delete', ['$result' => $success], $parameters['extension'] ?? null);
|
||||
} else {
|
||||
throw new BadRequestException('other API error');
|
||||
}
|
||||
|
|
|
@ -56,6 +56,6 @@ class Notification extends BaseApi
|
|||
$result = false;
|
||||
}
|
||||
|
||||
DI::apiResponse()->exit('notes', ['note' => $result], $this->parameters['extension'] ?? null);
|
||||
$this->response->exit('notes', ['note' => $result], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ class Delete extends BaseApi
|
|||
Item::deleteForUser($condition, $uid);
|
||||
|
||||
$result = ['result' => 'deleted', 'message' => 'photo with id `' . $request['photo_id'] . '` has been deleted from server.'];
|
||||
DI::apiResponse()->exit('photo_delete', ['$result' => $result], $this->parameters['extension'] ?? null);
|
||||
$this->response->exit('photo_delete', ['$result' => $result], $this->parameters['extension'] ?? null);
|
||||
} else {
|
||||
throw new InternalServerErrorException("unknown error on deleting photo from database table");
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ class Delete extends BaseApi
|
|||
// return success of deletion or error message
|
||||
if ($result) {
|
||||
$answer = ['result' => 'deleted', 'message' => 'album `' . $request['album'] . '` with all containing photos has been deleted.'];
|
||||
DI::apiResponse()->exit('photoalbum_delete', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||
$this->response->exit('photoalbum_delete', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||
} else {
|
||||
throw new InternalServerErrorException("unknown error - deleting from database failed");
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ class Update extends BaseApi
|
|||
// return success of updating or error message
|
||||
if ($result) {
|
||||
$answer = ['result' => 'updated', 'message' => 'album `' . $request['album'] . '` with all containing photos has been renamed to `' . $request['album_new'] . '`.'];
|
||||
DI::apiResponse()->exit('photoalbum_update', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||
$this->response->exit('photoalbum_update', ['$result' => $answer], $this->parameters['extension'] ?? null);
|
||||
} else {
|
||||
throw new InternalServerErrorException("unknown error - updating in database failed");
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ class Show extends BaseApi
|
|||
'profiles' => $profiles
|
||||
];
|
||||
|
||||
DI::apiResponse()->exit('friendica_profiles', ['$result' => $result], $this->parameters['extension'] ?? null);
|
||||
$this->response->exit('friendica_profiles', ['$result' => $result], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue