namespace Friendica;
-use Friendica\Network\HTTPException;
+use Friendica\Network\HTTPException\InternalServerErrorException;
/**
* The Entity classes directly inheriting from this abstract class are meant to represent a single business entity.
*
* Since these objects aren't meant to be using any dependency, including logging, unit tests can and must be
* written for each and all of their methods
+ *
+ * @property-read int $id
+ * @property-read int $uid
+ * @property-read string $verb
+ * @property-read int $type
+ * @property-read int $actorId
+ * @property-read int $targetUriId
+ * @property-read int $parentUriId
+ * @property-read \DateTime $created
+ * @property-read bool $seen
+ * @property-read bool $dismissed
*/
abstract class BaseEntity extends BaseDataTransferObject
{
/**
* @param string $name
* @return mixed
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
*/
public function __get(string $name)
{
if (!property_exists($this, $name)) {
- throw new HTTPException\InternalServerErrorException('Unknown property ' . $name . ' in Entity ' . static::class);
+ throw new InternalServerErrorException('Unknown property ' . $name . ' in Entity ' . static::class);
}
return $this->$name;
/**
* @param mixed $name
* @return bool
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
*/
public function __isset($name): bool
{
if (!property_exists($this, $name)) {
- throw new HTTPException\InternalServerErrorException('Unknown property ' . $name . ' of type ' . gettype($name) . ' in Entity ' . static::class);
+ throw new InternalServerErrorException('Unknown property ' . $name . ' of type ' . gettype($name) . ' in Entity ' . static::class);
}
return !empty($this->$name);
//
/**
- * @return Contact\FriendSuggest\Repository\FriendSuggest;
+ * @return Contact\FriendSuggest\Repository\FriendSuggest
*/
public static function fsuggest()
{
}
/**
- * @return Contact\FriendSuggest\Factory\FriendSuggest;
+ * @return Contact\FriendSuggest\Factory\FriendSuggest
*/
public static function fsuggestFactory()
{
namespace Friendica\Factory\Api\Mastodon;
use Friendica\BaseFactory;
-use Friendica\Content\Text\BBCode;
use Friendica\Model\Post;
use Friendica\Network\HTTPException;
-use Friendica\Util\Strings;
class Card extends BaseFactory
{
*
* @return \Friendica\Object\Api\Mastodon\Card
* @throws HTTPException\InternalServerErrorException
- * @throws \ImagickException*@throws \Exception
+ * @throws \ImagickException
+ * @throws \Exception
*/
public function createFromUriId(int $uriId, array $history = []): \Friendica\Object\Api\Mastodon\Card
{
use Friendica\BaseFactory;
use Friendica\Model\Contact;
-use Friendica\Navigation\Notifications;
+use Friendica\Navigation\Notifications\Entity\Notification as NotificationEntity;
use Friendica\Navigation\Notifications\Exception\UnexpectedNotificationTypeException;
use Friendica\Object\Api\Mastodon\Notification as MstdnNotification;
use Friendica\Protocol\Activity;
}
/**
- * @param Notifications\Entity\Notification $Notification
- * @param bool $display_quote Display quoted posts
+ * @param NotificationEntity $Notification
+ * @param bool $display_quotes Display quoted posts
*
* @return MstdnNotification
* @throws UnexpectedNotificationTypeException
*/
- public function createFromNotification(Notifications\Entity\Notification $Notification, bool $display_quotes): MstdnNotification
+ public function createFromNotification(NotificationEntity $Notification, bool $display_quotes): MstdnNotification
{
$type = self::getType($Notification);
- if (empty($type)) {
+
+ if ($type === '') {
throw new UnexpectedNotificationTypeException();
}
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Model\Verb;
-use Friendica\Network\HTTPException;
+use Friendica\Network\HTTPException\InternalServerErrorException;
+use Friendica\Network\HTTPException\NotFoundException;
use Friendica\Object\Api\Mastodon\Status\FriendicaDeliveryData;
use Friendica\Object\Api\Mastodon\Status\FriendicaExtension;
use Friendica\Object\Api\Mastodon\Status\FriendicaVisibility;
* @param bool $in_reply_status Add an "in_reply_status" element
*
* @return \Friendica\Object\Api\Mastodon\Status
- * @throws HTTPException\InternalServerErrorException
- * @throws ImagickException|HTTPException\NotFoundException
+ * @throws InternalServerErrorException
+ * @throws ImagickException|NotFoundException
*/
public function createFromUriId(int $uriId, int $uid = 0, bool $display_quote = false, bool $reblog = true, bool $in_reply_status = true): \Friendica\Object\Api\Mastodon\Status
{
if ($mail) {
return $this->createFromMailId($mail['id']);
}
- throw new HTTPException\NotFoundException('Item with URI ID ' . $uriId . ' not found' . ($uid ? ' for user ' . $uid : '.'));
+ throw new NotFoundException('Item with URI ID ' . $uriId . ' not found' . ($uid ? ' for user ' . $uid : '.'));
}
$activity_fields = ['uri-id', 'thr-parent-id', 'uri', 'author-id', 'author-uri-id', 'author-link', 'app', 'created', 'network', 'parent-author-id', 'private'];
$activity = $item;
$item = Post::selectFirst($fields, ['uri-id' => $uriId, 'uid' => [0, $uid]], ['order' => ['uid' => true]]);
if (!$item) {
- throw new HTTPException\NotFoundException('Item with URI ID ' . $uriId . ' not found' . ($uid ? ' for user ' . $uid : '.'));
+ throw new NotFoundException('Item with URI ID ' . $uriId . ' not found' . ($uid ? ' for user ' . $uid : '.'));
}
foreach ($activity_fields as $field) {
$item[$field] = $activity[$field];
$sensitive = (bool)$item['sensitive'];
$network = ContactSelector::networkToName($item['network']);
- $sitename = '';
+ $sitename = '';
$platform = '';
$version = '';
if (!empty($gserver)) {
$platform = ucfirst($gserver['platform']);
$version = $gserver['version'];
- $sitename = $gserver['site_name'];
+ $sitename = $gserver['site_name'];
}
}
}
/**
- * @param int $uriId id of the mail
+ * @param int $id id of the mail
*
* @return \Friendica\Object\Api\Mastodon\Status
- * @throws HTTPException\InternalServerErrorException
- * @throws ImagickException|HTTPException\NotFoundException
+ * @throws InternalServerErrorException
+ * @throws ImagickException|NotFoundException
*/
public function createFromMailId(int $id): \Friendica\Object\Api\Mastodon\Status
{
$item = ActivityPub\Transmitter::getItemArrayFromMail($id, true);
if (empty($item)) {
- throw new HTTPException\NotFoundException('Mail record not found with id: ' . $id);
+ throw new NotFoundException('Mail record not found with id: ' . $id);
}
$account = $this->mstdnAccountFactory->createFromContactId($item['author-id']);
*
* @return \Friendica\Object\Api\Mastodon\StatusSource
* @throws HTTPException\InternalServerErrorException
- * @throws \ImagickException*@throws \Exception
+ * @throws \ImagickException
+ * @throws \Exception
*/
public function createFromUriId(int $uriId, int $uid): \Friendica\Object\Api\Mastodon\StatusSource
{
use Friendica\BaseFactory;
use Friendica\Database\DBA;
use Friendica\Model\Subscription as ModelSubscription;
+use Friendica\Object\Api\Mastodon\Subscription as SubscriptionObject;
class Subscription extends BaseFactory
{
/**
* @param int $applicationid Application Id
* @param int $uid Item user
- *
- * @return \Friendica\Object\Api\Mastodon\Status
*/
- public function createForApplicationIdAndUserId(int $applicationid, int $uid): \Friendica\Object\Api\Mastodon\Subscription
+ public function createForApplicationIdAndUserId(int $applicationid, int $uid): SubscriptionObject
{
$subscription = DBA::selectFirst('subscription', [], ['application-id' => $applicationid, 'uid' => $uid]);
- return new \Friendica\Object\Api\Mastodon\Subscription($subscription, ModelSubscription::getPublicVapidKey());
+ return new SubscriptionObject($subscription, ModelSubscription::getPublicVapidKey());
}
}
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Model\Verb;
-use Friendica\Network\HTTPException;
+use Friendica\Network\HTTPException\InternalServerErrorException;
+use Friendica\Network\HTTPException\NotFoundException;
use Friendica\Protocol\Activity;
use ImagickException;
use Psr\Log\LoggerInterface;
}
/**
- * @param int $uriId Uri-ID of the item
+ * @param int $id Uri-ID of the item
* @param int $uid Item user
* @param bool $include_entities Whether to include entities
*
* @return \Friendica\Object\Api\Twitter\Status
- * @throws HTTPException\InternalServerErrorException
- * @throws ImagickException|HTTPException\NotFoundException
+ * @throws InternalServerErrorException
+ * @throws ImagickException|NotFoundException
*/
public function createFromItemId(int $id, int $uid, bool $include_entities = false): \Friendica\Object\Api\Twitter\Status
{
'thr-parent-id', 'parent-author-id', 'parent-author-nick', 'uri', 'plink', 'private', 'vid', 'coord', 'quote-uri-id'];
$item = Post::selectFirst($fields, ['id' => $id], ['order' => ['uid' => true]]);
if (!$item) {
- throw new HTTPException\NotFoundException('Item with ID ' . $id . ' not found.');
+ throw new NotFoundException('Item with ID ' . $id . ' not found.');
}
return $this->createFromArray($item, $uid, $include_entities);
}
* @param bool $include_entities Whether to include entities
*
* @return \Friendica\Object\Api\Twitter\Status
- * @throws HTTPException\InternalServerErrorException
- * @throws ImagickException|HTTPException\NotFoundException
+ * @throws InternalServerErrorException
+ * @throws ImagickException|NotFoundException
*/
public function createFromUriId(int $uriId, int $uid = 0, bool $include_entities = false): \Friendica\Object\Api\Twitter\Status
{
'thr-parent-id', 'parent-author-id', 'parent-author-nick', 'uri', 'plink', 'private', 'vid', 'coord'];
$item = Post::selectFirst($fields, ['uri-id' => $uriId, 'uid' => [0, $uid]], ['order' => ['uid' => true]]);
if (!$item) {
- throw new HTTPException\NotFoundException('Item with URI ID ' . $uriId . ' not found' . ($uid ? ' for user ' . $uid : '.'));
+ throw new NotFoundException('Item with URI ID ' . $uriId . ' not found' . ($uid ? ' for user ' . $uid : '.'));
}
return $this->createFromArray($item, $uid, $include_entities);
}
* @param bool $include_entities Whether to include entities
*
* @return \Friendica\Object\Api\Twitter\Status
- * @throws HTTPException\InternalServerErrorException
- * @throws ImagickException|HTTPException\NotFoundException
+ * @throws InternalServerErrorException
+ * @throws ImagickException|NotFoundException
*/
private function createFromArray(array $item, int $uid, bool $include_entities): \Friendica\Object\Api\Twitter\Status
{
if ($include_entities) {
$hashtags = $this->hashtag->createFromUriId($item['uri-id'], $text);
$medias = $this->media->createFromUriId($item['uri-id'], $text);
- $urls = $this->url->createFromUriId($item['uri-id'], $text);
- $mentions = $this->mention->createFromUriId($item['uri-id'], $text);
+ $urls = $this->url->createFromUriId($item['uri-id']);
+ $mentions = $this->mention->createFromUriId($item['uri-id']);
} else {
$attachments = $this->attachment->createFromUriId($item['uri-id'], $text);
}
if ($include_entities) {
$hashtags = array_merge($hashtags, $this->hashtag->createFromUriId($shared_uri_id, $text));
$medias = array_merge($medias, $this->media->createFromUriId($shared_uri_id, $text));
- $urls = array_merge($urls, $this->url->createFromUriId($shared_uri_id, $text));
- $mentions = array_merge($mentions, $this->mention->createFromUriId($shared_uri_id, $text));
+ $urls = array_merge($urls, $this->url->createFromUriId($shared_uri_id));
+ $mentions = array_merge($mentions, $this->mention->createFromUriId($shared_uri_id));
} else {
$attachments = array_merge($attachments, $this->attachment->createFromUriId($shared_uri_id, $text));
}
use Friendica\BaseEntity;
/**
- * @property-read $id
- * @property-read $uid
- * @property-read $verb
- * @property-read $type
- * @property-read $actorId
- * @property-read $targetUriId
- * @property-read $parentUriId
- * @property-read $created
- * @property-read $seen
- * @property-read $dismissed
+ * @property-read int $id
+ * @property-read int $uid
+ * @property-read string $verb
+ * @property-read int $type
+ * @property-read int $actorId
+ * @property-read int $targetUriId
+ * @property-read int $parentUriId
+ * @property-read DateTime $created
+ * @property-read bool $seen
+ * @property-read bool $dismissed
*/
class Notification extends BaseEntity
{
/** @var string */
protected $verb;
/**
- * @var int One of the \Friendica\Model\Post\UserNotification::TYPE_* constant values
+ * @var int $type One of the \Friendica\Model\Post\UserNotification::TYPE_* constant values
* @see \Friendica\Model\Post\UserNotification
*/
protected $type;
* Class Counts
*
* @see https://docs.joinmastodon.org/entities/status
+ *
+ * @property-read int $dislikes
*/
class Counts
{