kopia lustrzana https://github.com/nextcloud/social
+limitToType
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/282/head
rodzic
88a0d72740
commit
109680149a
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue