configService = $configService; $this->miscService = $miscService; } /** * @param string $json * * @return ACore * @throws ActivityPubFormatException * @throws RedundancyLimitException * @throws SocialAppConfigException * @throws ItemUnknownException */ public function importFromJson(string $json): ACore { $data = json_decode($json, true); if (!is_array($data)) { throw new ActivityPubFormatException(); } return AP::$activityPub->getItemFromData($data); } /** * @param ACore $activity * * @throws ItemUnknownException * @throws InvalidOriginException */ public function parseIncomingRequest(ACore $activity) { $activity->checkOrigin($activity->getId()); $activity->setRequestToken($this->uuid()); $interface = AP::$activityPub->getInterfaceForItem($activity); try { $interface->processIncomingRequest($activity); } catch (Exception $e) { $this->miscService->log( 'Cannot parse ' . $activity->getType() . ': ' . get_class($e) . ' ' . $e->getMessage() ); } } }