Convert some constants to enums

This commit is contained in:
Alex Cabal 2024-05-11 13:23:15 -05:00
parent 06425d3dd6
commit ee7c8343dd
52 changed files with 282 additions and 268 deletions

View file

@ -8,16 +8,13 @@ use function Safe\shell_exec;
// This script makes various calls to external scripts using exec() (and when called via Apache, as the www-data user).
// These scripts are allowed using the /etc/sudoers.d/www-data file. Only the specific scripts
// in that file may be executed by this script.
$log = new Log(GITHUB_WEBHOOK_LOG_FILE_PATH);
$lastPushHashFlag = '';
try{
$log->Write('Received GitHub webhook.');
$log = new Log(GITHUB_WEBHOOK_LOG_FILE_PATH);
$lastPushHashFlag = '';
if(HttpInput::RequestMethod() != HTTP_POST){
throw new Exceptions\WebhookException('Expected HTTP POST.');
}
HttpInput::ValidateRequestMethod([HttpMethod::Post]);
$log->Write('Received GitHub webhook.');
$post = file_get_contents('php://input');

View file

@ -5,17 +5,14 @@ use function Safe\curl_setopt;
use function Safe\file_get_contents;
use function Safe\json_decode;
$log = new Log(POSTMARK_WEBHOOK_LOG_FILE_PATH);
try{
$log = new Log(POSTMARK_WEBHOOK_LOG_FILE_PATH);
/** @var string $smtpUsername */
$smtpUsername = get_cfg_var('se.secrets.postmark.username');
$log->Write('Received Postmark webhook.');
if(HttpInput::RequestMethod() != HTTP_POST){
throw new Exceptions\WebhookException('Expected HTTP POST.');
}
HttpInput::ValidateRequestMethod([HttpMethod::Post]);
$apiKey = get_cfg_var('se.secrets.postmark.api_key');

View file

@ -1,22 +1,17 @@
<?
use Safe\DateTimeImmutable;
use function Safe\file_get_contents;
use function Safe\preg_match;
use function Safe\preg_replace;
use function Safe\json_decode;
// This webhook receives POSTs when email from a Fractured Atlas donation is received
// at the SE Zoho email account. This script processes the email, and inserts the donation ID
// into the database for later processing by ~se/web/scripts/process-pending-payments
$log = new Log(ZOHO_WEBHOOK_LOG_FILE_PATH);
try{
$log->Write('Received Zoho webhook.');
$log = new Log(ZOHO_WEBHOOK_LOG_FILE_PATH);
if(HttpInput::RequestMethod() != HTTP_POST){
throw new Exceptions\WebhookException('Expected HTTP POST.');
}
HttpInput::ValidateRequestMethod([HttpMethod::Post]);
$log->Write('Received Zoho webhook.');
$post = file_get_contents('php://input');
@ -39,11 +34,11 @@ try{
$transactionId = $matches[1];
Db::Query('
INSERT into PendingPayments (Created, ChannelId, TransactionId)
INSERT into PendingPayments (Created, Processor, TransactionId)
values (utc_timestamp(),
?,
?)
', [PAYMENT_CHANNEL_FA, $transactionId]);
', [PaymentProcessor::FracturedAtlas, $transactionId]);
$log->Write('Donation ID: ' . $transactionId);
}