Differential D19017 Diff 45613 src/applications/metamta/controller/PhabricatorMetaMTASendGridReceiveController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/metamta/controller/PhabricatorMetaMTASendGridReceiveController.php
<?php | <?php | ||||
final class PhabricatorMetaMTASendGridReceiveController | final class PhabricatorMetaMTASendGridReceiveController | ||||
extends PhabricatorMetaMTAController { | extends PhabricatorMetaMTAController { | ||||
public function shouldRequireLogin() { | public function shouldRequireLogin() { | ||||
return false; | return false; | ||||
} | } | ||||
public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
$mailers = PhabricatorMetaMTAMail::newMailers(); | |||||
$sendgrid_type = PhabricatorMailImplementationSendGridAdapter::ADAPTERTYPE; | |||||
// SendGrid doesn't sign payloads so we can't be sure that SendGrid | // SendGrid doesn't sign payloads so we can't be sure that SendGrid | ||||
// actually sent this request, but require a configured SendGrid mailer | // actually sent this request, but require a configured SendGrid mailer | ||||
// before we activate this endpoint. | // before we activate this endpoint. | ||||
$mailers = PhabricatorMetaMTAMail::newMailersWithTypes( | |||||
$has_sendgrid = false; | array( | ||||
foreach ($mailers as $mailer) { | PhabricatorMailImplementationSendGridAdapter::ADAPTERTYPE, | ||||
if ($mailer->getAdapterType() != $sendgrid_type) { | )); | ||||
continue; | if (!$mailers) { | ||||
} | |||||
$has_sendgrid = true; | |||||
break; | |||||
} | |||||
if (!$has_sendgrid) { | |||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
// No CSRF for SendGrid. | // No CSRF for SendGrid. | ||||
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); | $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); | ||||
$user = $request->getUser(); | $user = $request->getUser(); | ||||
$raw_headers = $request->getStr('headers'); | $raw_headers = $request->getStr('headers'); | ||||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |