path()),['m'=>__METHOD__]); // For app installs, we have nothing to check. if (in_array($request->path(),config('slack.bypass_routes'))) return $next($request); switch ($request->path()) { // For slashcmd full validation is done in the controller case 'api/slack/slashcmd': return $next($request); case 'api/slack/event': // URL Verification if ($request->input('type') === 'url_verification') { Log::debug(sprintf('%s:Responding directly to URL Verification',static::LOGKEY),['m'=>__METHOD__,'r'=>$request->all()]); return response($request->input('challenge'),200); } $event = EventFactory::make(new Payload($request->all(),TRUE)); break; case 'api/slack/imsgopt': $event = OptionsFactory::make(new Payload(json_decode($request->payload,TRUE),TRUE)); break; case 'api/slack/imsg': $event = InteractiveFactory::make(new Payload(json_decode($request->payload,TRUE),TRUE)); break; default: // Quietly die if we got here. return response('',444); } // Ignore events for inactive workspaces if ($event->enterprise_id AND (! $event->enterprise()->active)) { Log::notice(sprintf('%s:IGNORING post, Enterprise INACTIVE [%s]',static::LOGKEY,$event->enterprise_id),['m'=>__METHOD__]); // Quietly die if the team is not active return response('',200); } elseif ((! $event->enterprise_id) AND ((! $event->team()) OR (! $event->team()->active))) { Log::notice(sprintf('%s:IGNORING post, Team INACTIVE [%s]',static::LOGKEY,$event->team_id),['m'=>__METHOD__]); // Quietly die if the team is not active return response('',200); } else { Log::debug(sprintf('%s:Incoming Request Allowed',static::LOGKEY),['m'=>__METHOD__,'e'=>$event->enterprise_id,'t'=>$event->team_id,'eo'=>$event->enterprise()->id,'to'=>$event->team()]); return $next($request); } } }