// "Factory" namespace instances
//
- /**
- * @return Factory\Api\Friendica\Activities
- */
- public static function friendicaActivities()
- {
- return self::$dice->create(Factory\Api\Friendica\Activities::class);
- }
-
- /**
- * @return Factory\Api\Friendica\Group
- */
- public static function friendicaGroup()
- {
- return self::$dice->create(Factory\Api\Friendica\Group::class);
- }
-
- /**
- * @return Factory\Api\Friendica\Photo
- */
- public static function friendicaPhoto()
- {
- return self::$dice->create(Factory\Api\Friendica\Photo::class);
- }
-
/**
* @return Factory\Api\Mastodon\Account
*/
namespace Friendica\Factory\Api\Friendica;
-use Friendica\App\BaseURL;
use Friendica\BaseFactory;
use Friendica\Database\DBA;
use Friendica\Model\Post;
class Activities extends BaseFactory
{
- /** @var BaseURL */
- private $baseUrl;
/** @var twitterUser entity */
private $twitterUser;
- public function __construct(LoggerInterface $logger, BaseURL $baseURL, TwitterUser $twitteruser)
+ public function __construct(LoggerInterface $logger, TwitterUser $twitteruser)
{
parent::__construct($logger);
$this->twitterUser = $twitteruser;
- $this->baseUrl = $baseURL;
}
/**
namespace Friendica\Module\Api\Friendica;
-use Friendica\DI;
-use Friendica\Model\Contact;
+use Friendica\App;
+use Friendica\Core\L10n;
+use Friendica\Factory\Api\Friendica\Photo as FriendicaPhoto;
use Friendica\Module\BaseApi;
+use Friendica\Model\Contact;
+use Friendica\Module\Api\ApiResponse;
use Friendica\Network\HTTPException;
+use Friendica\Util\Profiler;
+use Psr\Log\LoggerInterface;
class Photo extends BaseApi
{
+ /** @var FriendicaPhoto */
+ private $friendicaPhoto;
+
+
+ public function __construct(FriendicaPhoto $friendicaPhoto, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
+ {
+ parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
+
+ $this->friendicaPhoto = $friendicaPhoto;
+ }
+
protected function post(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$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)];
+ $data = ['photo' => $this->friendicaPhoto->createFromId($photo_id, $scale, $uid, $type)];
$this->response->exit('statuses', $data, $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
}
namespace Friendica\Module\Api\Friendica\Photo;
+use Friendica\App;
use Friendica\Core\ACL;
-use Friendica\DI;
-use Friendica\Model\Photo;
+use Friendica\Core\L10n;
+use Friendica\Factory\Api\Friendica\Photo as FriendicaPhoto;
use Friendica\Module\BaseApi;
+use Friendica\Model\Photo;
+use Friendica\Module\Api\ApiResponse;
use Friendica\Network\HTTPException;
+use Friendica\Util\Profiler;
+use Psr\Log\LoggerInterface;
/**
* API endpoint: /api/friendica/photo/create
*/
class Create extends BaseApi
{
+ /** @var FriendicaPhoto */
+ private $friendicaPhoto;
+
+
+ public function __construct(FriendicaPhoto $friendicaPhoto, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
+ {
+ parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
+
+ $this->friendicaPhoto = $friendicaPhoto;
+ }
+
protected function post(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
// return success of updating or error message
if (!empty($photo)) {
- $data = ['photo' => DI::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);
return;
} else {
namespace Friendica\Module\Api\Friendica\Photo;
use Friendica\Database\DBA;
-use Friendica\DI;
+use Friendica\App;
+use Friendica\Core\L10n;
+use Friendica\Factory\Api\Friendica\Photo as FriendicaPhoto;
use Friendica\Module\BaseApi;
use Friendica\Model\Contact;
use Friendica\Model\Photo;
+use Friendica\Module\Api\ApiResponse;
+use Friendica\Util\Profiler;
+use Psr\Log\LoggerInterface;
/**
* Returns all lists the user subscribes to.
*/
class Lists extends BaseApi
{
+ /** @var FriendicaPhoto */
+ private $friendicaPhoto;
+
+
+ public function __construct(FriendicaPhoto $friendicaPhoto, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
+ {
+ parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
+
+ $this->friendicaPhoto = $friendicaPhoto;
+ }
+
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$data = ['photo' => []];
if (DBA::isResult($photos)) {
foreach ($photos as $photo) {
- $element = DI::friendicaPhoto()->createFromId($photo['resource-id'], null, $uid, 'json', false);
+ $element = $this->friendicaPhoto->createFromId($photo['resource-id'], null, $uid, 'json', false);
$element['thumb'] = end($element['link']);
unset($element['link']);
namespace Friendica\Module\Api\Friendica\Photo;
+use Friendica\App;
use Friendica\Core\ACL;
-use Friendica\DI;
-use Friendica\Model\Photo;
+use Friendica\Core\L10n;
+use Friendica\Factory\Api\Friendica\Photo as FriendicaPhoto;
use Friendica\Module\BaseApi;
+use Friendica\Model\Photo;
+use Friendica\Module\Api\ApiResponse;
use Friendica\Network\HTTPException;
+use Friendica\Util\Profiler;
+use Psr\Log\LoggerInterface;
/**
* API endpoint: /api/friendica/photo/update
*/
class Update extends BaseApi
{
+ /** @var FriendicaPhoto */
+ private $friendicaPhoto;
+
+
+ public function __construct(FriendicaPhoto $friendicaPhoto, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
+ {
+ parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
+
+ $this->friendicaPhoto = $friendicaPhoto;
+ }
+
protected function post(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
$nothingtodo = false;
$photo = Photo::upload($uid, $_FILES['media'], $album, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc, $photo_id);
if (!empty($photo)) {
- $data = ['photo' => DI::friendicaPhoto()->createFromId($photo['resource_id'], null, $uid, $type)];
+ $data = ['photo' => $this->friendicaPhoto->createFromId($photo['resource_id'], null, $uid, $type)];
$this->response->exit('photo_update', $data, $this->parameters['extension'] ?? null);
return;
}
namespace Friendica\Module\Api\Twitter\Lists;
-use Friendica\Database\DBA;
-use Friendica\DI;
+use Friendica\App;
+use Friendica\Core\L10n;
+use Friendica\Database\Database;
+use Friendica\Factory\Api\Friendica\Group as FriendicaGroup;
use Friendica\Module\BaseApi;
use Friendica\Model\Contact;
use Friendica\Model\Group;
+use Friendica\Module\Api\ApiResponse;
use Friendica\Network\HTTPException;
+use Friendica\Util\Profiler;
+use Psr\Log\LoggerInterface;
/**
* Update information about a group.
*/
class Create extends BaseApi
{
+ /** @var friendicaGroup */
+ private $friendicaGroup;
+
+ /** @var Database */
+ private $dba;
+
+ public function __construct(Database $dba, FriendicaGroup $friendicaGroup, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
+ {
+ parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
+
+ $this->dba = $dba;
+ $this->friendicaGroup = $friendicaGroup;
+ }
+
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
}
// error message if specified group name already exists
- if (DBA::exists('group', ['uid' => $uid, 'name' => $name, 'deleted' => false])) {
+ if ($this->dba->exists('group', ['uid' => $uid, 'name' => $name, 'deleted' => false])) {
throw new HTTPException\BadRequestException('group name already exists');
}
throw new HTTPException\BadRequestException('other API error');
}
- $grp = DI::friendicaGroup()->createFromId($gid);
+ $grp = $this->friendicaGroup->createFromId($gid);
$this->response->exit('statuses', ['lists' => ['lists' => $grp]], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
}
namespace Friendica\Module\Api\Twitter\Lists;
-use Friendica\Database\DBA;
-use Friendica\DI;
+use Friendica\App;
+use Friendica\Core\L10n;
+use Friendica\Database\Database;
+use Friendica\Factory\Api\Friendica\Group as FriendicaGroup;
use Friendica\Module\BaseApi;
use Friendica\Model\Contact;
use Friendica\Model\Group;
+use Friendica\Module\Api\ApiResponse;
use Friendica\Network\HTTPException;
+use Friendica\Util\Profiler;
+use Psr\Log\LoggerInterface;
/**
* Delete a group.
*/
class Destroy extends BaseApi
{
+ /** @var friendicaGroup */
+ private $friendicaGroup;
+
+ /** @var Database */
+ private $dba;
+
+ public function __construct(Database $dba, FriendicaGroup $friendicaGroup, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
+ {
+ parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
+
+ $this->dba = $dba;
+ $this->friendicaGroup = $friendicaGroup;
+ }
+
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
}
// get data of the specified group id
- $group = DBA::selectFirst('group', [], ['uid' => $uid, 'id' => $gid]);
+ $group = $this->dba->selectFirst('group', [], ['uid' => $uid, 'id' => $gid]);
// error message if specified gid is not in database
if (!$group) {
throw new HTTPException\BadRequestException('gid not available');
}
- $list = DI::friendicaGroup()->createFromId($gid);
+ $list = $this->friendicaGroup->createFromId($gid);
if (Group::remove($gid)) {
$this->response->exit('statuses', ['lists' => ['lists' => $list]], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
namespace Friendica\Module\Api\Twitter\Lists;
-use Friendica\Database\DBA;
-use Friendica\DI;
+use Friendica\App;
+use Friendica\Core\L10n;
+use Friendica\Database\Database;
+use Friendica\Factory\Api\Friendica\Group as FriendicaGroup;
use Friendica\Module\BaseApi;
use Friendica\Model\Contact;
+use Friendica\Module\Api\ApiResponse;
+use Friendica\Util\Profiler;
+use Psr\Log\LoggerInterface;
/**
* Returns all groups the user owns.
*/
class Ownership extends BaseApi
{
+ /** @var friendicaGroup */
+ private $friendicaGroup;
+
+ /** @var Database */
+ private $dba;
+
+ public function __construct(Database $dba, FriendicaGroup $friendicaGroup, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
+ {
+ parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
+
+ $this->dba = $dba;
+ $this->friendicaGroup = $friendicaGroup;
+ }
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
- $groups = DBA::select('group', [], ['deleted' => false, 'uid' => $uid]);
+ $groups = $this->dba->select('group', [], ['deleted' => false, 'uid' => $uid]);
// loop through all groups
$lists = [];
foreach ($groups as $group) {
- $lists[] = DI::friendicaGroup()->createFromId($group['id']);
+ $lists[] = $this->friendicaGroup->createFromId($group['id']);
}
$this->response->exit('statuses', ['lists' => ['lists' => $lists]], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
namespace Friendica\Module\Api\Twitter\Lists;
+use Friendica\App;
+use Friendica\Core\L10n;
+use Friendica\Database\Database;
use Friendica\Database\DBA;
+use Friendica\Factory\Api\Twitter\Status as TwitterStatus;
use Friendica\Module\BaseApi;
-use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Post;
-use Friendica\Network\HTTPException\BadRequestException;
+use Friendica\Module\Api\ApiResponse;
+use Friendica\Network\HTTPException;
+use Friendica\Util\Profiler;
+use Psr\Log\LoggerInterface;
/**
* Returns recent statuses from users in the specified group.
*/
class Statuses extends BaseApi
{
+ /** @var TwitterStatus */
+ private $twitterStatus;
+
+ /** @var Database */
+ private $dba;
+
+ public function __construct(Database $dba, TwitterStatus $twitterStatus, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
+ {
+ parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
+
+ $this->dba = $dba;
+ $this->twitterStatus = $twitterStatus;
+ }
+
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
if (empty($request['list_id'])) {
- throw new BadRequestException('list_id not specified');
+ throw new HTTPException\BadRequestException('list_id not specified');
}
// params
$start = max(0, ($page - 1) * $count);
- $groups = DBA::selectToArray('group_member', ['contact-id'], ['gid' => $request['list_id']]);
+ $groups = $this->dba->selectToArray('group_member', ['contact-id'], ['gid' => $request['list_id']]);
$gids = array_column($groups, 'contact-id');
$condition = ['uid' => $uid, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'contact-id' => $gids];
$condition = DBA::mergeConditions($condition, ["`id` > ?", $since_id]);
$include_entities = strtolower(($request['include_entities'] ?? 'false') == 'true');
$items = [];
- while ($status = DBA::fetch($statuses)) {
- $items[] = DI::twitterStatus()->createFromUriId($status['uri-id'], $status['uid'], $include_entities)->toArray();
+ while ($status = $this->dba->fetch($statuses)) {
+ $items[] = $this->twitterStatus->createFromUriId($status['uri-id'], $status['uid'], $include_entities)->toArray();
}
- DBA::close($statuses);
+ $this->dba->close($statuses);
$this->response->exit('statuses', ['status' => $items], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
}
namespace Friendica\Module\Api\Twitter\Lists;
-use Friendica\Database\DBA;
-use Friendica\DI;
+use Friendica\App;
+use Friendica\Core\L10n;
+use Friendica\Database\Database;
+use Friendica\Factory\Api\Friendica\Group as FriendicaGroup;
use Friendica\Module\BaseApi;
use Friendica\Model\Contact;
use Friendica\Model\Group;
+use Friendica\Module\Api\ApiResponse;
use Friendica\Network\HTTPException;
+use Friendica\Util\Profiler;
+use Psr\Log\LoggerInterface;
/**
* Update information about a group.
*/
class Update extends BaseApi
{
+ /** @var friendicaGroup */
+ private $friendicaGroup;
+
+ /** @var Database */
+ private $dba;
+
+ public function __construct(Database $dba, FriendicaGroup $friendicaGroup, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
+ {
+ parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
+
+ $this->dba = $dba;
+ $this->friendicaGroup = $friendicaGroup;
+ }
+
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
}
// get data of the specified group id
- $group = DBA::selectFirst('group', [], ['uid' => $uid, 'id' => $gid]);
+ $group = $this->dba->selectFirst('group', [], ['uid' => $uid, 'id' => $gid]);
// error message if specified gid is not in database
if (!$group) {
throw new HTTPException\BadRequestException('gid not available');
}
if (Group::update($gid, $name)) {
- $list = DI::friendicaGroup()->createFromId($gid);
+ $list = $this->friendicaGroup->createFromId($gid);
$this->response->exit('statuses', ['lists' => ['lists' => $list]], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
}