kopia lustrzana https://github.com/nextcloud/social
rodzic
17b7b5a8c1
commit
0aed4f797e
|
@ -109,7 +109,9 @@ class LikeInterface extends AbstractActivityPubInterface implements IActivityPub
|
||||||
public function getItem(ACore $item): ACore {
|
public function getItem(ACore $item): ACore {
|
||||||
try {
|
try {
|
||||||
return $this->actionsRequest->getAction(
|
return $this->actionsRequest->getAction(
|
||||||
$item->getActorId(), $item->getObjectId(), Like::TYPE
|
$item->getActorId(),
|
||||||
|
$item->getObjectId(),
|
||||||
|
Like::TYPE
|
||||||
);
|
);
|
||||||
} catch (ActionDoesNotExistException $e) {
|
} catch (ActionDoesNotExistException $e) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,11 +37,12 @@ use OCA\Social\Exceptions\InvalidResourceEntryException;
|
||||||
use OCA\Social\Exceptions\UrlCloudException;
|
use OCA\Social\Exceptions\UrlCloudException;
|
||||||
use OCA\Social\Model\ActivityPub\Object\Document;
|
use OCA\Social\Model\ActivityPub\Object\Document;
|
||||||
use OCA\Social\Model\LinkedDataSignature;
|
use OCA\Social\Model\LinkedDataSignature;
|
||||||
|
use OCA\Social\Tools\IQueryRow;
|
||||||
use OCA\Social\Tools\Traits\TArrayTools;
|
use OCA\Social\Tools\Traits\TArrayTools;
|
||||||
use OCA\Social\Tools\Traits\TPathTools;
|
use OCA\Social\Tools\Traits\TPathTools;
|
||||||
use OCA\Social\Tools\Traits\TStringTools;
|
use OCA\Social\Tools\Traits\TStringTools;
|
||||||
|
|
||||||
class ACore extends Item implements JsonSerializable {
|
class ACore extends Item implements JsonSerializable, IQueryRow {
|
||||||
use TArrayTools;
|
use TArrayTools;
|
||||||
use TStringTools;
|
use TStringTools;
|
||||||
use TPathTools;
|
use TPathTools;
|
||||||
|
|
|
@ -40,6 +40,7 @@ class ActionService {
|
||||||
|
|
||||||
private StreamService $streamService;
|
private StreamService $streamService;
|
||||||
private BoostService $boostService;
|
private BoostService $boostService;
|
||||||
|
private LikeService $likeService;
|
||||||
private StreamActionService $streamActionService;
|
private StreamActionService $streamActionService;
|
||||||
|
|
||||||
private const TRANSLATE = 'translate';
|
private const TRANSLATE = 'translate';
|
||||||
|
@ -71,10 +72,12 @@ class ActionService {
|
||||||
public function __construct(
|
public function __construct(
|
||||||
StreamService $streamService,
|
StreamService $streamService,
|
||||||
BoostService $boostService,
|
BoostService $boostService,
|
||||||
|
LikeService $likeService,
|
||||||
StreamActionService $streamActionService
|
StreamActionService $streamActionService
|
||||||
) {
|
) {
|
||||||
$this->streamService = $streamService;
|
$this->streamService = $streamService;
|
||||||
$this->boostService = $boostService;
|
$this->boostService = $boostService;
|
||||||
|
$this->likeService = $likeService;
|
||||||
$this->streamActionService = $streamActionService;
|
$this->streamActionService = $streamActionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,8 +137,11 @@ class ActionService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private function favourite(Person $actor, string $postId, bool $enabled = true): void {
|
private function favourite(Person $actor, string $postId, bool $enabled = true): void {
|
||||||
$this->boostService->delete($actor, $postId);
|
if ($enabled) {
|
||||||
// $this->streamActionService->setActionBool($actor->getId(), $postId, StreamAction::LIKED, $enabled);
|
$this->likeService->create($actor, $postId);
|
||||||
|
} else {
|
||||||
|
$this->likeService->delete($actor, $postId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function reblog(Person $actor, string $postId, bool $enabled = true): void {
|
private function reblog(Person $actor, string $postId, bool $enabled = true): void {
|
||||||
|
|
|
@ -108,7 +108,7 @@ class LikeService {
|
||||||
* @throws SocialAppConfigException
|
* @throws SocialAppConfigException
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function create(Person $actor, string $postId, &$token = ''): ACore {
|
public function create(Person $actor, string $postId, string &$token = ''): ACore {
|
||||||
/** @var Like $like */
|
/** @var Like $like */
|
||||||
$like = AP::$activityPub->getItemFromType(Like::TYPE);
|
$like = AP::$activityPub->getItemFromType(Like::TYPE);
|
||||||
$like->setId($actor->getId() . '#like/' . $this->uuid(8));
|
$like->setId($actor->getId() . '#like/' . $this->uuid(8));
|
||||||
|
@ -160,7 +160,7 @@ class LikeService {
|
||||||
* @throws SocialAppConfigException
|
* @throws SocialAppConfigException
|
||||||
* @throws StreamNotFoundException
|
* @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 = new Undo();
|
||||||
$undo->setActor($actor);
|
$undo->setActor($actor);
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue