summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2019-05-06 18:45:09 -0100
committerMaxence Lange <maxence@artificial-owl.com>2019-05-06 18:45:09 -0100
commit109680149a5e1b433164cf634c5be233b002e3e9 (patch)
treebfe867a8cc128ec433e2bfe1e6b36ba92223bea8 /lib
parent88a0d72740dc8c3bff670f013f04eda758f8940a (diff)
+limitToType
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Controller/LocalController.php3
-rw-r--r--lib/Db/NotesRequest.php10
-rw-r--r--lib/Interfaces/Object/AnnounceInterface.php8
-rw-r--r--lib/Interfaces/Object/NoteInterface.php2
-rw-r--r--lib/Service/BoostService.php4
-rw-r--r--lib/Service/NoteService.php5
6 files changed, 18 insertions, 14 deletions
diff --git a/lib/Controller/LocalController.php b/lib/Controller/LocalController.php
index 5f68a7fe..5e7dcd6a 100644
--- a/lib/Controller/LocalController.php
+++ b/lib/Controller/LocalController.php
@@ -37,6 +37,7 @@ use OCA\Social\AppInfo\Application;
use OCA\Social\Exceptions\AccountDoesNotExistException;
use OCA\Social\Exceptions\InvalidResourceException;
use OCA\Social\Model\ActivityPub\Actor\Person;
+use OCA\Social\Model\ActivityPub\Object\Note;
use OCA\Social\Model\ActivityPub\Stream;
use OCA\Social\Model\Post;
use OCA\Social\Service\AccountService;
@@ -191,7 +192,7 @@ class LocalController extends Controller {
throw new InvalidResourceException('user have no rights');
}
- $this->noteService->deleteLocalItem($note);
+ $this->noteService->deleteLocalItem($note, Note::TYPE);
return $this->success();
} catch (Exception $e) {
diff --git a/lib/Db/NotesRequest.php b/lib/Db/NotesRequest.php
index 5a8bb8c1..f9267366 100644
--- a/lib/Db/NotesRequest.php
+++ b/lib/Db/NotesRequest.php
@@ -155,7 +155,7 @@ class NotesRequest extends NotesRequestBuilder {
$qb = $this->getNotesSelectSql();
$this->limitToIdString($qb, $id);
- $this->limitToType($qb, Note::TYPE);
+// $this->limitToType($qb, Note::TYPE);
if ($asViewer) {
$this->limitToViewer($qb);
@@ -510,11 +510,15 @@ class NotesRequest extends NotesRequestBuilder {
/**
* @param string $id
+ * @param string $type
*/
- public function deleteNoteById(string $id) {
+ public function deleteNoteById(string $id, string $type = '') {
$qb = $this->getNotesDeleteSql();
- $this->limitToType($qb, Note::TYPE);
+
$this->limitToIdString($qb, $id);
+ if ($type !== '') {
+ $this->limitToType($qb, $type);
+ }
$qb->execute();
}
diff --git a/lib/Interfaces/Object/AnnounceInterface.php b/lib/Interfaces/Object/AnnounceInterface.php
index efb63461..c71f23f5 100644
--- a/lib/Interfaces/Object/AnnounceInterface.php
+++ b/lib/Interfaces/Object/AnnounceInterface.php
@@ -154,10 +154,10 @@ class AnnounceInterface implements IActivityPubInterface {
*/
public function delete(ACore $item) {
try {
- $stream = $this->notesRequest->getNoteById($item->getId());
- if ($stream->getType() === Announce::TYPE) {
- $this->notesRequest->deleteNoteById($item->getId());
- }
+// $stream = $this->notesRequest->getNoteById($item->getId());
+// if ($stream->getType() === Announce::TYPE) {
+ $this->notesRequest->deleteNoteById($item->getId(), Announce::TYPE);
+// }
} catch (NoteNotFoundException $e) {
}
}
diff --git a/lib/Interfaces/Object/NoteInterface.php b/lib/Interfaces/Object/NoteInterface.php
index d807ab98..c77d14bb 100644
--- a/lib/Interfaces/Object/NoteInterface.php
+++ b/lib/Interfaces/Object/NoteInterface.php
@@ -149,7 +149,7 @@ class NoteInterface implements IActivityPubInterface {
$item->checkOrigin(($item->getId()));
/** @var Note $item */
- $this->notesRequest->deleteNoteById($item->getId());
+ $this->notesRequest->deleteNoteById($item->getId(), Note::TYPE);
}
diff --git a/lib/Service/BoostService.php b/lib/Service/BoostService.php
index a23bf956..87c4433e 100644
--- a/lib/Service/BoostService.php
+++ b/lib/Service/BoostService.php
@@ -171,9 +171,7 @@ class BoostService {
* @param string $token
*
* @return ACore
- * @throws ItemUnknownException
* @throws NoteNotFoundException
- * @throws RedundancyLimitException
* @throws SocialAppConfigException
*/
public function delete(Person $actor, string $postId, &$token = ''): ACore {
@@ -191,7 +189,7 @@ class BoostService {
$undo->setObject($announce);
$undo->setCcArray($announce->getCcArray());
- $this->notesRequest->deleteNoteById($announce->getId());
+ $this->notesRequest->deleteNoteById($announce->getId(), Announce::TYPE);
$this->streamActionService->setActionBool($actor->getId(), $postId, 'boosted', false);
$this->signatureService->signObject($actor, $undo);
diff --git a/lib/Service/NoteService.php b/lib/Service/NoteService.php
index 3ebdf223..864f7609 100644
--- a/lib/Service/NoteService.php
+++ b/lib/Service/NoteService.php
@@ -313,17 +313,18 @@ class NoteService {
/**
* @param Stream $item
+ * @param string $type
*
* @throws Exception
*/
- public function deleteLocalItem(Stream $item) {
+ public function deleteLocalItem(Stream $item, string $type = '') {
if (!$item->isLocal()) {
return;
}
$item->setActorId($item->getAttributedTo());
$this->activityService->deleteActivity($item);
- $this->notesRequest->deleteNoteById($item->getId());
+ $this->notesRequest->deleteNoteById($item->getId(), $type);
}