summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouis <6653109+artonge@users.noreply.github.com>2023-03-21 12:45:42 +0100
committerGitHub <noreply@github.com>2023-03-21 12:45:42 +0100
commit7f362c6c20c247bbb8eb9783f1b07e8d36262418 (patch)
tree61315c701c7fd576f5842f7aa75a05d051ad76e7
parent17b7b5a8c14e0483ca2aeed17047e8b4cc1260d6 (diff)
parent0aed4f797e941c4eba4f96d74d17fae8bf35d97b (diff)
Merge pull request #1691 from nextcloud/fix/noid/like-2
fix like
-rw-r--r--lib/Interfaces/Object/LikeInterface.php4
-rw-r--r--lib/Model/ActivityPub/ACore.php3
-rw-r--r--lib/Service/ActionService.php10
-rw-r--r--lib/Service/LikeService.php4
4 files changed, 15 insertions, 6 deletions
diff --git a/lib/Interfaces/Object/LikeInterface.php b/lib/Interfaces/Object/LikeInterface.php
index da08ab8e..27039305 100644
--- a/lib/Interfaces/Object/LikeInterface.php
+++ b/lib/Interfaces/Object/LikeInterface.php
@@ -109,7 +109,9 @@ class LikeInterface extends AbstractActivityPubInterface implements IActivityPub
public function getItem(ACore $item): ACore {
try {
return $this->actionsRequest->getAction(
- $item->getActorId(), $item->getObjectId(), Like::TYPE
+ $item->getActorId(),
+ $item->getObjectId(),
+ Like::TYPE
);
} catch (ActionDoesNotExistException $e) {
}
diff --git a/lib/Model/ActivityPub/ACore.php b/lib/Model/ActivityPub/ACore.php
index a30d2197..7b950a69 100644
--- a/lib/Model/ActivityPub/ACore.php
+++ b/lib/Model/ActivityPub/ACore.php
@@ -37,11 +37,12 @@ use OCA\Social\Exceptions\InvalidResourceEntryException;
use OCA\Social\Exceptions\UrlCloudException;
use OCA\Social\Model\ActivityPub\Object\Document;
use OCA\Social\Model\LinkedDataSignature;
+use OCA\Social\Tools\IQueryRow;
use OCA\Social\Tools\Traits\TArrayTools;
use OCA\Social\Tools\Traits\TPathTools;
use OCA\Social\Tools\Traits\TStringTools;
-class ACore extends Item implements JsonSerializable {
+class ACore extends Item implements JsonSerializable, IQueryRow {
use TArrayTools;
use TStringTools;
use TPathTools;
diff --git a/lib/Service/ActionService.php b/lib/Service/ActionService.php
index b318c795..08c81aa1 100644
--- a/lib/Service/ActionService.php
+++ b/lib/Service/ActionService.php
@@ -40,6 +40,7 @@ class ActionService {
private StreamService $streamService;
private BoostService $boostService;
+ private LikeService $likeService;
private StreamActionService $streamActionService;
private const TRANSLATE = 'translate';
@@ -71,10 +72,12 @@ class ActionService {
public function __construct(
StreamService $streamService,
BoostService $boostService,
+ LikeService $likeService,
StreamActionService $streamActionService
) {
$this->streamService = $streamService;
$this->boostService = $boostService;
+ $this->likeService = $likeService;
$this->streamActionService = $streamActionService;
}
@@ -134,8 +137,11 @@ class ActionService {
}
private function favourite(Person $actor, string $postId, bool $enabled = true): void {
- $this->boostService->delete($actor, $postId);
-// $this->streamActionService->setActionBool($actor->getId(), $postId, StreamAction::LIKED, $enabled);
+ if ($enabled) {
+ $this->likeService->create($actor, $postId);
+ } else {
+ $this->likeService->delete($actor, $postId);
+ }
}
private function reblog(Person $actor, string $postId, bool $enabled = true): void {
diff --git a/lib/Service/LikeService.php b/lib/Service/LikeService.php
index b70e4bde..b8f6ab34 100644
--- a/lib/Service/LikeService.php
+++ b/lib/Service/LikeService.php
@@ -108,7 +108,7 @@ class LikeService {
* @throws SocialAppConfigException
* @throws Exception
*/
- public function create(Person $actor, string $postId, &$token = ''): ACore {
+ public function create(Person $actor, string $postId, string &$token = ''): ACore {
/** @var Like $like */
$like = AP::$activityPub->getItemFromType(Like::TYPE);
$like->setId($actor->getId() . '#like/' . $this->uuid(8));
@@ -160,7 +160,7 @@ class LikeService {
* @throws SocialAppConfigException
* @throws StreamNotFoundException
*/
- public function delete(Person $actor, string $postId, &$token = ''): ACore {
+ public function delete(Person $actor, string $postId, string &$token = ''): ACore {
$undo = new Undo();
$undo->setActor($actor);