mirror of
https://github.com/friendica/friendica
synced 2025-04-22 03:50:11 +00:00
Some standards
This commit is contained in:
parent
95f085b7ac
commit
f68c94db04
5 changed files with 25 additions and 24 deletions
|
@ -26,7 +26,7 @@ use Friendica\Model\Contact;
|
|||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
||||
class Activity extends BaseApi
|
||||
class Photo extends BaseApi
|
||||
{
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
|
@ -37,13 +37,13 @@ class Activity extends BaseApi
|
|||
if (empty($_REQUEST['photo_id'])) {
|
||||
throw new HTTPException\BadRequestException('No photo id.');
|
||||
}
|
||||
|
||||
|
||||
$scale = (!empty($_REQUEST['scale']) ? intval($_REQUEST['scale']) : false);
|
||||
$photo_id = $_REQUEST['photo_id'];
|
||||
|
||||
|
||||
// prepare json/xml output with data from database for the requested photo
|
||||
$data = ['photo' => DI::friendicaPhoto()->createFromId($photo_id, $scale, $uid, $type)];
|
||||
|
||||
|
||||
$this->response->exit('statuses', $data, $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,19 +45,19 @@ class Create extends BaseApi
|
|||
$deny_cid = $_REQUEST['deny_cid' ] ?? null;
|
||||
$allow_gid = $_REQUEST['allow_gid'] ?? null;
|
||||
$deny_gid = $_REQUEST['deny_gid' ] ?? null;
|
||||
|
||||
|
||||
// do several checks on input parameters
|
||||
// we do not allow calls without album string
|
||||
if ($album == null) {
|
||||
throw new HTTPException\BadRequestException('no albumname specified');
|
||||
}
|
||||
|
||||
|
||||
// error if no media posted in create-mode
|
||||
if (empty($_FILES['media'])) {
|
||||
// Output error
|
||||
throw new HTTPException\BadRequestException('no media data submitted');
|
||||
}
|
||||
|
||||
|
||||
// checks on acl strings provided by clients
|
||||
$acl_input_error = false;
|
||||
$acl_input_error |= !ACL::isValidContact($allow_cid, $uid);
|
||||
|
|
|
@ -42,15 +42,15 @@ class Lists extends BaseApi
|
|||
|
||||
$photos = Photo::selectToArray(['resource-id'], ["`uid` = ? AND NOT `photo-type` IN (?, ?)", $uid, Photo::CONTACT_AVATAR, Photo::CONTACT_BANNER],
|
||||
['order' => ['id'], 'group_by' => ['resource-id']]);
|
||||
|
||||
|
||||
$data = ['photo' => []];
|
||||
if (DBA::isResult($photos)) {
|
||||
foreach ($photos as $photo) {
|
||||
$element = DI::friendicaPhoto()->createFromId($photo['resource-id'], null, $uid, 'json', false);
|
||||
|
||||
|
||||
$element['thumb'] = end($element['link']);
|
||||
unset($element['link']);
|
||||
|
||||
|
||||
if ($type == 'xml') {
|
||||
$thumb = $element['thumb'];
|
||||
unset($element['thumb']);
|
||||
|
|
|
@ -37,7 +37,7 @@ class Update extends BaseApi
|
|||
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
|
||||
$uid = BaseApi::getCurrentUserID();
|
||||
$type = $this->parameters['extension'] ?? '';
|
||||
|
||||
|
||||
// input params
|
||||
$photo_id = $_REQUEST['photo_id'] ?? null;
|
||||
$desc = $_REQUEST['desc'] ?? null;
|
||||
|
@ -47,7 +47,7 @@ class Update extends BaseApi
|
|||
$deny_cid = $_REQUEST['deny_cid' ] ?? null;
|
||||
$allow_gid = $_REQUEST['allow_gid'] ?? null;
|
||||
$deny_gid = $_REQUEST['deny_gid' ] ?? null;
|
||||
|
||||
|
||||
// do several checks on input parameters
|
||||
// we do not allow calls without album string
|
||||
if ($album == null) {
|
||||
|
@ -58,7 +58,7 @@ class Update extends BaseApi
|
|||
if (!Photo::exists(['resource-id' => $photo_id, 'uid' => $uid, 'album' => $album])) {
|
||||
throw new HTTPException\BadRequestException('photo not available');
|
||||
}
|
||||
|
||||
|
||||
// checks on acl strings provided by clients
|
||||
$acl_input_error = false;
|
||||
$acl_input_error |= !ACL::isValidContact($allow_cid, $uid);
|
||||
|
@ -68,7 +68,7 @@ class Update extends BaseApi
|
|||
if ($acl_input_error) {
|
||||
throw new HTTPException\BadRequestException('acl data invalid');
|
||||
}
|
||||
|
||||
|
||||
$updated_fields = [];
|
||||
|
||||
if (!is_null($desc)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue