Working on tests

This commit is contained in:
Hillel Coren 2018-03-11 12:10:29 +02:00
parent 5cfa19a5c8
commit bf5ba05943
4 changed files with 42 additions and 45 deletions

View File

@ -158,7 +158,7 @@ if (! defined('APP_NAME')) {
define('MAX_DOCUMENT_SIZE', env('MAX_DOCUMENT_SIZE', 10000)); // KB define('MAX_DOCUMENT_SIZE', env('MAX_DOCUMENT_SIZE', 10000)); // KB
define('MAX_EMAIL_DOCUMENTS_SIZE', env('MAX_EMAIL_DOCUMENTS_SIZE', 10000)); // Total KB define('MAX_EMAIL_DOCUMENTS_SIZE', env('MAX_EMAIL_DOCUMENTS_SIZE', 10000)); // Total KB
define('MAX_ZIP_DOCUMENTS_SIZE', env('MAX_EMAIL_DOCUMENTS_SIZE', 30000)); // Total KB (uncompressed) define('MAX_ZIP_DOCUMENTS_SIZE', env('MAX_EMAIL_DOCUMENTS_SIZE', 30000)); // Total KB (uncompressed)
define('MAX_EMAILS_SENT_PER_HOUR', 90); define('MAX_EMAILS_SENT_PER_DAY', 80);
define('DOCUMENT_PREVIEW_SIZE', env('DOCUMENT_PREVIEW_SIZE', 300)); // pixels define('DOCUMENT_PREVIEW_SIZE', env('DOCUMENT_PREVIEW_SIZE', 300)); // pixels
define('DEFAULT_FONT_SIZE', 9); define('DEFAULT_FONT_SIZE', 9);
define('DEFAULT_HEADER_FONT', 1); // Roboto define('DEFAULT_HEADER_FONT', 1); // Roboto

View File

@ -378,26 +378,26 @@ class ContactMailer extends Mailer
$key = $account->company_id; $key = $account->company_id;
// http://stackoverflow.com/questions/1375501/how-do-i-throttle-my-sites-api-users // http://stackoverflow.com/questions/1375501/how-do-i-throttle-my-sites-api-users
$hour = 60 * 60; $day = 60 * 60 * 24;
$hour_limit = MAX_EMAILS_SENT_PER_HOUR; $day_limit = MAX_EMAILS_SENT_PER_DAY;
$hour_throttle = Cache::get("email_hour_throttle:{$key}", null); $day_throttle = Cache::get("email_day_throttle:{$key}", null);
$last_api_request = Cache::get("last_email_request:{$key}", 0); $last_api_request = Cache::get("last_email_request:{$key}", 0);
$last_api_diff = time() - $last_api_request; $last_api_diff = time() - $last_api_request;
if (is_null($hour_throttle)) { if (is_null($day_throttle)) {
$new_hour_throttle = 0; $new_day_throttle = 0;
} else { } else {
$new_hour_throttle = $hour_throttle - $last_api_diff; $new_day_throttle = $day_throttle - $last_api_diff;
$new_hour_throttle = $new_hour_throttle < 0 ? 0 : $new_hour_throttle; $new_day_throttle = $new_day_throttle < 0 ? 0 : $new_day_throttle;
$new_hour_throttle += $hour / $hour_limit; $new_day_throttle += $day / $day_limit;
$hour_hits_remaining = floor(($hour - $new_hour_throttle) * $hour_limit / $hour); $day_hits_remaining = floor(($day - $new_day_throttle) * $day_limit / $day);
$hour_hits_remaining = $hour_hits_remaining >= 0 ? $hour_hits_remaining : 0; $day_hits_remaining = $day_hits_remaining >= 0 ? $day_hits_remaining : 0;
} }
Cache::put("email_hour_throttle:{$key}", $new_hour_throttle, 60); Cache::put("email_day_throttle:{$key}", $new_day_throttle, 60);
Cache::put("last_email_request:{$key}", time(), 60); Cache::put("last_email_request:{$key}", time(), 60);
if ($new_hour_throttle > $hour) { if ($new_day_throttle > $day) {
$errorEmail = env('ERROR_EMAIL'); $errorEmail = env('ERROR_EMAIL');
if ($errorEmail && ! Cache::get("throttle_notified:{$key}")) { if ($errorEmail && ! Cache::get("throttle_notified:{$key}")) {
Mail::raw('Account Throttle', function ($message) use ($errorEmail, $account) { Mail::raw('Account Throttle', function ($message) use ($errorEmail, $account) {
@ -406,7 +406,7 @@ class ContactMailer extends Mailer
->subject("Email throttle triggered for account " . $account->id); ->subject("Email throttle triggered for account " . $account->id);
}); });
} }
Cache::put("throttle_notified:{$key}", true, 60); Cache::put("throttle_notified:{$key}", true, 60 * 24);
return true; return true;
} }

View File

@ -134,8 +134,6 @@ class PaymentService extends BaseService
} }
} }
return $paymentDriver->completeOnsitePurchase(false, $paymentMethod);
/*
try { try {
return $paymentDriver->completeOnsitePurchase(false, $paymentMethod); return $paymentDriver->completeOnsitePurchase(false, $paymentMethod);
} catch (Exception $exception) { } catch (Exception $exception) {
@ -151,7 +149,6 @@ class PaymentService extends BaseService
return false; return false;
} }
*/
} }
public function save($input, $payment = null, $invoice = null) public function save($input, $payment = null, $invoice = null)

56
composer.lock generated
View File

@ -393,16 +393,16 @@
}, },
{ {
"name": "aws/aws-sdk-php", "name": "aws/aws-sdk-php",
"version": "3.52.22", "version": "3.52.23",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/aws/aws-sdk-php.git", "url": "https://github.com/aws/aws-sdk-php.git",
"reference": "f42076f6347590dfbf4de7befc19bb660be0ea22" "reference": "3ce95b96c217a699168d937c4ed700e6a27ec783"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/f42076f6347590dfbf4de7befc19bb660be0ea22", "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/3ce95b96c217a699168d937c4ed700e6a27ec783",
"reference": "f42076f6347590dfbf4de7befc19bb660be0ea22", "reference": "3ce95b96c217a699168d937c4ed700e6a27ec783",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -469,7 +469,7 @@
"s3", "s3",
"sdk" "sdk"
], ],
"time": "2018-03-07 22:55:58" "time": "2018-03-08 22:51:35"
}, },
{ {
"name": "bacon/bacon-qr-code", "name": "bacon/bacon-qr-code",
@ -4348,16 +4348,16 @@
}, },
{ {
"name": "laravel/tinker", "name": "laravel/tinker",
"version": "v1.0.4", "version": "v1.0.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/tinker.git", "url": "https://github.com/laravel/tinker.git",
"reference": "eb8d3cfb41b7f74fb0ef4724e459d44f4cbb35b8" "reference": "94f6daf2131508cebd11cd6f8632ba586d7ecc41"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/tinker/zipball/eb8d3cfb41b7f74fb0ef4724e459d44f4cbb35b8", "url": "https://api.github.com/repos/laravel/tinker/zipball/94f6daf2131508cebd11cd6f8632ba586d7ecc41",
"reference": "eb8d3cfb41b7f74fb0ef4724e459d44f4cbb35b8", "reference": "94f6daf2131508cebd11cd6f8632ba586d7ecc41",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -4407,7 +4407,7 @@
"laravel", "laravel",
"psysh" "psysh"
], ],
"time": "2018-03-06 13:48:07" "time": "2018-03-06 17:34:36"
}, },
{ {
"name": "laravelcollective/html", "name": "laravelcollective/html",
@ -4873,16 +4873,16 @@
}, },
{ {
"name": "maatwebsite/excel", "name": "maatwebsite/excel",
"version": "2.1.26", "version": "2.1.27",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Maatwebsite/Laravel-Excel.git", "url": "https://github.com/Maatwebsite/Laravel-Excel.git",
"reference": "c93b4658e73e9bafc33ad26959402ab8e9722ca2" "reference": "ea758fe5a9d33e0d88b40f099d1df652a0c99d38"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/Maatwebsite/Laravel-Excel/zipball/c93b4658e73e9bafc33ad26959402ab8e9722ca2", "url": "https://api.github.com/repos/Maatwebsite/Laravel-Excel/zipball/ea758fe5a9d33e0d88b40f099d1df652a0c99d38",
"reference": "c93b4658e73e9bafc33ad26959402ab8e9722ca2", "reference": "ea758fe5a9d33e0d88b40f099d1df652a0c99d38",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -4947,7 +4947,7 @@
"import", "import",
"laravel" "laravel"
], ],
"time": "2018-03-05 10:01:36" "time": "2018-03-09 13:14:19"
}, },
{ {
"name": "maximebf/debugbar", "name": "maximebf/debugbar",
@ -5438,20 +5438,20 @@
}, },
{ {
"name": "nesbot/carbon", "name": "nesbot/carbon",
"version": "1.23.0", "version": "1.24.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/briannesbitt/Carbon.git", "url": "https://github.com/briannesbitt/Carbon.git",
"reference": "4a874a39b2b00d7e0146cd46fab6f47c41ce9e65" "reference": "ef12cbd8ba5ce624f0a6a95e0850c4cc13e71e41"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/4a874a39b2b00d7e0146cd46fab6f47c41ce9e65", "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/ef12cbd8ba5ce624f0a6a95e0850c4cc13e71e41",
"reference": "4a874a39b2b00d7e0146cd46fab6f47c41ce9e65", "reference": "ef12cbd8ba5ce624f0a6a95e0850c4cc13e71e41",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.0", "php": ">=5.3.9",
"symfony/translation": "~2.6 || ~3.0 || ~4.0" "symfony/translation": "~2.6 || ~3.0 || ~4.0"
}, },
"require-dev": { "require-dev": {
@ -5487,7 +5487,7 @@
"datetime", "datetime",
"time" "time"
], ],
"time": "2018-02-28 09:22:05" "time": "2018-03-09 15:49:34"
}, },
{ {
"name": "nikic/php-parser", "name": "nikic/php-parser",
@ -7426,24 +7426,24 @@
}, },
{ {
"name": "paragonie/constant_time_encoding", "name": "paragonie/constant_time_encoding",
"version": "v2.2.1", "version": "v2.2.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/paragonie/constant_time_encoding.git", "url": "https://github.com/paragonie/constant_time_encoding.git",
"reference": "7c74c5d08761ead7b5e89d07c854bc28eb0b2186" "reference": "eccf915f45f911bfb189d1d1638d940ec6ee6e33"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/7c74c5d08761ead7b5e89d07c854bc28eb0b2186", "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/eccf915f45f911bfb189d1d1638d940ec6ee6e33",
"reference": "7c74c5d08761ead7b5e89d07c854bc28eb0b2186", "reference": "eccf915f45f911bfb189d1d1638d940ec6ee6e33",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7" "php": "^7"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^6", "phpunit/phpunit": "^6|^7",
"vimeo/psalm": "^0.3|^1" "vimeo/psalm": "^1"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@ -7484,7 +7484,7 @@
"hex2bin", "hex2bin",
"rfc4648" "rfc4648"
], ],
"time": "2018-01-23 00:54:57" "time": "2018-03-10 19:47:49"
}, },
{ {
"name": "paragonie/random_compat", "name": "paragonie/random_compat",