Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
pull/113/head
Maxence Lange 2018-12-03 20:03:22 -01:00
rodzic c45cfe6b49
commit 55600ee628
8 zmienionych plików z 68 dodań i 24 usunięć

Wyświetl plik

@ -130,5 +130,13 @@ class DeleteService implements ICoreService {
public function delete(ACore $item) {
}
/**
* @param ACore $item
*/
public function save(ACore $item) {
}
}

Wyświetl plik

@ -167,14 +167,20 @@ class DocumentService implements ICoreService {
* @param ACore $item
*/
public function parse(ACore $item) {
// TODO: Implement parse() method.
}
/**
* @param ACore $item
*/
public function save(ACore $item) {
}
/**
* @param ACore $item
*/
public function delete(ACore $item) {
// TODO: Implement delete() method.
}
}

Wyświetl plik

@ -276,6 +276,13 @@ class FollowService implements ICoreService {
}
/**
* @param ACore $item
*/
public function save(ACore $item) {
}
/**
* @param ACore $item
*/

Wyświetl plik

@ -48,6 +48,12 @@ interface ICoreService {
public function parse(ACore $item);
/**
* @param ACore $item
*/
public function save(ACore $item);
/**
* @param ACore $item
*/

Wyświetl plik

@ -276,11 +276,21 @@ class NoteService implements ICoreService {
if ($parent->getType() === Create::TYPE) {
$parent->checkOrigin($note->getAttributedTo());
try {
$this->notesRequest->getNoteById($note->getId());
} catch (NoteNotFoundException $e) {
$this->notesRequest->save($note);
}
$this->save($note);
}
}
/**
* @param ACore $note
*/
public function save(ACore $note) {
/** @var Note $note */
try {
$this->notesRequest->getNoteById($note->getId());
} catch (NoteNotFoundException $e) {
$this->notesRequest->save($note);
}
}

Wyświetl plik

@ -125,7 +125,7 @@ class PersonService implements ICoreService {
$actor->setLocal(true);
$actor->setSource(json_encode($actor, JSON_UNESCAPED_SLASHES));
$this->parse($actor);
$this->save($actor);
}
@ -160,7 +160,7 @@ class PersonService implements ICoreService {
$actor = $this->generateActorFromObject($object);
$actor->setAccount($actor->getPreferredUsername() . '@' . $this->get('_host', $object));
try {
$this->parse($actor);
$this->save($actor);
} catch (Exception $e) {
throw new InvalidResourceException($e->getMessage());
}
@ -196,7 +196,7 @@ class PersonService implements ICoreService {
$actor = $this->generateActorFromObject($object);
$actor->setAccount($account);
try {
$this->parse($actor);
$this->save($actor);
} catch (Exception $e) {
throw new InvalidResourceException($e->getMessage());
}
@ -261,6 +261,15 @@ class PersonService implements ICoreService {
return;
}
$this->save($person);
}
/**
* @param ACore $person
*/
public function save(ACore $person) {
/** @var Person $person */
if ($person->gotIcon()) {
try {
$icon = $this->cacheDocumentsRequest->getBySource(

Wyświetl plik

@ -62,6 +62,13 @@ class UndoService implements ICoreService {
}
/**
* @param ACore $item
*/
public function save(ACore $item) {
}
/**
* @param ACore $item
*/

Wyświetl plik

@ -153,8 +153,7 @@ class ActivityService {
* @return string
* @throws Exception
*/
public function createActivity(Person $actor, ACore $item, ACore &$activity = null
): string {
public function createActivity(Person $actor, ACore $item, ACore &$activity = null): string {
$activity = new Create();
$item->setParent($activity);
@ -233,7 +232,7 @@ class ActivityService {
* @throws Exception
*/
public function request(ACore $activity): string {
$this->setupCore($activity);
$this->saveActivity($activity);
$author = $this->getAuthorFromItem($activity);
$instancePaths = $this->generateInstancePaths($activity);
@ -593,24 +592,16 @@ class ActivityService {
/**
* @deprecated !??? - do we need this !?
*
* @param ACore $activity
*/
private function setupCore(ACore $activity) {
// $this->initCore($activity);
if ($activity->isRoot()) {
$activity->addEntry('@context', self::CONTEXT_ACTIVITYSTREAMS);
}
private function saveActivity(ACore $activity) {
$coreService = $activity->savingAs();
if ($coreService !== null) {
$coreService->parse($activity);
$coreService->save($activity);
}
if ($activity->gotObject()) {
$this->setupCore($activity->getObject());
$this->saveActivity($activity->getObject());
}
}