Apply suggestions from code review

Co-authored-by: Philipp <admin+Github@philipp.info>
This commit is contained in:
Michael Vogel 2022-01-16 21:47:12 +01:00 committed by GitHub
parent 88ac888a3b
commit b38c9bed6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 5 deletions

View File

@ -22,7 +22,7 @@
namespace Friendica\Factory\Api\Friendica; namespace Friendica\Factory\Api\Friendica;
use Friendica\BaseFactory; use Friendica\BaseFactory;
use Friendica\Database\DBA; use Friendica\Database\Database;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Friendica\Factory\Api\Twitter\User as TwitterUser; use Friendica\Factory\Api\Twitter\User as TwitterUser;
@ -31,12 +31,15 @@ class Group extends BaseFactory
{ {
/** @var twitterUser entity */ /** @var twitterUser entity */
private $twitterUser; private $twitterUser;
/** @var Database */
private $database;
public function __construct(LoggerInterface $logger, TwitterUser $twitteruser) public function __construct(LoggerInterface $logger, TwitterUser $twitteruser, Database $dba)
{ {
parent::__construct($logger); parent::__construct($logger);
$this->twitterUser = $twitteruser; $this->twitterUser = $twitteruser;
$this->dba = $dba;
} }
/** /**
@ -46,7 +49,7 @@ class Group extends BaseFactory
*/ */
public function createFromId(int $id): array public function createFromId(int $id): array
{ {
$group = DBA::selectFirst('group', [], ['id' => $id, 'deleted' => false]); $group = $this->dba->selectFirst('group', [], ['id' => $id, 'deleted' => false]);
if (empty($group)) { if (empty($group)) {
return []; return [];
} }

View File

@ -22,7 +22,6 @@
namespace Friendica\Module\Api\Friendica\Group; namespace Friendica\Module\Api\Friendica\Group;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Module\BaseApi; use Friendica\Module\BaseApi;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;

View File

@ -90,7 +90,6 @@ class Create extends BaseApi
if (!empty($photo)) { if (!empty($photo)) {
$data = ['photo' => $this->friendicaPhoto->createFromId($photo['resource_id'], null, $uid, $type)]; $data = ['photo' => $this->friendicaPhoto->createFromId($photo['resource_id'], null, $uid, $type)];
$this->response->exit('photo_create', $data, $this->parameters['extension'] ?? null); $this->response->exit('photo_create', $data, $this->parameters['extension'] ?? null);
return;
} else { } else {
throw new HTTPException\InternalServerErrorException('unknown error - uploading photo failed, see Friendica log for more information'); throw new HTTPException\InternalServerErrorException('unknown error - uploading photo failed, see Friendica log for more information');
} }