From: Hypolite Petovan Date: Wed, 14 Dec 2022 15:01:01 +0000 (-0500) Subject: Add Posts and Rules sub-entities and collections for Moderation\Report X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d29a84ae461d75b14473157b842a025380433b5b;p=friendica.git Add Posts and Rules sub-entities and collections for Moderation\Report --- diff --git a/src/Moderation/Collection/Report/Posts.php b/src/Moderation/Collection/Report/Posts.php new file mode 100644 index 0000000000..374654dc37 --- /dev/null +++ b/src/Moderation/Collection/Report/Posts.php @@ -0,0 +1,33 @@ +. + * + */ + +namespace Friendica\Moderation\Collection\Report; + +class Posts extends \Friendica\BaseCollection +{ + /** + * @return \Friendica\Moderation\Entity\Report\Post + */ + public function current(): \Friendica\Moderation\Entity\Report\Post + { + return parent::current(); + } +} diff --git a/src/Moderation/Collection/Report/Rules.php b/src/Moderation/Collection/Report/Rules.php new file mode 100644 index 0000000000..4803c6bda6 --- /dev/null +++ b/src/Moderation/Collection/Report/Rules.php @@ -0,0 +1,33 @@ +. + * + */ + +namespace Friendica\Moderation\Collection\Report; + +class Rules extends \Friendica\BaseCollection +{ + /** + * @return \Friendica\Moderation\Entity\Report\Rule + */ + public function current(): \Friendica\Moderation\Entity\Report\Rule + { + return parent::current(); + } +} diff --git a/src/Moderation/Entity/Report/Post.php b/src/Moderation/Entity/Report/Post.php new file mode 100644 index 0000000000..956052a30e --- /dev/null +++ b/src/Moderation/Entity/Report/Post.php @@ -0,0 +1,44 @@ +. + * + */ + +namespace Friendica\Moderation\Entity\Report; + +/** + * @property-read int $uriId URI Id of the reported post + * @property-read int $status One of STATUS_* + */ +final class Post extends \Friendica\BaseEntity +{ + const STATUS_NO_ACTION = 0; + const STATUS_UNLISTED = 1; + const STATUS_DELETED = 2; + + /** @var int */ + protected $uriId; + /** @var int|null */ + protected $status; + + public function __construct(int $uriId, int $status = self::STATUS_NO_ACTION) + { + $this->uriId = $uriId; + $this->status = $status; + } +} diff --git a/src/Moderation/Entity/Report/Rule.php b/src/Moderation/Entity/Report/Rule.php new file mode 100644 index 0000000000..3d1d1f8d1e --- /dev/null +++ b/src/Moderation/Entity/Report/Rule.php @@ -0,0 +1,40 @@ +. + * + */ + +namespace Friendica\Moderation\Entity\Report; + +/** + * @property-read int $lineId Terms of service text line number + * @property-read string $text Terms of service rule text + */ +final class Rule extends \Friendica\BaseEntity +{ + /** @var int */ + protected $lineId; + /** @var string */ + protected $text; + + public function __construct(int $lineId, string $text) + { + $this->lineId = $lineId; + $this->text = $text; + } +} diff --git a/src/Moderation/Factory/Report/Post.php b/src/Moderation/Factory/Report/Post.php new file mode 100644 index 0000000000..f70460a28b --- /dev/null +++ b/src/Moderation/Factory/Report/Post.php @@ -0,0 +1,35 @@ +. + * + */ + +namespace Friendica\Moderation\Factory\Report; + +use Friendica\Capabilities\ICanCreateFromTableRow; + +class Post extends \Friendica\BaseFactory implements ICanCreateFromTableRow +{ + public function createFromTableRow(array $row): \Friendica\Moderation\Entity\Report\Post + { + return new \Friendica\Moderation\Entity\Report\Post( + $row['uri-id'], + $row['status'] + ); + } +} diff --git a/src/Moderation/Factory/Report/Rule.php b/src/Moderation/Factory/Report/Rule.php new file mode 100644 index 0000000000..334570630f --- /dev/null +++ b/src/Moderation/Factory/Report/Rule.php @@ -0,0 +1,35 @@ +. + * + */ + +namespace Friendica\Moderation\Factory\Report; + +use Friendica\Capabilities\ICanCreateFromTableRow; + +class Rule extends \Friendica\BaseFactory implements ICanCreateFromTableRow +{ + public function createFromTableRow(array $row): \Friendica\Moderation\Entity\Report\Rule + { + return new \Friendica\Moderation\Entity\Report\Rule( + $row['line-id'], + $row['text'] + ); + } +}