Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
pull/282/head
Maxence Lange 2019-05-06 18:45:09 -01:00
rodzic 88a0d72740
commit 109680149a
6 zmienionych plików z 18 dodań i 14 usunięć

Wyświetl plik

@ -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) {

Wyświetl plik

@ -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();
}

Wyświetl plik

@ -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) {
}
}

Wyświetl plik

@ -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);
}

Wyświetl plik

@ -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);

Wyświetl plik

@ -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);
}