Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
pull/462/head
Maxence Lange 2019-04-08 19:13:55 -01:00
rodzic b4d773940c
commit a39d223535
3 zmienionych plików z 16 dodań i 12 usunięć

Wyświetl plik

@ -134,11 +134,11 @@ class NoteBoost extends Base {
$actor = $this->accountService->getActorFromUserId($userId);
$this->noteService->setViewer($actor);
if ($input->getOption('unboost') === null) {
$token = '';
if (!$input->getOption('unboost')) {
$activity = $this->boostService->create($actor, $noteId, $token);
} else {
$activity= $this->boostService->delete($actor, $noteId, $token );
$activity= $this->boostService->delete($actor, $noteId, $token);
}
echo 'object: ' . json_encode($activity, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";

Wyświetl plik

@ -177,14 +177,17 @@ class NotesRequest extends NotesRequestBuilder {
$qb = $this->getNotesSelectSql();
$this->limitToObjectId($qb, $objectId);
$this->limitToType($qb, $type);
$this->limitToActorId($qb, $actor->getId());
$this->limitToAttributedTo($qb, $actor->getId());
$cursor = $qb->execute();
$data = $cursor->fetch();
$cursor->closeCursor();
if ($data === false) {
throw new NoteNotFoundException('Post not found');
throw new NoteNotFoundException(
'StreamByObjectId not found - ' . $actor->getId() . ' - ' . $type . ' - '
. $objectId
);
}
return $this->parseNotesSelectSql($data);

Wyświetl plik

@ -105,6 +105,7 @@ class BoostService {
* @return ACore
* @throws NoteNotFoundException
* @throws SocialAppConfigException
* @throws Exception
*/
public function create(Person $actor, string $postId, string &$token = ''): ACore {
@ -123,10 +124,10 @@ class BoostService {
}
$announce->addCc($note->getAttributedTo());
$announce->setObjectId($note->getId());
if ($note->isLocal()) {
$announce->setObject($note);
} else {
$announce->setObjectId($note->getId());
$announce->addCacheItem($note->getId());
}
@ -159,13 +160,13 @@ class BoostService {
/**
* @param Person $actor
* @param string $postId
* @param ACore $undo
* @param string $token
*
* @return string
* @throws SocialAppConfigException
* @return ACore
* @throws NoteNotFoundException
* @throws SocialAppConfigException
*/
public function delete(Person $actor, string $postId, ACore &$undo = null): string {
public function delete(Person $actor, string $postId, string &$token = ''): ACore {
$undo = new Undo();
$this->noteService->assignItem($undo, $actor, Stream::TYPE_PUBLIC);
$undo->setActor($actor);
@ -176,6 +177,7 @@ class BoostService {
}
$announce = $this->notesRequest->getNoteByObjectId($actor, Announce::TYPE, $postId);
$undo->setObject($announce);
$undo->setCcArray($announce->getCcArray());
@ -184,9 +186,8 @@ class BoostService {
$this->signatureService->signObject($actor, $undo);
$token = $this->activityService->request($undo);
return $token;
return $undo;
}
}