kopia lustrzana https://github.com/nextcloud/social
				
				
				
			checking origin of the object
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/256/head
							rodzic
							
								
									d334d117f7
								
							
						
					
					
						commit
						f5579329ee
					
				|  | @ -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) { | ||||
|  |  | |||
|  | @ -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) { | ||||
| 		} | ||||
| 	} | ||||
|  |  | |||
|  | @ -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.
 | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
|  | @ -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);
 | ||||
| 		} | ||||
| 
 | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -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) { | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 Maxence Lange
						Maxence Lange