Move Mastodon API factories to Factory\Api\Mastodon
This commit is contained in:
parent
75a2190af5
commit
1ac9107e5f
5 changed files with 60 additions and 14 deletions
18
src/DI.php
18
src/DI.php
|
@ -141,7 +141,7 @@ abstract class DI
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Friendica\Core\PConfig\IPConfig
|
* @return Core\PConfig\IPConfig
|
||||||
*/
|
*/
|
||||||
public static function pConfig()
|
public static function pConfig()
|
||||||
{
|
{
|
||||||
|
@ -221,31 +221,31 @@ abstract class DI
|
||||||
//
|
//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Factory\Mastodon\Account
|
* @return Factory\Api\Mastodon\Account
|
||||||
*/
|
*/
|
||||||
public static function mstdnAccount()
|
public static function mstdnAccount()
|
||||||
{
|
{
|
||||||
return self::$dice->create(Factory\Mastodon\Account::class);
|
return self::$dice->create(Factory\Api\Mastodon\Account::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Factory\Mastodon\FollowRequest
|
* @return Factory\Api\Mastodon\FollowRequest
|
||||||
*/
|
*/
|
||||||
public static function mstdnFollowRequest()
|
public static function mstdnFollowRequest()
|
||||||
{
|
{
|
||||||
return self::$dice->create(Factory\Mastodon\FollowRequest::class);
|
return self::$dice->create(Factory\Api\Mastodon\FollowRequest::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Factory\Mastodon\Relationship
|
* @return Factory\Api\Mastodon\Relationship
|
||||||
*/
|
*/
|
||||||
public static function mstdnRelationship()
|
public static function mstdnRelationship()
|
||||||
{
|
{
|
||||||
return self::$dice->create(Factory\Mastodon\Relationship::class);
|
return self::$dice->create(Factory\Api\Mastodon\Relationship::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Friendica\Factory\Notification\Notification
|
* @return Factory\Notification\Notification
|
||||||
*/
|
*/
|
||||||
public static function notification()
|
public static function notification()
|
||||||
{
|
{
|
||||||
|
@ -253,7 +253,7 @@ abstract class DI
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Friendica\Factory\Notification\Introduction
|
* @return Factory\Notification\Introduction
|
||||||
*/
|
*/
|
||||||
public static function notificationIntro()
|
public static function notificationIntro()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Friendica\Factory\Mastodon;
|
namespace Friendica\Factory\Api\Mastodon;
|
||||||
|
|
||||||
use Friendica\App\BaseURL;
|
use Friendica\App\BaseURL;
|
||||||
|
use Friendica\BaseFactory;
|
||||||
use Friendica\Model\APContact;
|
use Friendica\Model\APContact;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
use Friendica\BaseFactory;
|
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class Account extends BaseFactory
|
class Account extends BaseFactory
|
46
src/Factory/Api/Mastodon/Emoji.php
Normal file
46
src/Factory/Api/Mastodon/Emoji.php
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Friendica\Factory\Api\Mastodon;
|
||||||
|
|
||||||
|
use Friendica\App\BaseURL;
|
||||||
|
use Friendica\BaseFactory;
|
||||||
|
use Friendica\Model\APContact;
|
||||||
|
use Friendica\Model\Contact;
|
||||||
|
use Friendica\Network\HTTPException;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
|
class Emoji extends BaseFactory
|
||||||
|
{
|
||||||
|
/** @var BaseURL */
|
||||||
|
protected $baseUrl;
|
||||||
|
|
||||||
|
public function __construct(LoggerInterface $logger, BaseURL $baseURL)
|
||||||
|
{
|
||||||
|
parent::__construct($logger);
|
||||||
|
|
||||||
|
$this->baseUrl = $baseURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $contactId
|
||||||
|
* @param int $uid User Id
|
||||||
|
* @return \Friendica\Api\Entity\Mastodon\Account
|
||||||
|
* @throws HTTPException\InternalServerErrorException
|
||||||
|
* @throws \ImagickException
|
||||||
|
*/
|
||||||
|
public function createFromContactId(int $contactId, $uid = 0)
|
||||||
|
{
|
||||||
|
$cdata = Contact::getPublicAndUserContacID($contactId, $uid);
|
||||||
|
if (!empty($cdata)) {
|
||||||
|
$publicContact = Contact::getById($cdata['public']);
|
||||||
|
$userContact = Contact::getById($cdata['user']);
|
||||||
|
} else {
|
||||||
|
$publicContact = Contact::getById($contactId);
|
||||||
|
$userContact = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$apcontact = APContact::getByURL($publicContact['url'], false);
|
||||||
|
|
||||||
|
return new \Friendica\Api\Entity\Mastodon\Account($this->baseUrl, $publicContact, $apcontact, $userContact);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Friendica\Factory\Mastodon;
|
namespace Friendica\Factory\Api\Mastodon;
|
||||||
|
|
||||||
use Friendica\App\BaseURL;
|
use Friendica\App\BaseURL;
|
||||||
|
use Friendica\BaseFactory;
|
||||||
use Friendica\Model\APContact;
|
use Friendica\Model\APContact;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Introduction;
|
use Friendica\Model\Introduction;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
use Friendica\BaseFactory;
|
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class FollowRequest extends BaseFactory
|
class FollowRequest extends BaseFactory
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Friendica\Factory\Mastodon;
|
namespace Friendica\Factory\Api\Mastodon;
|
||||||
|
|
||||||
use Friendica\Object\Api\Mastodon\Relationship as RelationshipEntity;
|
use Friendica\Object\Api\Mastodon\Relationship as RelationshipEntity;
|
||||||
use Friendica\BaseFactory;
|
use Friendica\BaseFactory;
|
Loading…
Reference in a new issue