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:----wEbvNWKDO/EWvAVgF/iRS9qlQxwa/nWBJT+rzDHd/v6SZVkFy6b4/oKKuu00iAb3pEOELc5ZtvkZpSFZAM0jkk4v+/S56Pjy0AdG/BPvm7iXQD23riffjp1GwRjDuHhFfRXP202WzmbjcBJ4WFdZzk1jNTTqNlMH13JfHucYI56A5UC0/JYjgKz2KGBIbhIcGWznJz5jurJ6DlpmSkc2MskpEon8fMc2nOqlavI5MPF/HljUait/nX4mpWe2pi1ApIzxlHxV5MOI9YpaT8WXBudb7yXY1uiBxbOU+G7H4BqnM3c8smW+xXGiNDNs0L4ecokeMW7vizFaZefoFElIRtnLj9ytzfhvpEhmcD3eGyHwErh70Ge6br9HGxkjnMFh3THdDw+V9c2YaL761XU1y/Ce6P6OJR4O4F7ipTsXq2R18sekFENXTnNtHhRNjluMbm7DCnBjugc70iGp25oG20YXvn3nF3lWY4l0vFv7X3Qw9KdLce5ACga8FZjpOJDuwj/zr/ffsXrWkrSkQErbEOjlK0qAbynOrToakqlU9wmQjJYIoXwfrZV1Xm+Yk8LCLGoUFL9UDRMRaI/jbeW8b1pT7naOqOhGlZXzY8ilfD1dNsQVTdlb7VhcxxeL2Ntdto86EKFEE/0K91IsttbZ3G9gfkjFHyksCqZSg82gc3s=----ATTACHMENT:----Njc4NzY2MzcxNjkwODE0IDUwMDUxOTcwNjA4MzU1MTEgNzU2MjE5NjEyOTg1MTY5