settings = $settings; } /** * @param ServerRequestInterface $request * @return ResponseInterface */ public function handle(ServerRequestInterface $request): ResponseInterface { $userChannel = 'private-user'.RequestUtil::getActor($request)->id; $body = $request->getParsedBody(); if (Arr::get($body, 'channel_name') === $userChannel) { $pusher = new Pusher( $this->settings->get('flarum-pusher.app_key'), $this->settings->get('flarum-pusher.app_secret'), $this->settings->get('flarum-pusher.app_id'), ['cluster' => $this->settings->get('flarum-pusher.app_cluster')] ); $payload = json_decode($pusher->socket_auth($userChannel, Arr::get($body, 'socket_id')), true); return new JsonResponse($payload); } return new EmptyResponse(403); } }