summaryrefslogtreecommitdiffstats
path: root/lib/Db/ActionsRequest.php
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2019-07-08 13:42:16 -0100
committerMaxence Lange <maxence@artificial-owl.com>2019-07-08 13:42:16 -0100
commit57291f5b1df32bdc15a8c57848e8e8208c3fd531 (patch)
tree830b3b4feb1d8b0139c3ffba8aa19e4d2c0340ec /lib/Db/ActionsRequest.php
parent85242a82a14147e6a9fced9897326d38280ad6b3 (diff)
like/unlike post
Signed-off-by: Maxence Lange <maxence@artificial-owl.com> post like Signed-off-by: Maxence Lange <maxence@artificial-owl.com> better managing between save/delete Signed-off-by: Maxence Lange <maxence@artificial-owl.com> delete undoAction Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib/Db/ActionsRequest.php')
-rw-r--r--lib/Db/ActionsRequest.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/Db/ActionsRequest.php b/lib/Db/ActionsRequest.php
index cb01c5fc..979164ea 100644
--- a/lib/Db/ActionsRequest.php
+++ b/lib/Db/ActionsRequest.php
@@ -104,6 +104,29 @@ class ActionsRequest extends ActionsRequestBuilder {
/**
+ * @param ACore $item
+ *
+ * @return ACore
+ * @throws ActionDoesNotExistException
+ */
+ public function getActionFromItem(ACore $item): ACore {
+ $qb = $this->getActionsSelectSql();
+ $this->limitToActorId($qb, $item->getActorId());
+ $this->limitToObjectId($qb, $item->getObjectId());
+ $this->limitToType($qb, $item->getType());
+
+ $cursor = $qb->execute();
+ $data = $cursor->fetch();
+ $cursor->closeCursor();
+ if ($data === false) {
+ throw new ActionDoesNotExistException();
+ }
+
+ return $this->parseActionsSelectSql($data);
+ }
+
+
+ /**
* @param string $objectId
* @param string $type
*
@@ -149,6 +172,7 @@ class ActionsRequest extends ActionsRequestBuilder {
public function delete(ACore $item) {
$qb = $this->getActionsDeleteSql();
$this->limitToIdString($qb, $item->getId());
+ $this->limitToType($qb, $item->getType());
$qb->execute();
}