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:----jTSBsJQK5bCQGCRjEYzEbnb805h5amqdE7L9/jMECqB7U5SOyfNJ4xETSkNly4se4ogY+ulZIe+VEwip+Th5ss9Afw7+dcOPBQGiK9zF7ofH0eNuc6L6ACnIH22guRyluSh/1tYDuw7z7CbrSd36YIgUvfPyGXfz2evCKiBMhRpvvueUBFhoRC+z+Gzq9oRWIMLfQM/y6qEPTEir98v5ygkKqCt+97H/fN0vh2/jYJ2AYdXDOiILqch1er4uNtdZm5MUnn5B20CkUphrS80QAIwb9zOrUwd76LqJ/AYpRb8bv+Zla4onAee4J/KdLn4dFikjTELjJZPrzOu/H0CVBizZs1abXW5tjcAk8rn9HwA7ACYRKh8diuqQ7MXb2RDarv681HHqP7oD8yDmtkKfChGzFVmhA7/EQS2dLglnQMjjfzPxEvIJ54f/Y9oPWtLLLzFXD2soojCGJdB/mhYWQGVW/kmiQg/rKlSHo885qlJtgzrfzMve28sRaoUfaNjDHhj6NVmJtgj7gpNhgR/0N8z6+EddFZa31EJTtj5nd6szctqh/stzhh7kBq0U0jDdelzbjhphv71+Hgchno77yPG507wtUfxe4Qg83laTRFuFS4dlLeCED2tsebpCNKnyqXzfjBp2cz8SaHTGiMJRkvjtelWrENg7HEszdI+V4qE=----ATTACHMENT:----NjkyNjM4OTg1Mzc2ODQwMiA2MDMzNjA4MjE5MzU2OTg0IDI4MTI0NTIwNzM2NjEwNA==