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:----H4x/+v3ULK2htKBm29iDGl8aEW/odcy/hCLMgWAThno1c8/QEb3dWcBDRL6JPadrIzS0Ic7PM9OJgL4F2gpvPydkZE6Du4U4FZupuhmv23eNKUdIJN12Wy47aWvGNr77DF8Quk5fgPm1TKnNv2pD7Orv4jeguYvRe/XX4TRSpex/O5q+wnvp7Wg+OJJga+WGYn44ozlb+Y7u4Cyi2MIlcYn+7YaU4fAa4GPblEmtSq+lUzyJgSQkMASLYsAJ6dvbpOlBY+1OUuRIFV1P0VqYKfvrDi1zMZSbEBJnoY/LNTZTLpM2oVs7hGM4tvvkzlMtO2CFXN2pwI3OOJo1W1tqRpKvxdBac8k3omIpLMd0FwgvrSKaeU4Vkxbs4DirqW2EnhMloH+DKVfxAhAINzzGL7zkjeVQ4Oalu5RWURkjof6NSX23KVxg0rGdcWdGd09PAHlEH25k7KFcoKkI607mguo5fMwdE+XhFf/c7yGYtJaMfoBU5ZTcw8xDgZ9N9cGQi46PywVsO2qM6br92wvAnWRJ+xY6AArQK5QsLdiDzuI+F0i09mTsWyjK7rbuTohHZvuPRMcR5TJyY7ecxI2Mk7B7gTVAsw5wBLac91MF12UsmmrNssEubpZowMjiB1bHSid0OYNK0rcjG1l6k2BVjM6vLoI86amzvGZ/Hi7+ptM=----ATTACHMENT:----MTk2MzM3OTA0MDMyNjI3OSA4ODk0NTI0Mzc0OTUxMDY5IDU4NTM3Mjg2NzIyMjE0ODc=