Merge pull request #256 from nextcloud/origin-check-final

checking origin of the object
alpha1
Maxence Lange 2018-12-21 10:50:49 -01:00 zatwierdzone przez GitHub
commit fe8abe2db0
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
5 zmienionych plików z 24 dodań i 9 usunięć

Wyświetl plik

@ -111,10 +111,11 @@ class FollowInterface implements IActivityPubInterface {
$remoteActor = $this->cacheActorService->getFromId($follow->getActorId());
$accept = new Accept();
// $accept->setUrlCloud($this->configService->getCloudAddress());
$accept->setUrlCloud($this->configService->getCloudAddress());
$accept->generateUniqueId('#accept/follows');
$accept->setActorId($follow->getObjectId());
$accept->setObject($follow);
$follow->setParent($accept);
$accept->addInstancePath(
new InstancePath(
@ -122,8 +123,6 @@ class FollowInterface implements IActivityPubInterface {
)
);
$follow->setParent($accept);
$this->activityService->request($accept);
$this->followsRequest->accepted($follow);
} catch (Exception $e) {
@ -159,6 +158,7 @@ class FollowInterface implements IActivityPubInterface {
}
} catch (FollowDoesNotExistException $e) {
$actor = $this->cacheActorService->getFromId($follow->getObjectId());
if ($actor->isLocal()) {
$follow->setFollowId($actor->getFollowers());
$this->followsRequest->save($follow);
@ -189,13 +189,14 @@ class FollowInterface implements IActivityPubInterface {
public function activity(Acore $activity, ACore $item) {
/** @var Follow $item */
if ($activity->getType() === Undo::TYPE) {
$activity->checkOrigin($item->getId());
$activity->checkOrigin($item->getActorId());
$this->followsRequest->deleteByPersons($item);
$this->followsRequest->delete($item);
}
if ($activity->getType() === Reject::TYPE) {
$activity->checkOrigin($item->getObjectId());
$this->followsRequest->deleteByPersons($item);
$this->followsRequest->delete($item);
}
if ($activity->getType() === Accept::TYPE) {

Wyświetl plik

@ -63,11 +63,12 @@ class UndoInterface implements IActivityPubInterface {
if (!$item->gotObject()) {
return;
}
$object = $item->getObject();
try {
$service = AP::$activityPub->getInterfaceForItem($item->getObject());
$service->activity($item, $object);
$interface = AP::$activityPub->getInterfaceForItem($item->getObject());
$interface->activity($item, $object);
} catch (UnknownItemException $e) {
}
}

Wyświetl plik

@ -127,7 +127,7 @@ class PersonInterface implements IActivityPubInterface {
public function activity(Acore $activity, ACore $item) {
/** @var Person $item */
if ($activity->getType() === Update::TYPE) {
// $this->miscService->log('### UPDATE PERSON !' . json_encode($item));
// TODO - check time and update.
}
}

Wyświetl plik

@ -38,6 +38,7 @@ use OCA\Social\Exceptions\NoteNotFoundException;
use OCA\Social\Interfaces\IActivityPubInterface;
use OCA\Social\Model\ActivityPub\ACore;
use OCA\Social\Model\ActivityPub\Activity\Create;
use OCA\Social\Model\ActivityPub\Activity\Update;
use OCA\Social\Model\ActivityPub\Object\Note;
use OCA\Social\Service\ConfigService;
use OCA\Social\Service\CurlService;
@ -128,9 +129,18 @@ class NoteInterface implements IActivityPubInterface {
/** @var Note $item */
if ($activity->getType() === Create::TYPE) {
$activity->checkOrigin($item->getId());
$activity->checkOrigin($item->getAttributedTo());
$this->save($item);
}
if ($activity->getType() === Update::TYPE) {
$activity->checkOrigin($item->getId());
$activity->checkOrigin($item->getAttributedTo());
// TODO - check time and update.
// $this->save($item);
}
}

Wyświetl plik

@ -35,6 +35,7 @@ use daita\MySmallPhpTools\Traits\TArrayTools;
use Exception;
use OCA\Social\AP;
use OCA\Social\Exceptions\ActivityPubFormatException;
use OCA\Social\Exceptions\InvalidOriginException;
use OCA\Social\Exceptions\RedundancyLimitException;
use OCA\Social\Exceptions\SocialAppConfigException;
use OCA\Social\Exceptions\UnknownItemException;
@ -88,10 +89,12 @@ class ImportService {
* @param ACore $activity
*
* @throws UnknownItemException
* @throws InvalidOriginException
*/
public function parseIncomingRequest(ACore $activity) {
$interface = AP::$activityPub->getInterfaceForItem($activity);
$activity->checkOrigin($activity->getId());
$interface = AP::$activityPub->getInterfaceForItem($activity);
try {
$interface->processIncomingRequest($activity);
} catch (Exception $e) {