summaryrefslogtreecommitdiffstats
path: root/lib/Model/ActivityPub/Stream.php
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2019-04-08 15:52:03 -0100
committerMaxence Lange <maxence@artificial-owl.com>2019-05-03 16:31:15 -0100
commitb4d773940c9d6c601a2dc9a2ba39c0f6348e9545 (patch)
tree4b0ae964c51e8e8c8fc2f5411a180c177bc71858 /lib/Model/ActivityPub/Stream.php
parent36f7b7290bfab599610b779d83b12806fddacfce (diff)
Returns if a post is boosted, and allow unboost
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib/Model/ActivityPub/Stream.php')
-rw-r--r--lib/Model/ActivityPub/Stream.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/Model/ActivityPub/Stream.php b/lib/Model/ActivityPub/Stream.php
index f9cf86f2..dc0ff248 100644
--- a/lib/Model/ActivityPub/Stream.php
+++ b/lib/Model/ActivityPub/Stream.php
@@ -33,7 +33,9 @@ namespace OCA\Social\Model\ActivityPub;
use daita\MySmallPhpTools\Model\Cache;
use daita\MySmallPhpTools\Model\CacheItem;
use DateTime;
+use Exception;
use JsonSerializable;
+use OCA\Social\Model\StreamAction;
class Stream extends ACore implements JsonSerializable {
@@ -69,6 +71,9 @@ class Stream extends ACore implements JsonSerializable {
/** @var int */
private $publishedTime = 0;
+ /** @var StreamAction */
+ private $action = null;
+
public function __construct($parent = null) {
parent::__construct($parent);
@@ -208,6 +213,7 @@ class Stream extends ACore implements JsonSerializable {
/**
*
+ * @throws Exception
*/
public function convertPublished() {
$dTime = new DateTime($this->getPublished());
@@ -255,6 +261,37 @@ class Stream extends ACore implements JsonSerializable {
}
+ /**
+ * @return StreamAction
+ */
+ public function getAction(): StreamAction {
+ return $this->action;
+ }
+
+ /**
+ * @param StreamAction $action
+ *
+ * @return Stream
+ */
+ public function setAction(StreamAction $action): Stream {
+ $this->action = $action;
+
+ return $this;
+ }
+
+ /**
+ * @return bool
+ */
+ public function hasAction(): bool {
+ return ($this->action !== null);
+ }
+
+
+ /**
+ * @param array $data
+ *
+ * @throws Exception
+ */
public function import(array $data) {
parent::import($data);
@@ -270,6 +307,8 @@ class Stream extends ACore implements JsonSerializable {
/**
* @param array $data
+ *
+ * @throws Exception
*/
public function importFromDatabase(array $data) {
parent::importFromDatabase($data);
@@ -310,6 +349,7 @@ class Stream extends ACore implements JsonSerializable {
$result = array_merge(
$result,
[
+ 'action' => ($this->hasAction()) ? $this->getAction() : [],
'cache' => ($this->gotCache()) ? $this->getCache() : '',
'publishedTime' => $this->getPublishedTime()
]