Differential D19005 Diff 45570 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 | |||||
// actually sent this request, but require a configured SendGrid mailer | |||||
// before we activate this endpoint. | |||||
$has_sendgrid = false; | |||||
foreach ($mailers as $mailer) { | |||||
if ($mailer->getAdapterType() != $sendgrid_type) { | |||||
continue; | |||||
} | |||||
$has_sendgrid = true; | |||||
break; | |||||
} | |||||
if (!$has_sendgrid) { | |||||
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'); | ||||
$raw_headers = explode("\n", rtrim($raw_headers)); | $raw_headers = explode("\n", rtrim($raw_headers)); | ||||
$raw_dict = array(); | $raw_dict = array(); | ||||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |