Compare commits

..

5 Commits

Author SHA1 Message Date
github-actions
2a3ba9799e Auto commit for release 'develop' on 2024-04-08 2024-04-08 05:09:59 +02:00
James Cole
d121aad28f Check the directory, not the file. 2024-04-07 16:27:15 +02:00
github-actions
dc808fa807 Auto commit for release 'develop' on 2024-04-07 2024-04-07 16:22:39 +02:00
James Cole
a1be6ff62b Limit the number of error messages Firefly III will send. 2024-04-07 16:12:41 +02:00
James Cole
20dc5b0256 Fix layout errors. 2024-04-07 15:57:51 +02:00
12 changed files with 88 additions and 21 deletions

View File

@@ -27,6 +27,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Message;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use Symfony\Component\Mailer\Exception\TransportException;
/**
@@ -68,6 +69,14 @@ class MailError extends Job implements ShouldQueue
$args['user'] = $this->userData;
$args['ip'] = $this->ipAddress;
$args['token'] = config('firefly.ipinfo_token');
// limit number of error mails that can be sent.
if ($this->reachedLimit()) {
Log::info('MailError: reached limit, not sending email.');
return;
}
if ($this->attempts() < 3 && '' !== $email) {
try {
\Mail::send(
@@ -96,4 +105,62 @@ class MailError extends Job implements ShouldQueue
}
}
}
private function reachedLimit(): bool
{
Log::debug('reachedLimit()');
$types = [
'5m' => ['limit' => 5, 'reset' => 5 * 60],
'1h' => ['limit' => 15, 'reset' => 60 * 60],
'24h' => ['limit' => 15, 'reset' => 24 * 60 * 60],
];
$file = storage_path('framework/cache/error-count.json');
$directory = storage_path('framework/cache');
$limits = [];
if (!is_writable($directory)) {
Log::error(sprintf('MailError: cannot write to "%s", cannot rate limit errors!', $directory));
return false;
}
if (!file_exists($file)) {
Log::debug(sprintf('Wrote new file in "%s"', $file));
file_put_contents($file, json_encode($limits, JSON_PRETTY_PRINT));
}
if (file_exists($file)) {
Log::debug(sprintf('Read file in "%s"', $file));
$limits = json_decode(file_get_contents($file), true);
}
// limit reached?
foreach ($types as $type => $info) {
Log::debug(sprintf('Now checking limit "%s"', $type), $info);
if (!isset($limits[$type])) {
Log::debug(sprintf('Limit "%s" reset to zero, did not exist yet.', $type));
$limits[$type] = [
'time' => time(),
'sent' => 0,
];
}
if (time() - $limits[$type]['time'] > $info['reset']) {
Log::debug(sprintf('Time past for this limit is %d seconds, exceeding %d seconds. Reset to zero.', time() - $limits[$type]['time'], $info['reset']));
$limits[$type] = [
'time' => time(),
'sent' => 0,
];
}
if ($limits[$type]['sent'] > $info['limit']) {
Log::warning(sprintf('Sent %d emails in %s, return true.', $limits[$type]['sent'], $type));
return true;
}
++$limits[$type]['sent'];
}
file_put_contents($file, json_encode($limits, JSON_PRETTY_PRINT));
Log::debug('No limits reached, return FALSE.');
return false;
}
}

12
composer.lock generated
View File

@@ -2728,16 +2728,16 @@
},
{
"name": "league/flysystem",
"version": "3.26.0",
"version": "3.27.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem.git",
"reference": "072735c56cc0da00e10716dd90d5a7f7b40b36be"
"reference": "4729745b1ab737908c7d055148c9a6b3e959832f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/072735c56cc0da00e10716dd90d5a7f7b40b36be",
"reference": "072735c56cc0da00e10716dd90d5a7f7b40b36be",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/4729745b1ab737908c7d055148c9a6b3e959832f",
"reference": "4729745b1ab737908c7d055148c9a6b3e959832f",
"shasum": ""
},
"require": {
@@ -2802,7 +2802,7 @@
],
"support": {
"issues": "https://github.com/thephpleague/flysystem/issues",
"source": "https://github.com/thephpleague/flysystem/tree/3.26.0"
"source": "https://github.com/thephpleague/flysystem/tree/3.27.0"
},
"funding": [
{
@@ -2814,7 +2814,7 @@
"type": "github"
}
],
"time": "2024-03-25T11:49:53+00:00"
"time": "2024-04-07T19:17:50+00:00"
},
{
"name": "league/flysystem-local",

View File

@@ -117,7 +117,7 @@ return [
'expression_engine' => false,
// see cer.php for exchange rates feature flag.
],
'version' => 'develop/2024-04-07',
'version' => 'develop/2024-04-08',
'api_version' => '2.0.13',
'db_version' => 24,

View File

@@ -4,7 +4,7 @@
"date_time_fns": "DO [de] MMMM YYYY, @ HH:mm:ss",
"month_and_day_fns": "d MMMM y",
"does_not_exist": "(config.does_not_exist)",
"date_time_fns_short": "MMMM do, yyyy @ HH:mm"
"date_time_fns_short": "do MMMM yyyy @ HH:mm"
},
"form": {
"title": "T\u00edtulo"

View File

@@ -4,7 +4,7 @@
"date_time_fns": "DO [de] MMMM YYYY, @ HH:mm:ss",
"month_and_day_fns": "d MMMM y",
"does_not_exist": "(config.does_not_exist)",
"date_time_fns_short": "MMMM do, yyyy @ HH:mm"
"date_time_fns_short": "do MMMM yyyy @ HH:mm"
},
"form": {
"title": "T\u00edtulo"

View File

@@ -3,7 +3,7 @@
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build",
"build": "vite build --emptyOutDir",
"postinstall": "patch-package --error-on-fail"
},
"devDependencies": {

View File

@@ -64,7 +64,7 @@ return [
// 'date_time' => '%B %e, %Y, @ %T',
'date_time_js' => 'DD [de] MMMM [de] YYYY, @ HH:mm:ss',
'date_time_fns' => 'DO [de] MMMM YYYY, @ HH:mm:ss',
'date_time_fns_short' => 'MMMM do, yyyy @ HH:mm',
'date_time_fns_short' => 'do MMMM yyyy @ HH:mm',
// 'specific_day' => '%e %B %Y',
'specific_day_js' => 'D MMMM YYYY',

View File

@@ -55,11 +55,11 @@ return [
'reconciled_forbidden_field' => 'Esta transação já está reconciliada, não pode alterar o ":field"',
'deleted_user' => 'Devido a motivos de segurança, não se pode registar com este email.',
'rule_trigger_value' => 'Este valor é inválido para o gatilho selecionado.',
'rule_action_expression' => 'Invalid expression. :error',
'rule_action_expression' => 'Expressão inválida. :error',
'rule_action_value' => 'Este valor é inválido para a ação selecionada.',
'file_already_attached' => 'O ficheiro ":name" carregado já está anexado a este objeto.',
'file_attached' => 'Ficheiro carregado com sucesso ":name".',
'file_zero' => 'The file is zero bytes in size.',
'file_zero' => 'O tamanho do ficheiro é nulo.',
'must_exist' => 'O ID no campo :attribute não existe na base de dados.',
'all_accounts_equal' => 'Todas as contas neste campo têm de ser iguais.',
'group_title_mandatory' => 'Um título de grupo é obrigatório quando existe mais de uma transação.',
@@ -68,8 +68,8 @@ return [
'invalid_selection' => 'A sua seleção é invalida.',
'belongs_user' => 'Esse valor está ligado a um objeto que parece não existir.',
'belongs_user_or_user_group' => 'Esse valor está ligado a um objeto que parece não existir na sua administração financeira atual.',
'no_access_group' => 'The user has no access to this user group.',
'no_accepted_roles_defined' => 'No access roles have been defined for this endpoint, access denied.',
'no_access_group' => 'O utilizador não tem acesso a este grupo.',
'no_accepted_roles_defined' => 'Nenhum acesso foi definido para este endpoint, acesso recusado.',
'at_least_one_transaction' => 'Necessita pelo menos de uma transação.',
'recurring_transaction_id' => 'Precisa de pelo menos uma transação.',
'need_id_to_match' => 'Precisa de enviar esta entrada com um ID para corresponder com a API.',
@@ -199,7 +199,7 @@ return [
*
*/
'secure_password' => 'This is not a secure password. Please try again. For more information, visit https://bit.ly/FF3-password',
'secure_password' => 'Palavra-passe não é segura. Por favor, tente novamente. Para mais informações visite https://bit.ly/FF3-password',
'valid_recurrence_rep_type' => 'Tipo de repetição inválido para transações recorrentes.',
'valid_recurrence_rep_moment' => 'Momento inválido para este tipo de repetição.',
'invalid_account_info' => 'Informação de conta inválida.',
@@ -302,7 +302,7 @@ return [
// no access to administration:
'no_access_user_group' => 'Não tem as permissões de acesso necessárias para esta administração.',
'administration_owner_rename' => 'You can\'t rename your standard administration.',
'administration_owner_rename' => 'Não pode modificar o nome da sua administração padrão.',
];
/*

View File

@@ -68,7 +68,7 @@ return [
'invalid_selection' => 'Vaša izbira je neveljavna.',
'belongs_user' => 'Ta vrednost je povezana z objektom, za katerega se zdi, da ne obstaja.',
'belongs_user_or_user_group' => 'Ta vrednost je povezana z objektom, za katerega se zdi, da ne obstaja v vaši trenutni finančni upravi.',
'no_access_group' => 'The user has no access to this user group.',
'no_access_group' => 'Uporabnik nima dostopa do te uporabniške skupine.',
'no_accepted_roles_defined' => 'No access roles have been defined for this endpoint, access denied.',
'at_least_one_transaction' => 'Potrebujete vsaj eno transakcijo.',
'recurring_transaction_id' => 'Potrebujete vsaj eno transakcijo.',

View File

@@ -62,7 +62,7 @@
})()
</script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@vite(['sass/app.scss'])
@vite(['src/sass/app.scss'])
</head>
<body class="container bg-body-secondary">

View File

@@ -62,7 +62,7 @@
})()
</script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@vite(['sass/app.scss'])
@vite(['src/sass/app.scss'])
</head>
<body class="container bg-body-secondary">

View File

@@ -62,7 +62,7 @@
})()
</script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@vite(['sass/app.scss'])
@vite(['src/sass/app.scss'])
</head>
<body class="login-page bg-body-secondary">