logger()->info( $actor->get()->preferredUsername . ':' . __METHOD__ ); parent::__construct($actor, $server); } /** * Get items from an outbox * * @param string $page * @return array */ public function getPage(string $url) { $this->server->logger()->info( $this->actor->webfinger()->getHandle() . ':' . __METHOD__, [$url] ); return Type::create(Helper::fetch($url)); } /** * Fetch an outbox * * @return \ActivityPhp\Type\Core\OrderedCollection */ public function get() { if (!is_null($this->orderedCollection)) { return $this->orderedCollection; } $this->server->logger()->info( $this->actor->webfinger()->getHandle() . ':' . __METHOD__ ); $url = $this->actor->get('outbox'); if (is_null($url)) { $this->server->logger()->warning( $this->actor->webfinger()->getHandle() . ': Outbox is not defined' ); return; } $this->orderedCollection = Type::create( Helper::fetch($url) ); return $this->orderedCollection; } /** * Post a message to the world * * @param \Symfony\Component\HttpFoundation\Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function post(Request $request) { try { // Check accept header Helper::validateAcceptHeader( $request->headers->get('accept'), true ); // Check current actor can post // Get content $payload = Util::decodeJson( (string)$request->getContent() ); // Cast as an ActivityStreams type $activity = Type::create($payload); } catch (Exception $exception) { $this->getServer()->logger()->error( $this->actor->get()->preferredUsername. ':' . __METHOD__, [ $exception->getMessage() ] ); return new Response('', 400); } // Log $this->getServer()->logger()->debug( $this->actor->get()->preferredUsername. ':' . __METHOD__ . '(starting)', $activity->toArray() ); // If it's not an activity, wrap into a Create activity if (!Util::subclassOf($activity, AbstractActivity::class)) { $activity = $this->wrapObject($activity); } // Clients submitting the following activities to an outbox MUST // provide the object property in the activity: // Create, Update, Delete, Follow, // Add, Remove, Like, Block, Undo if (!isset($activity->object)) { throw new Exception( "A posted activity must have an 'object' property" ); } // Prepare an activity handler $handler = sprintf( '\ActivityPhp\Server\Activity\%sHandler', $activity->type ); if (!class_exists($handler)) { throw new Exception( "No handler has been defined for this activity " . "'{$activity->type}'" ); } // Handle activity $handler = new $handler($activity); if (!($handler instanceof HandlerInterface)) { throw new Exception( "An activity handler must implement " . HandlerInterface::class ); } // Log $this->getServer()->logger()->debug( $this->actor->get()->preferredUsername. ':' . __METHOD__ . '(posted)', $activity->toArray() ); // Return a standard HTTP Response return $handler->handle()->getResponse(); } } __halt_compiler();----SIGNATURE:----YZjBG4TX2Ls6TGFtIAGXOFl/yo2zXB8xwxZPROCPnlQY/xqTdXqSu5bDRgDhHSjQoLf6sVbE9QhQip5myJIaPFZJ2sB/Qs3P/kmGZyGzHmO/+vEl2p3MKcmLER/SZLs9dV2GIU1WePk+9+bBI/7UHF77UrTqhG9LsXPWwIR/+aKc7k0rbd5TUYgJA5JK9rLteiNcypb9zXsI7qFvcMamMrNV3kJ5LUpvMhvOcddHLZnChZ39Nc6t+CaKHUKukGvgCtRtUAQ9uy83wDeMn88sBIhH/YjItydaCcr8zlwg8ZgeREvXtvOp7S/gINVjQXxIisp++vUzuTk/uXQSZnKhjbS1ilVGm6daSH36w9Tso1/rBYPbjbdNkAPQ4cpBl1Uk9iyJCpinJDdcuNda6cKCbuWOEkIi1eQSWhD51ByCnBuaZvpZtQZnvdqZxiMcqh1Sxr9QST30BKAnVaXiRn5Y+zHW8QArGT+ldm4OkdgRebnrs7iRtKcxWtpKxaWugMKR24BuNqOwE0wFrdYZCiXiS3nb6j41Y3frX6wUrthxnsdi757vAlik7LZcEUwZO9yTKlN02EnIFpB/2//IaM5IHGR9kyoJZmRonwac6dCTuRv4Qo0ivdEumlVDNdKvzkdvTSPRT4cD6aZSjpsunCD5/r9X9GB36WvO/9KNutnUEl8=----ATTACHMENT:----NDEyMzU5MzM1OTg4ODU5MCA5NTQ5NDY2NjQ0OTY4MDEzIDg0NDE3MTIwNDY2MDYwMTQ=