mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-02 20:25:28 +00:00
Compare commits
68 Commits
develop-20
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7743d16ea1 | ||
|
|
ae767fc90d | ||
|
|
b49575db8b | ||
|
|
69b816d957 | ||
|
|
e9cf5111c9 | ||
|
|
a57cf4e9be | ||
|
|
d5e431c3a1 | ||
|
|
ffe0f39f6a | ||
|
|
e99a37bae3 | ||
|
|
27336e0721 | ||
|
|
c20c804f9a | ||
|
|
ddd94276db | ||
|
|
f8c95f2028 | ||
|
|
418150034b | ||
|
|
18589f87b7 | ||
|
|
e2b3e8492d | ||
|
|
8ff40e22e0 | ||
|
|
a941dca5e1 | ||
|
|
b43f0ca4a8 | ||
|
|
2298fb8406 | ||
|
|
8f4511b466 | ||
|
|
b5be712754 | ||
|
|
4f1ea96308 | ||
|
|
7cb8687b88 | ||
|
|
feb6ecb01c | ||
|
|
c63e0a2cc5 | ||
|
|
c53661a579 | ||
|
|
4e15717634 | ||
|
|
860ae9d931 | ||
|
|
d045248747 | ||
|
|
87aa6feb29 | ||
|
|
dfa32353da | ||
|
|
08c9703900 | ||
|
|
101f56d1b1 | ||
|
|
83bdaff033 | ||
|
|
e25fbcfb19 | ||
|
|
40c4c9f109 | ||
|
|
d178956541 | ||
|
|
c29f997733 | ||
|
|
2aabb56d2d | ||
|
|
e1e18a2a0c | ||
|
|
2c41694f41 | ||
|
|
48a641286c | ||
|
|
5eec91f439 | ||
|
|
782f0c7d54 | ||
|
|
a4dff6d39f | ||
|
|
9312ddbb7b | ||
|
|
14a9bede11 | ||
|
|
58d798df86 | ||
|
|
e740fc57a6 | ||
|
|
ecd7750030 | ||
|
|
19c4a82194 | ||
|
|
ffc91d5ead | ||
|
|
4898c29b85 | ||
|
|
84b4ab0cc2 | ||
|
|
eb808a0fbc | ||
|
|
d25ae50d30 | ||
|
|
c43821e29c | ||
|
|
b7570b2651 | ||
|
|
cb77609f27 | ||
|
|
99651bb61e | ||
|
|
bf1e14f66d | ||
|
|
d0e55804f8 | ||
|
|
0a9715b8c1 | ||
|
|
61390e67f6 | ||
|
|
536d25980f | ||
|
|
3388cb6f66 | ||
|
|
1c3c9377ca |
24
.ci/php-cs-fixer/composer.lock
generated
24
.ci/php-cs-fixer/composer.lock
generated
@@ -1251,16 +1251,16 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/console",
|
||||
"version": "v7.3.4",
|
||||
"version": "v7.3.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/console.git",
|
||||
"reference": "2b9c5fafbac0399a20a2e82429e2bd735dcfb7db"
|
||||
"reference": "cdb80fa5869653c83cfe1a9084a673b6daf57ea7"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/console/zipball/2b9c5fafbac0399a20a2e82429e2bd735dcfb7db",
|
||||
"reference": "2b9c5fafbac0399a20a2e82429e2bd735dcfb7db",
|
||||
"url": "https://api.github.com/repos/symfony/console/zipball/cdb80fa5869653c83cfe1a9084a673b6daf57ea7",
|
||||
"reference": "cdb80fa5869653c83cfe1a9084a673b6daf57ea7",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1325,7 +1325,7 @@
|
||||
"terminal"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/console/tree/v7.3.4"
|
||||
"source": "https://github.com/symfony/console/tree/v7.3.5"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -1345,7 +1345,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2025-09-22T15:31:00+00:00"
|
||||
"time": "2025-10-14T15:46:26+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/deprecation-contracts",
|
||||
@@ -1646,16 +1646,16 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/finder",
|
||||
"version": "v7.3.2",
|
||||
"version": "v7.3.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/finder.git",
|
||||
"reference": "2a6614966ba1074fa93dae0bc804227422df4dfe"
|
||||
"reference": "9f696d2f1e340484b4683f7853b273abff94421f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/finder/zipball/2a6614966ba1074fa93dae0bc804227422df4dfe",
|
||||
"reference": "2a6614966ba1074fa93dae0bc804227422df4dfe",
|
||||
"url": "https://api.github.com/repos/symfony/finder/zipball/9f696d2f1e340484b4683f7853b273abff94421f",
|
||||
"reference": "9f696d2f1e340484b4683f7853b273abff94421f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1690,7 +1690,7 @@
|
||||
"description": "Finds files and directories via an intuitive fluent interface",
|
||||
"homepage": "https://symfony.com",
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/finder/tree/v7.3.2"
|
||||
"source": "https://github.com/symfony/finder/tree/v7.3.5"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -1710,7 +1710,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2025-07-15T13:41:35+00:00"
|
||||
"time": "2025-10-15T18:45:57+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/options-resolver",
|
||||
|
||||
18
.github/workflows/release.yml
vendored
18
.github/workflows/release.yml
vendored
@@ -18,6 +18,16 @@ jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Validate input
|
||||
run: |
|
||||
# validate argument
|
||||
if [[ $version != develo* ]] && [[ $version != v* ]] && [[ $version != branch* ]] ;
|
||||
then
|
||||
echo "Argument '$version' does not start with a d or with a v or a b"
|
||||
exit 1
|
||||
fi
|
||||
env:
|
||||
version: ${{ github.event_name == 'schedule' && 'develop' || inputs.version }}
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
@@ -36,6 +46,14 @@ jobs:
|
||||
extensions: mbstring, intl, zip, bcmath
|
||||
- name: Switch and pull
|
||||
run: |
|
||||
# validate argument
|
||||
if [[ $version != d* ]] && [[ $version != v* ]] ;
|
||||
then
|
||||
echo 'Argument does not start with a d or with a v'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Always check out origin/develop, unless its a branch release.
|
||||
#
|
||||
|
||||
@@ -4,6 +4,7 @@ Over time, many people have contributed to Firefly III. Their efforts are not al
|
||||
Please find below all the people who contributed to the Firefly III code. Their names are mentioned in the year of their first contribution.
|
||||
|
||||
## 2025
|
||||
- Jihad
|
||||
- jreyesr
|
||||
- codearena-bot
|
||||
- Nicky De Maeyer
|
||||
|
||||
@@ -25,7 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Api\V1\Controllers\Autocomplete;
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteApiRequest;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Enums\UserRoleEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
@@ -79,20 +79,26 @@ class AccountController extends Controller
|
||||
* @throws FireflyException
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function accounts(AutocompleteRequest $request): JsonResponse
|
||||
public function accounts(AutocompleteApiRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->getData();
|
||||
$types = $data['types'];
|
||||
$query = $data['query'];
|
||||
$date = $data['date'];
|
||||
$return = [];
|
||||
$timer = Timer::getInstance();
|
||||
$timer->start(sprintf('AC accounts "%s"', $query));
|
||||
$result = $this->repository->searchAccount((string) $query, $types, $this->parameters->get('limit'));
|
||||
Log::debug('Before All.');
|
||||
[
|
||||
'types' => $types,
|
||||
'query' => $query,
|
||||
'date' => $date,
|
||||
'limit' => $limit,
|
||||
]
|
||||
= $request->attributes->all();
|
||||
|
||||
$date ??= today(config('app.timezone'));
|
||||
|
||||
// set date to end-of-day for account balance. so it is at $date 23:59:59
|
||||
$date->endOfDay();
|
||||
|
||||
$return = [];
|
||||
$timer = Timer::getInstance();
|
||||
$timer->start(sprintf('AC accounts "%s"', $query));
|
||||
$result = $this->repository->searchAccount((string)$query, $types, $limit);
|
||||
$allBalances = Steam::accountsBalancesOptimized($result, $date, $this->primaryCurrency, $this->convertToPrimary);
|
||||
|
||||
/** @var Account $account */
|
||||
@@ -111,17 +117,17 @@ class AccountController extends Controller
|
||||
}
|
||||
|
||||
$return[] = [
|
||||
'id' => (string) $account->id,
|
||||
'id' => (string)$account->id,
|
||||
'name' => $account->name,
|
||||
'name_with_balance' => $nameWithBalance,
|
||||
'active' => $account->active,
|
||||
'type' => $account->accountType->type,
|
||||
'currency_id' => (string) $useCurrency->id,
|
||||
'currency_id' => (string)$useCurrency->id,
|
||||
'currency_name' => $useCurrency->name,
|
||||
'currency_code' => $useCurrency->code,
|
||||
'currency_symbol' => $useCurrency->symbol,
|
||||
'currency_decimal_places' => $useCurrency->decimal_places,
|
||||
'account_currency_id' => (string) $currency->id,
|
||||
'account_currency_id' => (string)$currency->id,
|
||||
'account_currency_name' => $currency->name,
|
||||
'account_currency_code' => $currency->code,
|
||||
'account_currency_symbol' => $currency->symbol,
|
||||
@@ -134,8 +140,8 @@ class AccountController extends Controller
|
||||
$return,
|
||||
static function (array $left, array $right) {
|
||||
$order = [AccountTypeEnum::ASSET->value, AccountTypeEnum::REVENUE->value, AccountTypeEnum::EXPENSE->value];
|
||||
$posA = (int) array_search($left['type'], $order, true);
|
||||
$posB = (int) array_search($right['type'], $order, true);
|
||||
$posA = (int)array_search($left['type'], $order, true);
|
||||
$posB = (int)array_search($right['type'], $order, true);
|
||||
|
||||
return $posA - $posB;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Api\V1\Controllers\Autocomplete;
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteApiRequest;
|
||||
use FireflyIII\Enums\UserRoleEnum;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
@@ -61,10 +61,9 @@ class BillController extends Controller
|
||||
* Documentation for this endpoint is at:
|
||||
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/autocomplete/getBillsAC
|
||||
*/
|
||||
public function bills(AutocompleteRequest $request): JsonResponse
|
||||
public function bills(AutocompleteApiRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->getData();
|
||||
$result = $this->repository->searchBill($data['query'], $this->parameters->get('limit'));
|
||||
$result = $this->repository->searchBill($request->attributes->get('query'), $request->attributes->get('limit'));
|
||||
$filtered = $result->map(
|
||||
static fn (Bill $item) => [
|
||||
'id' => (string) $item->id,
|
||||
|
||||
@@ -25,7 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Api\V1\Controllers\Autocomplete;
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteApiRequest;
|
||||
use FireflyIII\Enums\UserRoleEnum;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
@@ -61,10 +61,9 @@ class BudgetController extends Controller
|
||||
* Documentation for this endpoint is at:
|
||||
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/autocomplete/getBudgetsAC
|
||||
*/
|
||||
public function budgets(AutocompleteRequest $request): JsonResponse
|
||||
public function budgets(AutocompleteApiRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->getData();
|
||||
$result = $this->repository->searchBudget($data['query'], $this->parameters->get('limit'));
|
||||
$result = $this->repository->searchBudget($request->attributes->get('query'), $request->attributes->get('limit'));
|
||||
$filtered = $result->map(
|
||||
static fn (Budget $item) => [
|
||||
'id' => (string) $item->id,
|
||||
|
||||
@@ -25,7 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Api\V1\Controllers\Autocomplete;
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteApiRequest;
|
||||
use FireflyIII\Enums\UserRoleEnum;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
@@ -61,10 +61,9 @@ class CategoryController extends Controller
|
||||
* Documentation for this endpoint is at:
|
||||
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/autocomplete/getCategoriesAC
|
||||
*/
|
||||
public function categories(AutocompleteRequest $request): JsonResponse
|
||||
public function categories(AutocompleteApiRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->getData();
|
||||
$result = $this->repository->searchCategory($data['query'], $this->parameters->get('limit'));
|
||||
$result = $this->repository->searchCategory($request->attributes->get('query'), $request->attributes->get('limit'));
|
||||
$filtered = $result->map(
|
||||
static fn (Category $item) => [
|
||||
'id' => (string) $item->id,
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace FireflyIII\Api\V1\Controllers\Autocomplete;
|
||||
|
||||
use Deprecated;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteApiRequest;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||
use FireflyIII\Enums\UserRoleEnum;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
@@ -62,10 +63,9 @@ class CurrencyController extends Controller
|
||||
* Documentation for this endpoint is at:
|
||||
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/autocomplete/getCurrenciesAC
|
||||
*/
|
||||
public function currencies(AutocompleteRequest $request): JsonResponse
|
||||
public function currencies(AutocompleteApiRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->getData();
|
||||
$collection = $this->repository->searchCurrency($data['query'], $this->parameters->get('limit'));
|
||||
$collection = $this->repository->searchCurrency($request->attributes->get('query'), $request->attributes->get('limit'));
|
||||
$result = [];
|
||||
|
||||
/** @var TransactionCurrency $currency */
|
||||
|
||||
@@ -25,7 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Api\V1\Controllers\Autocomplete;
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteApiRequest;
|
||||
use FireflyIII\Enums\UserRoleEnum;
|
||||
use FireflyIII\Models\ObjectGroup;
|
||||
use FireflyIII\Repositories\ObjectGroup\ObjectGroupRepositoryInterface;
|
||||
@@ -61,11 +61,10 @@ class ObjectGroupController extends Controller
|
||||
* Documentation for this endpoint is at:
|
||||
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/autocomplete/getObjectGroupsAC
|
||||
*/
|
||||
public function objectGroups(AutocompleteRequest $request): JsonResponse
|
||||
public function objectGroups(AutocompleteApiRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->getData();
|
||||
$return = [];
|
||||
$result = $this->repository->search($data['query'], $this->parameters->get('limit'));
|
||||
$result = $this->repository->search($request->attributes->get('query'), $request->attributes->get('limit'));
|
||||
|
||||
/** @var ObjectGroup $objectGroup */
|
||||
foreach ($result as $objectGroup) {
|
||||
|
||||
@@ -25,7 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Api\V1\Controllers\Autocomplete;
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteApiRequest;
|
||||
use FireflyIII\Enums\UserRoleEnum;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
@@ -64,10 +64,9 @@ class PiggyBankController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
public function piggyBanks(AutocompleteRequest $request): JsonResponse
|
||||
public function piggyBanks(AutocompleteApiRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->getData();
|
||||
$piggies = $this->piggyRepository->searchPiggyBank($data['query'], $this->parameters->get('limit'));
|
||||
$piggies = $this->piggyRepository->searchPiggyBank($request->attributes->get('query'), $request->attributes->get('limit'));
|
||||
$response = [];
|
||||
|
||||
/** @var PiggyBank $piggy */
|
||||
@@ -90,10 +89,9 @@ class PiggyBankController extends Controller
|
||||
return response()->api($response);
|
||||
}
|
||||
|
||||
public function piggyBanksWithBalance(AutocompleteRequest $request): JsonResponse
|
||||
public function piggyBanksWithBalance(AutocompleteApiRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->getData();
|
||||
$piggies = $this->piggyRepository->searchPiggyBank($data['query'], $this->parameters->get('limit'));
|
||||
$piggies = $this->piggyRepository->searchPiggyBank($request->attributes->get('query'), $request->attributes->get('limit'));
|
||||
$response = [];
|
||||
|
||||
/** @var PiggyBank $piggy */
|
||||
|
||||
@@ -25,7 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Api\V1\Controllers\Autocomplete;
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteApiRequest;
|
||||
use FireflyIII\Enums\UserRoleEnum;
|
||||
use FireflyIII\Models\Recurrence;
|
||||
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
|
||||
@@ -57,10 +57,9 @@ class RecurrenceController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
public function recurring(AutocompleteRequest $request): JsonResponse
|
||||
public function recurring(AutocompleteApiRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->getData();
|
||||
$recurrences = $this->repository->searchRecurrence($data['query'], $this->parameters->get('limit'));
|
||||
$recurrences = $this->repository->searchRecurrence($request->attributes->get('query'), $request->attributes->get('limit'));
|
||||
$response = [];
|
||||
|
||||
/** @var Recurrence $recurrence */
|
||||
|
||||
@@ -25,7 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Api\V1\Controllers\Autocomplete;
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteApiRequest;
|
||||
use FireflyIII\Enums\UserRoleEnum;
|
||||
use FireflyIII\Models\Rule;
|
||||
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
||||
@@ -57,10 +57,9 @@ class RuleController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
public function rules(AutocompleteRequest $request): JsonResponse
|
||||
public function rules(AutocompleteApiRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->getData();
|
||||
$rules = $this->repository->searchRule($data['query'], $this->parameters->get('limit'));
|
||||
$rules = $this->repository->searchRule($request->attributes->get('query'), $request->attributes->get('limit'));
|
||||
$response = [];
|
||||
|
||||
/** @var Rule $rule */
|
||||
|
||||
@@ -25,7 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Api\V1\Controllers\Autocomplete;
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteApiRequest;
|
||||
use FireflyIII\Enums\UserRoleEnum;
|
||||
use FireflyIII\Models\RuleGroup;
|
||||
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
||||
@@ -57,10 +57,9 @@ class RuleGroupController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
public function ruleGroups(AutocompleteRequest $request): JsonResponse
|
||||
public function ruleGroups(AutocompleteApiRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->getData();
|
||||
$groups = $this->repository->searchRuleGroup($data['query'], $this->parameters->get('limit'));
|
||||
$groups = $this->repository->searchRuleGroup($request->attributes->get('query'), $request->attributes->get('limit'));
|
||||
$response = [];
|
||||
|
||||
/** @var RuleGroup $group */
|
||||
|
||||
@@ -25,7 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Api\V1\Controllers\Autocomplete;
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteApiRequest;
|
||||
use FireflyIII\Enums\UserRoleEnum;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||
@@ -57,10 +57,9 @@ class TagController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
public function tags(AutocompleteRequest $request): JsonResponse
|
||||
public function tags(AutocompleteApiRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->getData();
|
||||
$result = $this->repository->searchTags($data['query'], $this->parameters->get('limit'));
|
||||
$result = $this->repository->searchTags($request->attributes->get('query'), $request->attributes->get('limit'));
|
||||
$array = [];
|
||||
|
||||
/** @var Tag $tag */
|
||||
|
||||
@@ -25,7 +25,8 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Api\V1\Controllers\Autocomplete;
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteApiRequest;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteTransactionApiRequest;
|
||||
use FireflyIII\Enums\UserRoleEnum;
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
@@ -64,10 +65,9 @@ class TransactionController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
public function transactions(AutocompleteRequest $request): JsonResponse
|
||||
public function transactions(AutocompleteTransactionApiRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->getData();
|
||||
$result = $this->repository->searchJournalDescriptions($data['query'], $this->parameters->get('limit'));
|
||||
$result = $this->repository->searchJournalDescriptions($request->attributes->get('query'), $request->attributes->get('limit'));
|
||||
|
||||
// limit and unique
|
||||
$filtered = $result->unique('description');
|
||||
@@ -86,13 +86,12 @@ class TransactionController extends Controller
|
||||
return response()->api($array);
|
||||
}
|
||||
|
||||
public function transactionsWithID(AutocompleteRequest $request): JsonResponse
|
||||
public function transactionsWithID(AutocompleteApiRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->getData();
|
||||
$result = new Collection();
|
||||
if (is_numeric($data['query'])) {
|
||||
if (is_numeric($request->attributes->get('query'))) {
|
||||
// search for group, not journal.
|
||||
$firstResult = $this->groupRepository->find((int) $data['query']);
|
||||
$firstResult = $this->groupRepository->find((int) $request->attributes->get('query'));
|
||||
if ($firstResult instanceof TransactionGroup) {
|
||||
// group may contain multiple journals, each a result:
|
||||
foreach ($firstResult->transactionJournals as $journal) {
|
||||
@@ -100,8 +99,8 @@ class TransactionController extends Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!is_numeric($data['query'])) {
|
||||
$result = $this->repository->searchJournalDescriptions($data['query'], $this->parameters->get('limit'));
|
||||
if (!is_numeric($request->attributes->get('query'))) {
|
||||
$result = $this->repository->searchJournalDescriptions($request->attributes->get('query'), $request->attributes->get('limit'));
|
||||
}
|
||||
|
||||
// limit and unique
|
||||
|
||||
@@ -25,7 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Api\V1\Controllers\Autocomplete;
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteApiRequest;
|
||||
use FireflyIII\Enums\UserRoleEnum;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\TransactionType\TransactionTypeRepositoryInterface;
|
||||
@@ -55,10 +55,9 @@ class TransactionTypeController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
public function transactionTypes(AutocompleteRequest $request): JsonResponse
|
||||
public function transactionTypes(AutocompleteApiRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->getData();
|
||||
$types = $this->repository->searchTypes($data['query'], $this->parameters->get('limit'));
|
||||
$types = $this->repository->searchTypes($request->attributes->get('query'), $request->attributes->get('limit'));
|
||||
$array = [];
|
||||
|
||||
/** @var TransactionType $type */
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace FireflyIII\Api\V1\Controllers\Chart;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Data\SameDateRequest;
|
||||
use FireflyIII\Api\V1\Requests\DateRangeRequest;
|
||||
use FireflyIII\Enums\UserRoleEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Budget;
|
||||
@@ -83,15 +83,13 @@ class BudgetController extends Controller
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function overview(SameDateRequest $request): JsonResponse
|
||||
public function overview(DateRangeRequest $request): JsonResponse
|
||||
{
|
||||
$params = $request->getAll();
|
||||
|
||||
/** @var Carbon $start */
|
||||
$start = $params['start'];
|
||||
$start = $request->attributes->get('start');
|
||||
|
||||
/** @var Carbon $end */
|
||||
$end = $params['end'];
|
||||
$end = $request->attributes->get('end');
|
||||
|
||||
// code from FrontpageChartGenerator, but not in separate class
|
||||
$budgets = $this->repository->getActiveBudgets();
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace FireflyIII\Api\V1\Controllers\Chart;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Data\SameDateRequest;
|
||||
use FireflyIII\Api\V1\Requests\DateRangeRequest;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Enums\UserRoleEnum;
|
||||
@@ -80,13 +80,13 @@ class CategoryController extends Controller
|
||||
*
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
*/
|
||||
public function overview(SameDateRequest $request): JsonResponse
|
||||
public function overview(DateRangeRequest $request): JsonResponse
|
||||
{
|
||||
/** @var Carbon $start */
|
||||
$start = $this->parameters->get('start');
|
||||
$start = $request->attributes->get('start');
|
||||
|
||||
/** @var Carbon $end */
|
||||
$end = $this->parameters->get('end');
|
||||
$end = $request->attributes->get('end');
|
||||
$accounts = $this->accountRepos->getAccountsByType([AccountTypeEnum::DEBT->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::ASSET->value]);
|
||||
$currencies = [];
|
||||
$return = [];
|
||||
|
||||
@@ -29,6 +29,7 @@ use Carbon\Exceptions\InvalidFormatException;
|
||||
use FireflyIII\Exceptions\BadHttpHeaderException;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
|
||||
use FireflyIII\Transformers\AbstractTransformer;
|
||||
@@ -159,7 +160,7 @@ abstract class Controller extends BaseController
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
$pageSize = (int)app('preferences')->getForUser($user, 'listPageSize', 50)->data;
|
||||
$pageSize = (int)Preferences::getForUser($user, 'listPageSize', 50)->data;
|
||||
$bag->set($integer, $pageSize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||
use FireflyIII\Services\Internal\Destroy\AccountDestroyService;
|
||||
use FireflyIII\Services\Internal\Destroy\JournalDestroyService;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
@@ -102,7 +103,7 @@ class DestroyController extends Controller
|
||||
default => throw new FireflyException(sprintf('200033: This endpoint can\'t handle object "%s"', $objects)),
|
||||
};
|
||||
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace FireflyIII\Api\V1\Controllers\Models\Account;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
/**
|
||||
@@ -60,7 +61,7 @@ class DestroyController extends Controller
|
||||
public function destroy(Account $account): JsonResponse
|
||||
{
|
||||
$this->repository->destroy($account, null);
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Api\V1\Controllers\Models\Account;
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Generic\PaginationDateRangeRequest;
|
||||
use FireflyIII\Api\V1\Requests\PaginationRequest;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
@@ -70,7 +71,7 @@ class ListController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
public function attachments(Account $account, PaginationRequest $request): JsonResponse
|
||||
public function attachments(PaginationRequest $request, Account $account): JsonResponse
|
||||
{
|
||||
$manager = $this->getManager();
|
||||
[
|
||||
@@ -96,18 +97,21 @@ class ListController extends Controller
|
||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||
}
|
||||
|
||||
public function piggyBanks(Account $account): JsonResponse
|
||||
public function piggyBanks(PaginationRequest $request, Account $account): JsonResponse
|
||||
{
|
||||
// create some objects:
|
||||
$manager = $this->getManager();
|
||||
|
||||
// types to get, page size:
|
||||
$pageSize = $this->parameters->get('limit');
|
||||
[
|
||||
'limit' => $limit,
|
||||
'offset' => $offset,
|
||||
'page' => $page,
|
||||
] = $request->attributes->all();
|
||||
|
||||
// get list of piggy banks. Count it and split it.
|
||||
$collection = $this->repository->getPiggyBanks($account);
|
||||
$count = $collection->count();
|
||||
$piggyBanks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||
$piggyBanks = $collection->slice($offset, $limit);
|
||||
|
||||
// enrich
|
||||
/** @var User $admin */
|
||||
@@ -117,12 +121,12 @@ class ListController extends Controller
|
||||
$piggyBanks = $enrichment->enrich($piggyBanks);
|
||||
|
||||
// make paginator:
|
||||
$paginator = new LengthAwarePaginator($piggyBanks, $count, $pageSize, $this->parameters->get('page'));
|
||||
$paginator = new LengthAwarePaginator($piggyBanks, $count, $limit, $page);
|
||||
$paginator->setPath(route('api.v1.accounts.piggy-banks', [$account->id]).$this->buildParams());
|
||||
|
||||
/** @var PiggyBankTransformer $transformer */
|
||||
$transformer = app(PiggyBankTransformer::class);
|
||||
$transformer->setParameters($this->parameters);
|
||||
// $transformer->setParameters($this->parameters);
|
||||
|
||||
$resource = new FractalCollection($piggyBanks, $transformer, 'piggy-banks');
|
||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||
@@ -133,12 +137,15 @@ class ListController extends Controller
|
||||
/**
|
||||
* Show all transaction groups related to the account.
|
||||
*/
|
||||
public function transactions(Request $request, Account $account): JsonResponse
|
||||
public function transactions(PaginationDateRangeRequest $request, Account $account): JsonResponse
|
||||
{
|
||||
$pageSize = $this->parameters->get('limit');
|
||||
$type = $request->get('type') ?? 'default';
|
||||
$this->parameters->set('type', $type);
|
||||
$types = $this->mapTransactionTypes($this->parameters->get('type'));
|
||||
[
|
||||
'limit' => $limit,
|
||||
'page' => $page,
|
||||
'start' => $start,
|
||||
'end' => $end,
|
||||
'types' => $types,
|
||||
] = $request->attributes->all();
|
||||
$manager = $this->getManager();
|
||||
|
||||
/** @var User $admin */
|
||||
@@ -147,15 +154,12 @@ class ListController extends Controller
|
||||
// use new group collector:
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setUser($admin)->setAccounts(new Collection()->push($account))
|
||||
->withAPIInformation()->setLimit($pageSize)->setPage($this->parameters->get('page'))->setTypes($types)
|
||||
;
|
||||
|
||||
if (null !== $this->parameters->get('start')) {
|
||||
$collector->setStart($this->parameters->get('start'));
|
||||
$collector->setUser($admin)->setAccounts(new Collection()->push($account))->withAPIInformation()->setLimit($limit)->setPage($page)->setTypes($types);
|
||||
if (null !== $start) {
|
||||
$collector->setStart($start);
|
||||
}
|
||||
if (null !== $this->parameters->get('end')) {
|
||||
$collector->setEnd($this->parameters->get('end'));
|
||||
if (null !== $end) {
|
||||
$collector->setEnd($end);
|
||||
}
|
||||
|
||||
$paginator = $collector->getPaginatedGroups();
|
||||
@@ -168,7 +172,6 @@ class ListController extends Controller
|
||||
|
||||
/** @var TransactionGroupTransformer $transformer */
|
||||
$transformer = app(TransactionGroupTransformer::class);
|
||||
$transformer->setParameters($this->parameters);
|
||||
|
||||
$resource = new FractalCollection($transactions, $transformer, 'transactions');
|
||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||
|
||||
@@ -81,7 +81,6 @@ class StoreController extends Controller
|
||||
|
||||
/** @var AccountTransformer $transformer */
|
||||
$transformer = app(AccountTransformer::class);
|
||||
$transformer->setParameters($this->parameters);
|
||||
|
||||
$resource = new Item($account, $transformer, self::RESOURCE_KEY);
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Models\Account\UpdateRequest;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\Support\JsonApi\Enrichments\AccountEnrichment;
|
||||
use FireflyIII\Transformers\AccountTransformer;
|
||||
use FireflyIII\User;
|
||||
@@ -74,7 +75,7 @@ class UpdateController extends Controller
|
||||
$account = $this->repository->update($account, $data);
|
||||
$manager = $this->getManager();
|
||||
$account->refresh();
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
|
||||
// enrich
|
||||
/** @var User $admin */
|
||||
@@ -86,7 +87,6 @@ class UpdateController extends Controller
|
||||
|
||||
/** @var AccountTransformer $transformer */
|
||||
$transformer = app(AccountTransformer::class);
|
||||
$transformer->setParameters($this->parameters);
|
||||
$resource = new Item($account, $transformer, self::RESOURCE_KEY);
|
||||
|
||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||
|
||||
@@ -28,6 +28,7 @@ use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Middleware\ApiDemoUser;
|
||||
use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -74,7 +75,7 @@ class DestroyController extends Controller
|
||||
}
|
||||
|
||||
$this->repository->destroy($attachment);
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace FireflyIII\Api\V1\Controllers\Models\Attachment;
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Middleware\ApiDemoUser;
|
||||
use FireflyIII\Api\V1\Requests\PaginationRequest;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||
@@ -120,8 +121,14 @@ class ShowController extends Controller
|
||||
*
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(): JsonResponse
|
||||
public function index(PaginationRequest $request): JsonResponse
|
||||
{
|
||||
[
|
||||
'limit' => $limit,
|
||||
'offset' => $offset,
|
||||
'page' => $page,
|
||||
] = $request->attributes->all();
|
||||
|
||||
if (true === auth()->user()->hasRole('demo')) {
|
||||
Log::channel('audit')->warning(sprintf('Demo user tries to access attachment API in %s', __METHOD__));
|
||||
|
||||
@@ -130,21 +137,17 @@ class ShowController extends Controller
|
||||
|
||||
$manager = $this->getManager();
|
||||
|
||||
// types to get, page size:
|
||||
$pageSize = $this->parameters->get('limit');
|
||||
|
||||
// get list of attachments. Count it and split it.
|
||||
$collection = $this->repository->get();
|
||||
$count = $collection->count();
|
||||
$attachments = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||
$attachments = $collection->slice($offset, $limit);
|
||||
|
||||
// make paginator:
|
||||
$paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));
|
||||
$paginator = new LengthAwarePaginator($attachments, $count, $limit, $page);
|
||||
$paginator->setPath(route('api.v1.attachments.index').$this->buildParams());
|
||||
|
||||
/** @var AttachmentTransformer $transformer */
|
||||
$transformer = app(AttachmentTransformer::class);
|
||||
$transformer->setParameters($this->parameters);
|
||||
|
||||
$resource = new FractalCollection($attachments, $transformer, 'attachments');
|
||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||
@@ -169,7 +172,6 @@ class ShowController extends Controller
|
||||
|
||||
/** @var AttachmentTransformer $transformer */
|
||||
$transformer = app(AttachmentTransformer::class);
|
||||
$transformer->setParameters($this->parameters);
|
||||
|
||||
$resource = new Item($attachment, $transformer, 'attachments');
|
||||
|
||||
|
||||
@@ -87,7 +87,6 @@ class StoreController extends Controller
|
||||
|
||||
/** @var AttachmentTransformer $transformer */
|
||||
$transformer = app(AttachmentTransformer::class);
|
||||
$transformer->setParameters($this->parameters);
|
||||
|
||||
$resource = new Item($attachment, $transformer, 'attachments');
|
||||
|
||||
|
||||
@@ -81,7 +81,6 @@ class UpdateController extends Controller
|
||||
|
||||
/** @var AttachmentTransformer $transformer */
|
||||
$transformer = app(AttachmentTransformer::class);
|
||||
$transformer->setParameters($this->parameters);
|
||||
|
||||
$resource = new Item($attachment, $transformer, 'attachments');
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Api\V1\Controllers\Models\AvailableBudget;
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Generic\PaginationDateRangeRequest;
|
||||
use FireflyIII\Models\AvailableBudget;
|
||||
use FireflyIII\Repositories\Budget\AvailableBudgetRepositoryInterface;
|
||||
use FireflyIII\Support\JsonApi\Enrichments\AvailableBudgetEnrichment;
|
||||
@@ -67,19 +68,21 @@ class ShowController extends Controller
|
||||
*
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(): JsonResponse
|
||||
public function index(PaginationDateRangeRequest $request): JsonResponse
|
||||
{
|
||||
$manager = $this->getManager();
|
||||
|
||||
// types to get, page size:
|
||||
$pageSize = $this->parameters->get('limit');
|
||||
$start = $this->parameters->get('start');
|
||||
$end = $this->parameters->get('end');
|
||||
[
|
||||
'limit' => $limit,
|
||||
'offset' => $offset,
|
||||
'page' => $page,
|
||||
'start' => $start,
|
||||
'end' => $end,
|
||||
] = $request->attributes->all();
|
||||
|
||||
// get list of available budgets. Count it and split it.
|
||||
$collection = $this->abRepository->getAvailableBudgetsByDate($start, $end);
|
||||
$count = $collection->count();
|
||||
$availableBudgets = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||
$availableBudgets = $collection->slice($offset, $limit);
|
||||
|
||||
// enrich
|
||||
/** @var User $admin */
|
||||
@@ -89,12 +92,11 @@ class ShowController extends Controller
|
||||
$availableBudgets = $enrichment->enrich($availableBudgets);
|
||||
|
||||
// make paginator:
|
||||
$paginator = new LengthAwarePaginator($availableBudgets, $count, $pageSize, $this->parameters->get('page'));
|
||||
$paginator = new LengthAwarePaginator($availableBudgets, $count, $limit, $page);
|
||||
$paginator->setPath(route('api.v1.available-budgets.index').$this->buildParams());
|
||||
|
||||
/** @var AvailableBudgetTransformer $transformer */
|
||||
$transformer = app(AvailableBudgetTransformer::class);
|
||||
$transformer->setParameters($this->parameters);
|
||||
|
||||
$resource = new FractalCollection($availableBudgets, $transformer, 'available_budgets');
|
||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||
@@ -116,15 +118,12 @@ class ShowController extends Controller
|
||||
|
||||
/** @var AvailableBudgetTransformer $transformer */
|
||||
$transformer = app(AvailableBudgetTransformer::class);
|
||||
$transformer->setParameters($this->parameters);
|
||||
|
||||
// enrich
|
||||
/** @var User $admin */
|
||||
$admin = auth()->user();
|
||||
$enrichment = new AvailableBudgetEnrichment();
|
||||
$enrichment->setUser($admin);
|
||||
// $enrichment->setStart($start);
|
||||
// $enrichment->setEnd($end);
|
||||
$availableBudget = $enrichment->enrichSingle($availableBudget);
|
||||
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace FireflyIII\Api\V1\Controllers\Models\Bill;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
/**
|
||||
@@ -61,7 +62,7 @@ class DestroyController extends Controller
|
||||
public function destroy(Bill $bill): JsonResponse
|
||||
{
|
||||
$this->repository->destroy($bill);
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Api\V1\Controllers\Models\Bill;
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Generic\PaginationDateRangeRequest;
|
||||
use FireflyIII\Api\V1\Requests\PaginationRequest;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
@@ -71,22 +73,25 @@ class ListController extends Controller
|
||||
*
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function attachments(Bill $bill): JsonResponse
|
||||
public function attachments(PaginationRequest $request, Bill $bill): JsonResponse
|
||||
{
|
||||
[
|
||||
'limit' => $limit,
|
||||
'offset' => $offset,
|
||||
'page' => $page,
|
||||
] = $request->attributes->all();
|
||||
$manager = $this->getManager();
|
||||
$pageSize = $this->parameters->get('limit');
|
||||
$collection = $this->repository->getAttachments($bill);
|
||||
|
||||
$count = $collection->count();
|
||||
$attachments = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||
$attachments = $collection->slice($offset, $limit);
|
||||
|
||||
// make paginator:
|
||||
$paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));
|
||||
$paginator = new LengthAwarePaginator($attachments, $count, $limit, $page);
|
||||
$paginator->setPath(route('api.v1.bills.attachments', [$bill->id]).$this->buildParams());
|
||||
|
||||
/** @var AttachmentTransformer $transformer */
|
||||
$transformer = app(AttachmentTransformer::class);
|
||||
$transformer->setParameters($this->parameters);
|
||||
|
||||
$resource = new FractalCollection($attachments, $transformer, 'attachments');
|
||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||
@@ -100,25 +105,25 @@ class ListController extends Controller
|
||||
*
|
||||
* List all of them.
|
||||
*/
|
||||
public function rules(Bill $bill): JsonResponse
|
||||
public function rules(PaginationRequest $request, Bill $bill): JsonResponse
|
||||
{
|
||||
[
|
||||
'limit' => $limit,
|
||||
'offset' => $offset,
|
||||
'page' => $page,
|
||||
] = $request->attributes->all();
|
||||
|
||||
$manager = $this->getManager();
|
||||
|
||||
// types to get, page size:
|
||||
$pageSize = $this->parameters->get('limit');
|
||||
|
||||
// get list of budgets. Count it and split it.
|
||||
$collection = $this->repository->getRulesForBill($bill);
|
||||
$count = $collection->count();
|
||||
$rules = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||
$rules = $collection->slice($offset, $limit);
|
||||
|
||||
// make paginator:
|
||||
$paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page'));
|
||||
$paginator = new LengthAwarePaginator($rules, $count, $limit, $page);
|
||||
$paginator->setPath(route('api.v1.bills.rules', [$bill->id]).$this->buildParams());
|
||||
|
||||
/** @var RuleTransformer $transformer */
|
||||
$transformer = app(RuleTransformer::class);
|
||||
$transformer->setParameters($this->parameters);
|
||||
$resource = new FractalCollection($rules, $transformer, 'rules');
|
||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||
|
||||
@@ -131,13 +136,16 @@ class ListController extends Controller
|
||||
*
|
||||
* Show all transactions.
|
||||
*/
|
||||
public function transactions(Request $request, Bill $bill): JsonResponse
|
||||
public function transactions(PaginationDateRangeRequest $request, Bill $bill): JsonResponse
|
||||
{
|
||||
$pageSize = $this->parameters->get('limit');
|
||||
$type = $request->get('type') ?? 'default';
|
||||
$this->parameters->set('type', $type);
|
||||
[
|
||||
'limit' => $limit,
|
||||
'page' => $page,
|
||||
'types' => $types,
|
||||
'start' => $start,
|
||||
'end' => $end,
|
||||
] = $request->attributes->all();
|
||||
|
||||
$types = $this->mapTransactionTypes($this->parameters->get('type'));
|
||||
$manager = $this->getManager();
|
||||
|
||||
/** @var User $admin */
|
||||
@@ -153,18 +161,18 @@ class ListController extends Controller
|
||||
// all info needed for the API:
|
||||
->withAPIInformation()
|
||||
// set page size:
|
||||
->setLimit($pageSize)
|
||||
->setLimit($limit)
|
||||
// set page to retrieve
|
||||
->setPage($this->parameters->get('page'))
|
||||
->setPage($page)
|
||||
// set types of transactions to return.
|
||||
->setTypes($types)
|
||||
;
|
||||
|
||||
if (null !== $this->parameters->get('start')) {
|
||||
$collector->setStart($this->parameters->get('start'));
|
||||
if (null !== $start) {
|
||||
$collector->setStart($start);
|
||||
}
|
||||
if (null !== $this->parameters->get('end')) {
|
||||
$collector->setEnd($this->parameters->get('end'));
|
||||
if (null !== $end) {
|
||||
$collector->setEnd($end);
|
||||
}
|
||||
|
||||
// get paginator.
|
||||
@@ -178,7 +186,6 @@ class ListController extends Controller
|
||||
|
||||
/** @var TransactionGroupTransformer $transformer */
|
||||
$transformer = app(TransactionGroupTransformer::class);
|
||||
$transformer->setParameters($this->parameters);
|
||||
|
||||
$resource = new FractalCollection($transactions, $transformer, 'transactions');
|
||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||
|
||||
@@ -25,6 +25,9 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Api\V1\Controllers\Models\Bill;
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\DateRangeRequest;
|
||||
use FireflyIII\Api\V1\Requests\Generic\PaginationDateRangeRequest;
|
||||
use FireflyIII\Api\V1\Requests\PaginationRequest;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Support\JsonApi\Enrichments\SubscriptionEnrichment;
|
||||
@@ -65,28 +68,34 @@ class ShowController extends Controller
|
||||
*
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(): JsonResponse
|
||||
public function index(PaginationDateRangeRequest $request): JsonResponse
|
||||
{
|
||||
[
|
||||
'limit' => $limit,
|
||||
'offset' => $offset,
|
||||
'start' => $start,
|
||||
'end' => $end,
|
||||
'page' => $page,
|
||||
] = $request->attributes->all();
|
||||
|
||||
$this->repository->correctOrder();
|
||||
$bills = $this->repository->getBills();
|
||||
$manager = $this->getManager();
|
||||
$pageSize = $this->parameters->get('limit');
|
||||
$count = $bills->count();
|
||||
$bills = $bills->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||
$paginator = new LengthAwarePaginator($bills, $count, $pageSize, $this->parameters->get('page'));
|
||||
$bills = $bills->slice($offset, $limit);
|
||||
$paginator = new LengthAwarePaginator($bills, $count, $limit, $page);
|
||||
|
||||
// enrich
|
||||
/** @var User $admin */
|
||||
$admin = auth()->user();
|
||||
$enrichment = new SubscriptionEnrichment();
|
||||
$enrichment->setUser($admin);
|
||||
$enrichment->setStart($this->parameters->get('start'));
|
||||
$enrichment->setEnd($this->parameters->get('end'));
|
||||
$enrichment->setStart($start);
|
||||
$enrichment->setEnd($end);
|
||||
$bills = $enrichment->enrich($bills);
|
||||
|
||||
/** @var BillTransformer $transformer */
|
||||
$transformer = app(BillTransformer::class);
|
||||
$transformer->setParameters($this->parameters);
|
||||
|
||||
$resource = new FractalCollection($bills, $transformer, 'bills');
|
||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||
@@ -100,8 +109,13 @@ class ShowController extends Controller
|
||||
*
|
||||
* Show the specified bill.
|
||||
*/
|
||||
public function show(Bill $bill): JsonResponse
|
||||
public function show(DateRangeRequest $request, Bill $bill): JsonResponse
|
||||
{
|
||||
[
|
||||
'start' => $start,
|
||||
'end' => $end,
|
||||
] = $request->attributes->all();
|
||||
|
||||
$manager = $this->getManager();
|
||||
|
||||
// enrich
|
||||
@@ -109,13 +123,12 @@ class ShowController extends Controller
|
||||
$admin = auth()->user();
|
||||
$enrichment = new SubscriptionEnrichment();
|
||||
$enrichment->setUser($admin);
|
||||
$enrichment->setStart($this->parameters->get('start'));
|
||||
$enrichment->setEnd($this->parameters->get('end'));
|
||||
$enrichment->setStart($start);
|
||||
$enrichment->setEnd($end);
|
||||
$bill = $enrichment->enrichSingle($bill);
|
||||
|
||||
/** @var BillTransformer $transformer */
|
||||
$transformer = app(BillTransformer::class);
|
||||
$transformer->setParameters($this->parameters);
|
||||
|
||||
$resource = new Item($bill, $transformer, 'bills');
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace FireflyIII\Api\V1\Controllers\Models\Budget;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
/**
|
||||
@@ -61,7 +62,7 @@ class DestroyController extends Controller
|
||||
public function destroy(Budget $budget): JsonResponse
|
||||
{
|
||||
$this->repository->destroy($budget);
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use FireflyIII\Repositories\Budget\BudgetLimitRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -71,7 +72,7 @@ class DestroyController extends Controller
|
||||
throw new FireflyException('20028: The budget limit does not belong to the budget.');
|
||||
}
|
||||
$this->blRepository->destroyBudgetLimit($budgetLimit);
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace FireflyIII\Api\V1\Controllers\Models\Category;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
/**
|
||||
@@ -61,7 +62,7 @@ class DestroyController extends Controller
|
||||
public function destroy(Category $category): JsonResponse
|
||||
{
|
||||
$this->repository->destroy($category);
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use Carbon\Carbon;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Models\CurrencyExchangeRate\DestroyRequest;
|
||||
use FireflyIII\Enums\UserRoleEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\CurrencyExchangeRate;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\ExchangeRate\ExchangeRateRepositoryInterface;
|
||||
@@ -75,6 +76,9 @@ class DestroyController extends Controller
|
||||
if ($exchangeRate instanceof CurrencyExchangeRate) {
|
||||
$this->repository->deleteRate($exchangeRate);
|
||||
}
|
||||
if (!$exchangeRate instanceof CurrencyExchangeRate) {
|
||||
throw new FireflyException('Bla');
|
||||
}
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
||||
@@ -82,7 +82,6 @@ class UpdateController extends Controller
|
||||
$exchangeRate = $this->repository->updateExchangeRate($exchangeRate, $rate, $date);
|
||||
|
||||
$transformer = new ExchangeRateTransformer();
|
||||
$transformer->setParameters($this->parameters);
|
||||
|
||||
return response()
|
||||
->api($this->jsonApiObject(self::RESOURCE_KEY, $exchangeRate, $transformer))
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace FireflyIII\Api\V1\Controllers\Models\ObjectGroup;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Models\ObjectGroup;
|
||||
use FireflyIII\Repositories\ObjectGroup\ObjectGroupRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -64,7 +65,7 @@ class DestroyController extends Controller
|
||||
public function destroy(ObjectGroup $objectGroup): JsonResponse
|
||||
{
|
||||
$this->repository->destroy($objectGroup);
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace FireflyIII\Api\V1\Controllers\Models\PiggyBank;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
/**
|
||||
@@ -61,7 +62,7 @@ class DestroyController extends Controller
|
||||
public function destroy(PiggyBank $piggyBank): JsonResponse
|
||||
{
|
||||
$this->repository->destroy($piggyBank);
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace FireflyIII\Api\V1\Controllers\Models\Recurrence;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Models\Recurrence;
|
||||
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
/**
|
||||
@@ -61,7 +62,7 @@ class DestroyController extends Controller
|
||||
public function destroy(Recurrence $recurrence): JsonResponse
|
||||
{
|
||||
$this->repository->destroy($recurrence);
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace FireflyIII\Api\V1\Controllers\Models\Rule;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Models\Rule;
|
||||
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -65,7 +66,7 @@ class DestroyController extends Controller
|
||||
public function destroy(Rule $rule): JsonResponse
|
||||
{
|
||||
$this->ruleRepository->destroy($rule);
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace FireflyIII\Api\V1\Controllers\Models\RuleGroup;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Models\RuleGroup;
|
||||
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -65,7 +66,7 @@ class DestroyController extends Controller
|
||||
public function destroy(RuleGroup $ruleGroup): JsonResponse
|
||||
{
|
||||
$this->ruleGroupRepository->destroy($ruleGroup, null);
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace FireflyIII\Api\V1\Controllers\Models\Tag;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -65,7 +66,7 @@ class DestroyController extends Controller
|
||||
public function destroy(Tag $tag): JsonResponse
|
||||
{
|
||||
$this->repository->destroy($tag);
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ use FireflyIII\Models\TransactionGroup;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepository;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -92,7 +93,7 @@ class DestroyController extends Controller
|
||||
|
||||
$this->groupRepository->destroy($transactionGroup);
|
||||
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
@@ -112,7 +113,7 @@ class DestroyController extends Controller
|
||||
public function destroyJournal(TransactionJournal $transactionJournal): JsonResponse
|
||||
{
|
||||
$this->repository->destroyJournal($transactionJournal);
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface;
|
||||
use FireflyIII\Rules\IsDuplicateTransaction;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\Support\Http\Api\TransactionFilter;
|
||||
use FireflyIII\Support\JsonApi\Enrichments\TransactionGroupEnrichment;
|
||||
use FireflyIII\Transformers\TransactionGroupTransformer;
|
||||
@@ -107,7 +108,7 @@ class StoreController extends Controller
|
||||
|
||||
throw new ValidationException($validator);
|
||||
}
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
$applyRules = $data['apply_rules'] ?? true;
|
||||
$fireWebhooks = $data['fire_webhooks'] ?? true;
|
||||
event(new StoredTransactionGroup($transactionGroup, $applyRules, $fireWebhooks));
|
||||
|
||||
@@ -30,6 +30,7 @@ use FireflyIII\Events\UpdatedTransactionGroup;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\Support\JsonApi\Enrichments\TransactionGroupEnrichment;
|
||||
use FireflyIII\Transformers\TransactionGroupTransformer;
|
||||
use FireflyIII\User;
|
||||
@@ -79,7 +80,7 @@ class UpdateController extends Controller
|
||||
$newHash = $this->groupRepository->getCompareHash($transactionGroup);
|
||||
$manager = $this->getManager();
|
||||
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
$applyRules = $data['apply_rules'] ?? true;
|
||||
$fireWebhooks = $data['fire_webhooks'] ?? true;
|
||||
$runRecalculations = $oldHash !== $newHash;
|
||||
|
||||
@@ -29,6 +29,7 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
@@ -89,7 +90,7 @@ class DestroyController extends Controller
|
||||
}
|
||||
|
||||
$this->repository->destroy($currency);
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace FireflyIII\Api\V1\Controllers\Models\TransactionCurrency;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Models\TransactionCurrency\StoreRequest;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\Support\Http\Api\AccountFilter;
|
||||
use FireflyIII\Support\Http\Api\TransactionFilter;
|
||||
use FireflyIII\Transformers\CurrencyTransformer;
|
||||
@@ -71,7 +72,7 @@ class StoreController extends Controller
|
||||
$currency = $this->repository->store($request->getAll());
|
||||
if (true === $request->boolean('default')) {
|
||||
$this->repository->makePrimary($currency);
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
}
|
||||
$manager = $this->getManager();
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ use FireflyIII\Api\V1\Requests\Models\TransactionCurrency\UpdateRequest;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\Support\Http\Api\AccountFilter;
|
||||
use FireflyIII\Support\Http\Api\TransactionFilter;
|
||||
use FireflyIII\Transformers\CurrencyTransformer;
|
||||
@@ -105,7 +106,7 @@ class UpdateController extends Controller
|
||||
$this->repository->enable($currency);
|
||||
$this->repository->makePrimary($currency);
|
||||
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
|
||||
$manager = $this->getManager();
|
||||
$currency->refreshForUser($user);
|
||||
@@ -172,14 +173,13 @@ class UpdateController extends Controller
|
||||
|
||||
$currency = $this->repository->update($currency, $data);
|
||||
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
|
||||
$manager = $this->getManager();
|
||||
$currency->refreshForUser($user);
|
||||
|
||||
/** @var CurrencyTransformer $transformer */
|
||||
$transformer = app(CurrencyTransformer::class);
|
||||
$transformer->setParameters($this->parameters);
|
||||
|
||||
$resource = new Item($currency, $transformer, 'currencies');
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace FireflyIII\Api\V1\Controllers\Models\TransactionLink;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Models\TransactionJournalLink;
|
||||
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -66,7 +67,7 @@ class DestroyController extends Controller
|
||||
public function destroy(TransactionJournalLink $link): JsonResponse
|
||||
{
|
||||
$this->repository->destroyLink($link);
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\LinkType;
|
||||
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\Support\Http\Api\TransactionFilter;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -73,7 +74,7 @@ class DestroyController extends Controller
|
||||
throw new FireflyException('200020: Link type cannot be changed.');
|
||||
}
|
||||
$this->repository->destroy($linkType);
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Models\UserGroup\UpdateRequest;
|
||||
use FireflyIII\Models\UserGroup;
|
||||
use FireflyIII\Repositories\UserGroup\UserGroupRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\Transformers\UserGroupTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -59,7 +60,7 @@ class UpdateController extends Controller
|
||||
$data = $request->getData();
|
||||
$userGroup = $this->repository->update($userGroup, $data);
|
||||
$userGroup->refresh();
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
|
||||
$transformer = new UserGroupTransformer();
|
||||
$transformer->setParameters($this->parameters);
|
||||
|
||||
@@ -29,6 +29,7 @@ use FireflyIII\Api\V1\Requests\User\PreferenceStoreRequest;
|
||||
use FireflyIII\Api\V1\Requests\User\PreferenceUpdateRequest;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\Transformers\PreferenceTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
@@ -52,7 +53,7 @@ class PreferencesController extends Controller
|
||||
*/
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
$collection = app('preferences')->all();
|
||||
$collection = Preferences::all();
|
||||
$manager = $this->getManager();
|
||||
$count = $collection->count();
|
||||
$pageSize = $this->parameters->get('limit');
|
||||
@@ -110,7 +111,7 @@ class PreferencesController extends Controller
|
||||
throw new FireflyException('Please use api/v1/currencies/default instead.');
|
||||
}
|
||||
|
||||
$pref = app('preferences')->set($data['name'], $data['data']);
|
||||
$pref = Preferences::set($data['name'], $data['data']);
|
||||
|
||||
/** @var PreferenceTransformer $transformer */
|
||||
$transformer = app(PreferenceTransformer::class);
|
||||
@@ -135,7 +136,7 @@ class PreferencesController extends Controller
|
||||
|
||||
$manager = $this->getManager();
|
||||
$data = $request->getAll();
|
||||
$pref = app('preferences')->set($preference->name, $data['data']);
|
||||
$pref = Preferences::set($preference->name, $data['data']);
|
||||
|
||||
/** @var PreferenceTransformer $transformer */
|
||||
$transformer = app(PreferenceTransformer::class);
|
||||
|
||||
@@ -30,6 +30,7 @@ use FireflyIII\Models\Webhook;
|
||||
use FireflyIII\Models\WebhookAttempt;
|
||||
use FireflyIII\Models\WebhookMessage;
|
||||
use FireflyIII\Repositories\Webhook\WebhookRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
@@ -70,7 +71,7 @@ class DestroyController extends Controller
|
||||
|
||||
Log::channel('audit')->info(sprintf('User destroys webhook #%d.', $webhook->id));
|
||||
$this->repository->destroy($webhook);
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
@@ -101,7 +102,7 @@ class DestroyController extends Controller
|
||||
Log::channel('audit')->info(sprintf('User destroys webhook #%d, message #%d, attempt #%d.', $webhook->id, $message->id, $attempt->id));
|
||||
|
||||
$this->repository->destroyAttempt($attempt);
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
@@ -128,7 +129,7 @@ class DestroyController extends Controller
|
||||
Log::channel('audit')->info(sprintf('User destroys webhook #%d, message #%d.', $webhook->id, $message->id));
|
||||
|
||||
$this->repository->destroyMessage($message);
|
||||
app('preferences')->mark();
|
||||
Preferences::mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Requests;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -45,6 +46,7 @@ abstract class AggregateFormRequest extends ApiRequest
|
||||
|
||||
// instantiate all subrequests and share current requests' bags with them
|
||||
Log::debug('Initializing AggregateFormRequest.');
|
||||
|
||||
foreach ($this->getRequests() as $config) {
|
||||
$requestClass = is_array($config) ? array_shift($config) : $config;
|
||||
|
||||
|
||||
47
app/Api/V1/Requests/Autocomplete/AutocompleteApiRequest.php
Normal file
47
app/Api/V1/Requests/Autocomplete/AutocompleteApiRequest.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* AutocompleteApiRequest.php
|
||||
* Copyright (c) 2025 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Api\V1\Requests\Autocomplete;
|
||||
|
||||
use FireflyIII\Api\V1\Requests\AggregateFormRequest;
|
||||
use FireflyIII\Api\V1\Requests\DateRequest;
|
||||
use FireflyIII\Api\V1\Requests\Generic\ObjectTypeApiRequest;
|
||||
use FireflyIII\Api\V1\Requests\Generic\QueryRequest;
|
||||
use FireflyIII\Api\V1\Requests\Models\Account\AccountTypesApiRequest;
|
||||
use FireflyIII\Api\V1\Requests\PaginationRequest;
|
||||
use FireflyIII\Models\Account;
|
||||
use Override;
|
||||
|
||||
class AutocompleteApiRequest extends AggregateFormRequest
|
||||
{
|
||||
#[Override]
|
||||
protected function getRequests(): array
|
||||
{
|
||||
return [
|
||||
DateRequest::class,
|
||||
[PaginationRequest::class, 'sort_class' => Account::class],
|
||||
[ObjectTypeApiRequest::class, 'object_type' => Account::class],
|
||||
QueryRequest::class,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,8 @@ use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* Class AutocompleteRequest
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
class AutocompleteRequest extends FormRequest
|
||||
{
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* AutocompleteApiRequest.php
|
||||
* Copyright (c) 2025 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Api\V1\Requests\Autocomplete;
|
||||
|
||||
use FireflyIII\Api\V1\Requests\AggregateFormRequest;
|
||||
use FireflyIII\Api\V1\Requests\DateRequest;
|
||||
use FireflyIII\Api\V1\Requests\Generic\ObjectTypeApiRequest;
|
||||
use FireflyIII\Api\V1\Requests\Generic\QueryRequest;
|
||||
use FireflyIII\Api\V1\Requests\PaginationRequest;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use Override;
|
||||
|
||||
class AutocompleteTransactionApiRequest extends AggregateFormRequest
|
||||
{
|
||||
#[Override]
|
||||
protected function getRequests(): array
|
||||
{
|
||||
return [
|
||||
DateRequest::class,
|
||||
[PaginationRequest::class, 'sort_class' => Account::class],
|
||||
[ObjectTypeApiRequest::class, 'object_type' => Transaction::class],
|
||||
QueryRequest::class,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,8 @@ use Illuminate\Foundation\Http\FormRequest;
|
||||
* Request class for end points that require date parameters.
|
||||
*
|
||||
* Class SameDateRequest
|
||||
*
|
||||
* @deprecated Replaced by DateRangeRequest
|
||||
*/
|
||||
class SameDateRequest extends FormRequest
|
||||
{
|
||||
|
||||
@@ -40,10 +40,6 @@ class DateRangeRequest extends ApiRequest
|
||||
$validator->after(
|
||||
function (Validator $validator): void {
|
||||
if ($validator->failed()) {
|
||||
// set null values
|
||||
$this->attributes->set('start', null);
|
||||
$this->attributes->set('end', null);
|
||||
|
||||
return;
|
||||
}
|
||||
$start = $this->getCarbonDate('start')?->startOfDay();
|
||||
|
||||
94
app/Api/V1/Requests/Generic/ObjectTypeApiRequest.php
Normal file
94
app/Api/V1/Requests/Generic/ObjectTypeApiRequest.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* AccountTypeApiRequest.php
|
||||
* Copyright (c) 2025 https://github.com/ctrl-f5
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Api\V1\Requests\Generic;
|
||||
|
||||
use FireflyIII\Api\V1\Requests\ApiRequest;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Rules\Account\IsValidAccountTypeList;
|
||||
use FireflyIII\Rules\TransactionType\IsValidTransactionTypeList;
|
||||
use FireflyIII\Support\Http\Api\AccountFilter;
|
||||
use FireflyIII\Support\Http\Api\TransactionFilter;
|
||||
use Illuminate\Validation\Validator;
|
||||
use RuntimeException;
|
||||
|
||||
class ObjectTypeApiRequest extends ApiRequest
|
||||
{
|
||||
use AccountFilter;
|
||||
use TransactionFilter;
|
||||
|
||||
private ?string $objectType = null;
|
||||
|
||||
public function handleConfig(array $config): void
|
||||
{
|
||||
parent::handleConfig($config);
|
||||
|
||||
$this->objectType = $config['object_type'] ?? null;
|
||||
|
||||
if (!$this->objectType) {
|
||||
throw new RuntimeException('ObjectTypeApiRequest requires a object_type config');
|
||||
}
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$rule = null;
|
||||
if (Account::class === $this->objectType) {
|
||||
$rule = new IsValidAccountTypeList();
|
||||
}
|
||||
if (Transaction::class === $this->objectType) {
|
||||
$rule = new IsValidTransactionTypeList();
|
||||
}
|
||||
$rules = [
|
||||
'types' => [$rule],
|
||||
];
|
||||
if ('' !== $this->required) {
|
||||
$rules['types'][] = $this->required;
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public function withValidator(Validator $validator): void
|
||||
{
|
||||
$validator->after(
|
||||
function (Validator $validator): void {
|
||||
if ($validator->failed()) {
|
||||
return;
|
||||
}
|
||||
$type = $this->convertString('types', 'all');
|
||||
$this->attributes->set('type', $type);
|
||||
switch ($this->objectType) {
|
||||
default:
|
||||
$this->attributes->set('types', []);
|
||||
case Account::class:
|
||||
$this->attributes->set('types', $this->mapAccountTypes($type));
|
||||
break;
|
||||
case Transaction::class:
|
||||
$this->attributes->set('types', $this->mapTransactionTypes($type));
|
||||
break;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
43
app/Api/V1/Requests/Generic/PaginationDateRangeRequest.php
Normal file
43
app/Api/V1/Requests/Generic/PaginationDateRangeRequest.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/*
|
||||
* PaginationDateRangeRequest.php
|
||||
* Copyright (c) 2025 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Api\V1\Requests\Generic;
|
||||
|
||||
use FireflyIII\Api\V1\Requests\AggregateFormRequest;
|
||||
use FireflyIII\Api\V1\Requests\DateRangeRequest;
|
||||
use FireflyIII\Api\V1\Requests\PaginationRequest;
|
||||
use FireflyIII\Models\Transaction;
|
||||
|
||||
/**
|
||||
* TODO this class includes an object type filter which should be moved to its own thing.
|
||||
*/
|
||||
class PaginationDateRangeRequest extends AggregateFormRequest
|
||||
{
|
||||
#[Override]
|
||||
protected function getRequests(): array
|
||||
{
|
||||
return [
|
||||
DateRangeRequest::class,
|
||||
[ObjectTypeApiRequest::class, 'object_type' => Transaction::class],
|
||||
[PaginationRequest::class, 'sort_class' => Transaction::class],
|
||||
];
|
||||
}
|
||||
}
|
||||
55
app/Api/V1/Requests/Generic/QueryRequest.php
Normal file
55
app/Api/V1/Requests/Generic/QueryRequest.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* QueryRequest.php
|
||||
* Copyright (c) 2025 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Api\V1\Requests\Generic;
|
||||
|
||||
use FireflyIII\Api\V1\Requests\ApiRequest;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
class QueryRequest extends ApiRequest
|
||||
{
|
||||
use ChecksLogin;
|
||||
use ConvertsDataTypes;
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'query' => sprintf('min:1|max:50|%s', $this->required),
|
||||
];
|
||||
}
|
||||
|
||||
public function withValidator(Validator $validator): void
|
||||
{
|
||||
$validator->after(
|
||||
function (Validator $validator): void {
|
||||
if ($validator->failed()) {
|
||||
return;
|
||||
}
|
||||
$query = $this->convertString('query');
|
||||
$this->attributes->set('query', $query);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,8 @@ use Illuminate\Foundation\Http\FormRequest;
|
||||
* Request class for end points that require a date parameter.
|
||||
*
|
||||
* Class SingleDateRequest
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
class SingleDateRequest extends FormRequest
|
||||
{
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* AccountTypeApiRequest.php
|
||||
* Copyright (c) 2025 https://github.com/ctrl-f5
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Api\V1\Requests\Models\Account;
|
||||
|
||||
use FireflyIII\Api\V1\Requests\ApiRequest;
|
||||
use FireflyIII\Rules\Account\IsValidAccountTypeList;
|
||||
use FireflyIII\Support\Http\Api\AccountFilter;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
class AccountTypesApiRequest extends ApiRequest
|
||||
{
|
||||
use AccountFilter;
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
// sprintf('in:%s', implode(',', array_keys($this->types))),
|
||||
return [
|
||||
'types' => new IsValidAccountTypeList(),
|
||||
];
|
||||
}
|
||||
|
||||
public function withValidator(Validator $validator): void
|
||||
{
|
||||
$validator->after(
|
||||
function (Validator $validator): void {
|
||||
if ($validator->failed()) {
|
||||
return;
|
||||
}
|
||||
$types = explode(',', $this->convertString('types', 'all'));
|
||||
$result = [];
|
||||
// split and find all types:
|
||||
foreach ($types as $type) {
|
||||
$result = array_merge($result, $this->mapAccountTypes($type));
|
||||
}
|
||||
$result = array_unique($result);
|
||||
$this->attributes->set('types', $result);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ namespace FireflyIII\Api\V1\Requests\Models\Account;
|
||||
use FireflyIII\Api\V1\Requests\AggregateFormRequest;
|
||||
use FireflyIII\Api\V1\Requests\DateRangeRequest;
|
||||
use FireflyIII\Api\V1\Requests\DateRequest;
|
||||
use FireflyIII\Api\V1\Requests\Generic\ObjectTypeApiRequest;
|
||||
use FireflyIII\Api\V1\Requests\PaginationRequest;
|
||||
use FireflyIII\Models\Account;
|
||||
|
||||
@@ -38,6 +39,7 @@ class ShowRequest extends AggregateFormRequest
|
||||
DateRangeRequest::class,
|
||||
DateRequest::class,
|
||||
AccountTypeApiRequest::class,
|
||||
[ObjectTypeApiRequest::class, 'object_type' => Account::class],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,12 +68,10 @@ class PaginationRequest extends ApiRequest
|
||||
$user = auth()->user();
|
||||
$limit = (int)Preferences::getForUser($user, 'listPageSize', 50)->data;
|
||||
}
|
||||
|
||||
$page = $this->convertInteger('page');
|
||||
$page = min(max(1, $page), 2 ** 16);
|
||||
$offset = ($page - 1) * $limit;
|
||||
$sort = $this->sortClass ? $this->convertSortParameters('sort', $this->sortClass) : $this->get('sort');
|
||||
|
||||
$this->attributes->set('limit', $limit);
|
||||
$this->attributes->set('sort', $sort);
|
||||
$this->attributes->set('page', $page);
|
||||
|
||||
@@ -28,6 +28,7 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
@@ -47,7 +48,7 @@ class CorrectsFrontpageAccounts extends Command
|
||||
|
||||
/** @var User $user */
|
||||
foreach ($users as $user) {
|
||||
$preference = app('preferences')->getForUser($user, 'frontpageAccounts');
|
||||
$preference = Preferences::getForUser($user, 'frontpageAccounts');
|
||||
if (null !== $preference) {
|
||||
$this->fixPreference($preference);
|
||||
}
|
||||
@@ -79,6 +80,6 @@ class CorrectsFrontpageAccounts extends Command
|
||||
}
|
||||
}
|
||||
}
|
||||
app('preferences')->setForUser($preference->user, 'frontpageAccounts', $fixed);
|
||||
Preferences::setForUser($preference->user, 'frontpageAccounts', $fixed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace FireflyIII\Console\Commands\Correction;
|
||||
use Exception;
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
@@ -54,10 +55,10 @@ class CreatesAccessTokens extends Command
|
||||
|
||||
/** @var User $user */
|
||||
foreach ($users as $user) {
|
||||
$pref = app('preferences')->getForUser($user, 'access_token');
|
||||
$pref = Preferences::getForUser($user, 'access_token');
|
||||
if (null === $pref) {
|
||||
$token = $user->generateAccessToken();
|
||||
app('preferences')->setForUser($user, 'access_token', $token);
|
||||
Preferences::setForUser($user, 'access_token', $token);
|
||||
$this->friendlyInfo(sprintf('Generated access token for user %s', $user->email));
|
||||
++$count;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
||||
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
@@ -114,7 +115,7 @@ class UpgradesBillsToRules extends Command
|
||||
$this->ruleRepository->setUser($user);
|
||||
|
||||
/** @var Preference $lang */
|
||||
$lang = app('preferences')->getForUser($user, 'language', 'en_US');
|
||||
$lang = Preferences::getForUser($user, 'language', 'en_US');
|
||||
$language = null !== $lang->data && !is_array($lang->data) ? (string) $lang->data : 'en_US';
|
||||
$groupTitle = (string) trans('firefly.rulegroup_for_bills_title', [], $language);
|
||||
$ruleGroup = $this->ruleGroupRepository->findByTitle($groupTitle);
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace FireflyIII\Console\Commands;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
@@ -79,7 +80,7 @@ trait VerifiesAccessToken
|
||||
|
||||
return false;
|
||||
}
|
||||
$accessToken = app('preferences')->getForUser($user, 'access_token');
|
||||
$accessToken = Preferences::getForUser($user, 'access_token');
|
||||
if (null === $accessToken) {
|
||||
Log::error(sprintf('User #%d has no access token, so cannot access command line options.', $userId));
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ use FireflyIII\Repositories\ObjectGroup\CreatesObjectGroups;
|
||||
use FireflyIII\Services\Internal\Support\BillServiceTrait;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class BillFactory
|
||||
@@ -47,7 +48,7 @@ class BillFactory
|
||||
*/
|
||||
public function create(array $data): ?Bill
|
||||
{
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__), $data);
|
||||
Log::debug(sprintf('Now in %s', __METHOD__), $data);
|
||||
$factory = app(TransactionCurrencyFactory::class);
|
||||
$currency = $factory->find((int) ($data['currency_id'] ?? null), (string) ($data['currency_code'] ?? null))
|
||||
?? app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
@@ -82,8 +83,8 @@ class BillFactory
|
||||
]
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
|
||||
throw new FireflyException('400000: Could not store bill.', 0, $e);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
/**
|
||||
* Class CategoryFactory
|
||||
*/
|
||||
@@ -43,7 +43,7 @@ class CategoryFactory
|
||||
$categoryId = (int) $categoryId;
|
||||
$categoryName = (string) $categoryName;
|
||||
|
||||
app('log')->debug(sprintf('Going to find category with ID %d and name "%s"', $categoryId, $categoryName));
|
||||
Log::debug(sprintf('Going to find category with ID %d and name "%s"', $categoryId, $categoryName));
|
||||
|
||||
if ('' === $categoryName && 0 === $categoryId) {
|
||||
return null;
|
||||
@@ -72,8 +72,8 @@ class CategoryFactory
|
||||
]
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
|
||||
throw new FireflyException('400003: Could not store new category.', 0, $e);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use function Safe\json_encode;
|
||||
|
||||
/**
|
||||
* Class PiggyBankFactory
|
||||
*/
|
||||
@@ -92,7 +91,7 @@ class PiggyBankFactory
|
||||
/** @var PiggyBank $piggyBank */
|
||||
$piggyBank = PiggyBank::createQuietly($piggyBankData);
|
||||
} catch (QueryException $e) {
|
||||
app('log')->error(sprintf('Could not store piggy bank: %s', $e->getMessage()), $piggyBankData);
|
||||
Log::error(sprintf('Could not store piggy bank: %s', $e->getMessage()), $piggyBankData);
|
||||
|
||||
throw new FireflyException('400005: Could not store new piggy bank.', 0, $e);
|
||||
}
|
||||
@@ -211,7 +210,7 @@ class PiggyBankFactory
|
||||
$current = 1;
|
||||
foreach ($set as $piggyBank) {
|
||||
if ($piggyBank->order !== $current) {
|
||||
app('log')->debug(sprintf('Piggy bank #%d ("%s") was at place %d but should be on %d', $piggyBank->id, $piggyBank->name, $piggyBank->order, $current));
|
||||
Log::debug(sprintf('Piggy bank #%d ("%s") was at place %d but should be on %d', $piggyBank->id, $piggyBank->name, $piggyBank->order, $current));
|
||||
$piggyBank->order = $current;
|
||||
$piggyBank->save();
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use FireflyIII\Models\Location;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Models\UserGroup;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class TagFactory
|
||||
@@ -40,12 +41,12 @@ class TagFactory
|
||||
public function findOrCreate(string $tag): ?Tag
|
||||
{
|
||||
$tag = trim($tag);
|
||||
app('log')->debug(sprintf('Now in TagFactory::findOrCreate("%s")', $tag));
|
||||
Log::debug(sprintf('Now in TagFactory::findOrCreate("%s")', $tag));
|
||||
|
||||
/** @var null|Tag $dbTag */
|
||||
$dbTag = $this->user->tags()->where('tag', $tag)->first();
|
||||
if (null !== $dbTag) {
|
||||
app('log')->debug(sprintf('Tag exists (#%d), return it.', $dbTag->id));
|
||||
Log::debug(sprintf('Tag exists (#%d), return it.', $dbTag->id));
|
||||
|
||||
return $dbTag;
|
||||
}
|
||||
@@ -60,11 +61,11 @@ class TagFactory
|
||||
]
|
||||
);
|
||||
if (!$newTag instanceof Tag) {
|
||||
app('log')->error(sprintf('TagFactory::findOrCreate("%s") but tag is unexpectedly NULL!', $tag));
|
||||
Log::error(sprintf('TagFactory::findOrCreate("%s") but tag is unexpectedly NULL!', $tag));
|
||||
|
||||
return null;
|
||||
}
|
||||
app('log')->debug(sprintf('Created new tag #%d ("%s")', $newTag->id, $newTag->tag));
|
||||
Log::debug(sprintf('Created new tag #%d ("%s")', $newTag->id, $newTag->tag));
|
||||
|
||||
return $newTag;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ use FireflyIII\Rules\UniqueIban;
|
||||
use FireflyIII\Services\Internal\Update\AccountUpdateService;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class TransactionFactory
|
||||
@@ -96,9 +97,9 @@ class TransactionFactory
|
||||
/** @var null|Transaction $result */
|
||||
$result = Transaction::create($data);
|
||||
} catch (QueryException $e) {
|
||||
app('log')->error(sprintf('Could not create transaction: %s', $e->getMessage()), $data);
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error(sprintf('Could not create transaction: %s', $e->getMessage()), $data);
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
|
||||
throw new FireflyException(sprintf('Query exception when creating transaction: %s', $e->getMessage()), 0, $e);
|
||||
}
|
||||
@@ -106,7 +107,7 @@ class TransactionFactory
|
||||
throw new FireflyException('Transaction is NULL.');
|
||||
}
|
||||
|
||||
app('log')->debug(
|
||||
Log::debug(
|
||||
sprintf(
|
||||
'Created transaction #%d (%s %s, account %s), part of journal #%d',
|
||||
$result->id,
|
||||
@@ -138,17 +139,17 @@ class TransactionFactory
|
||||
private function updateAccountInformation(): void
|
||||
{
|
||||
if (!array_key_exists('iban', $this->accountInformation)) {
|
||||
app('log')->debug('No IBAN information in array, will not update.');
|
||||
Log::debug('No IBAN information in array, will not update.');
|
||||
|
||||
return;
|
||||
}
|
||||
if ('' !== (string) $this->account->iban) {
|
||||
app('log')->debug('Account already has IBAN information, will not update.');
|
||||
Log::debug('Account already has IBAN information, will not update.');
|
||||
|
||||
return;
|
||||
}
|
||||
if ($this->account->iban === $this->accountInformation['iban']) {
|
||||
app('log')->debug('Account already has this IBAN, will not update.');
|
||||
Log::debug('Account already has this IBAN, will not update.');
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -157,12 +158,12 @@ class TransactionFactory
|
||||
'iban' => ['required', new UniqueIban($this->account, $this->account->accountType->type)],
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
app('log')->debug('Invalid or non-unique IBAN, will not update.');
|
||||
Log::debug('Invalid or non-unique IBAN, will not update.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
app('log')->debug('Will update account with IBAN information.');
|
||||
Log::debug('Will update account with IBAN information.');
|
||||
$service = app(AccountUpdateService::class);
|
||||
$service->update($this->account, ['iban' => $this->accountInformation['iban']]);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
use FireflyIII\Models\UserGroup;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class TransactionGroupFactory
|
||||
@@ -55,7 +56,7 @@ class TransactionGroupFactory
|
||||
*/
|
||||
public function create(array $data): TransactionGroup
|
||||
{
|
||||
app('log')->debug('Now in TransactionGroupFactory::create()');
|
||||
Log::debug('Now in TransactionGroupFactory::create()');
|
||||
$this->journalFactory->setUser($data['user']);
|
||||
$this->journalFactory->setUserGroup($data['user_group']);
|
||||
$this->journalFactory->setErrorOnHash($data['error_if_duplicate_hash'] ?? false);
|
||||
@@ -63,7 +64,7 @@ class TransactionGroupFactory
|
||||
try {
|
||||
$collection = $this->journalFactory->create($data);
|
||||
} catch (DuplicateTransactionException $e) {
|
||||
app('log')->warning('GroupFactory::create() caught journalFactory::create() with a duplicate!');
|
||||
Log::warning('GroupFactory::create() caught journalFactory::create() with a duplicate!');
|
||||
|
||||
throw new DuplicateTransactionException($e->getMessage(), 0, $e);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace FireflyIII\Factory;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\TransactionJournalMeta;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class TransactionJournalMetaFactory
|
||||
@@ -34,27 +35,27 @@ class TransactionJournalMetaFactory
|
||||
{
|
||||
public function updateOrCreate(array $data): ?TransactionJournalMeta
|
||||
{
|
||||
// app('log')->debug('In updateOrCreate()');
|
||||
// Log::debug('In updateOrCreate()');
|
||||
$value = $data['data'];
|
||||
|
||||
/** @var null|TransactionJournalMeta $entry */
|
||||
$entry = $data['journal']->transactionJournalMeta()->where('name', $data['name'])->first();
|
||||
if (null === $value && null !== $entry) {
|
||||
// app('log')->debug('Value is empty, delete meta value.');
|
||||
// Log::debug('Value is empty, delete meta value.');
|
||||
$entry->delete();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($data['data'] instanceof Carbon) {
|
||||
app('log')->debug('Is a carbon object.');
|
||||
Log::debug('Is a carbon object.');
|
||||
$value = $data['data']->toW3cString();
|
||||
}
|
||||
if ('' === (string) $value) {
|
||||
// app('log')->debug('Is an empty string.');
|
||||
// Log::debug('Is an empty string.');
|
||||
// don't store blank strings.
|
||||
if (null !== $entry) {
|
||||
app('log')->debug('Will not store empty strings, delete meta value');
|
||||
Log::debug('Will not store empty strings, delete meta value');
|
||||
$entry->delete();
|
||||
}
|
||||
|
||||
@@ -62,13 +63,13 @@ class TransactionJournalMetaFactory
|
||||
}
|
||||
|
||||
if (null === $entry) {
|
||||
// app('log')->debug('Will create new object.');
|
||||
app('log')->debug(sprintf('Going to create new meta-data entry to store "%s".', $data['name']));
|
||||
// Log::debug('Will create new object.');
|
||||
Log::debug(sprintf('Going to create new meta-data entry to store "%s".', $data['name']));
|
||||
$entry = new TransactionJournalMeta();
|
||||
$entry->transactionJournal()->associate($data['journal']);
|
||||
$entry->name = $data['name'];
|
||||
}
|
||||
app('log')->debug('Will update value and return.');
|
||||
Log::debug('Will update value and return.');
|
||||
$entry->data = $value;
|
||||
$entry->save();
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Generator\Report\ReportGeneratorInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Throwable;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class MonthReportGenerator.
|
||||
@@ -58,8 +59,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
->render()
|
||||
;
|
||||
} catch (Throwable $e) {
|
||||
app('log')->error(sprintf('Cannot render reports.double.report: %s', $e->getMessage()));
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error(sprintf('Cannot render reports.double.report: %s', $e->getMessage()));
|
||||
Log::error($e->getTraceAsString());
|
||||
$result = sprintf('Could not render report view: %s', $e->getMessage());
|
||||
|
||||
throw new FireflyException($result, 0, $e);
|
||||
|
||||
@@ -105,8 +105,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
->render()
|
||||
;
|
||||
} catch (Throwable $e) {
|
||||
app('log')->error(sprintf('Cannot render reports.audit.report: %s', $e->getMessage()));
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error(sprintf('Cannot render reports.audit.report: %s', $e->getMessage()));
|
||||
Log::error($e->getTraceAsString());
|
||||
$result = sprintf('Could not render report view: %s', $e->getMessage());
|
||||
|
||||
throw new FireflyException($result, 0, $e);
|
||||
|
||||
@@ -30,6 +30,7 @@ use FireflyIII\Generator\Report\ReportGeneratorInterface;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Throwable;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class MonthReportGenerator.
|
||||
@@ -72,8 +73,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
->render()
|
||||
;
|
||||
} catch (Throwable $e) {
|
||||
app('log')->error(sprintf('Cannot render reports.account.report: %s', $e->getMessage()));
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error(sprintf('Cannot render reports.account.report: %s', $e->getMessage()));
|
||||
Log::error($e->getTraceAsString());
|
||||
$result = sprintf('Could not render report view: %s', $e->getMessage());
|
||||
|
||||
throw new FireflyException($result, 0, $e);
|
||||
@@ -132,7 +133,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
protected function getExpenses(): array
|
||||
{
|
||||
if (0 !== count($this->expenses)) {
|
||||
app('log')->debug('Return previous set of expenses.');
|
||||
Log::debug('Return previous set of expenses.');
|
||||
|
||||
return $this->expenses;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ use FireflyIII\Generator\Report\ReportGeneratorInterface;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Throwable;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class MonthReportGenerator.
|
||||
@@ -73,8 +74,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
->render()
|
||||
;
|
||||
} catch (Throwable $e) {
|
||||
app('log')->error(sprintf('Cannot render reports.category.month: %s', $e->getMessage()));
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error(sprintf('Cannot render reports.category.month: %s', $e->getMessage()));
|
||||
Log::error($e->getTraceAsString());
|
||||
$result = sprintf('Could not render report view: %s', $e->getMessage());
|
||||
|
||||
throw new FireflyException($result, 0, $e);
|
||||
@@ -131,7 +132,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
protected function getExpenses(): array
|
||||
{
|
||||
if (0 !== count($this->expenses)) {
|
||||
app('log')->debug('Return previous set of expenses.');
|
||||
Log::debug('Return previous set of expenses.');
|
||||
|
||||
return $this->expenses;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Generator\Report\ReportGeneratorInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Throwable;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class MonthReportGenerator.
|
||||
@@ -56,8 +57,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
try {
|
||||
return view('reports.default.month', compact('accountIds', 'reportType'))->with('start', $this->start)->with('end', $this->end)->render();
|
||||
} catch (Throwable $e) {
|
||||
app('log')->error(sprintf('Cannot render reports.default.month: %s', $e->getMessage()));
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error(sprintf('Cannot render reports.default.month: %s', $e->getMessage()));
|
||||
Log::error($e->getTraceAsString());
|
||||
$result = 'Could not render report view.';
|
||||
|
||||
throw new FireflyException($result, 0, $e);
|
||||
|
||||
@@ -28,6 +28,7 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Generator\Report\ReportGeneratorInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Throwable;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class MonthReportGenerator.
|
||||
@@ -60,8 +61,8 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
|
||||
compact('accountIds', 'reportType')
|
||||
)->with('start', $this->start)->with('end', $this->end)->render();
|
||||
} catch (Throwable $e) {
|
||||
app('log')->error(sprintf('Cannot render reports.default.multi-year: %s', $e->getMessage()));
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error(sprintf('Cannot render reports.default.multi-year: %s', $e->getMessage()));
|
||||
Log::error($e->getTraceAsString());
|
||||
$result = sprintf('Could not render report view: %s', $e->getMessage());
|
||||
|
||||
throw new FireflyException($result, 0, $e);
|
||||
|
||||
@@ -28,6 +28,7 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Generator\Report\ReportGeneratorInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Throwable;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class MonthReportGenerator.
|
||||
@@ -60,8 +61,8 @@ class YearReportGenerator implements ReportGeneratorInterface
|
||||
compact('accountIds', 'reportType')
|
||||
)->with('start', $this->start)->with('end', $this->end)->render();
|
||||
} catch (Throwable $e) {
|
||||
app('log')->error(sprintf('Cannot render reports.account.report: %s', $e->getMessage()));
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error(sprintf('Cannot render reports.account.report: %s', $e->getMessage()));
|
||||
Log::error($e->getTraceAsString());
|
||||
$result = 'Could not render report view.';
|
||||
|
||||
throw new FireflyException($result, 0, $e);
|
||||
|
||||
@@ -29,6 +29,7 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Generator\Report\ReportGeneratorInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Throwable;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class MonthReportGenerator.
|
||||
@@ -67,8 +68,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
compact('accountIds', 'reportType', 'tagIds')
|
||||
)->with('start', $this->start)->with('end', $this->end)->with('tags', $this->tags)->with('accounts', $this->accounts)->render();
|
||||
} catch (Throwable $e) {
|
||||
app('log')->error(sprintf('Cannot render reports.tag.month: %s', $e->getMessage()));
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error(sprintf('Cannot render reports.tag.month: %s', $e->getMessage()));
|
||||
Log::error($e->getTraceAsString());
|
||||
$result = sprintf('Could not render report view: %s', $e->getMessage());
|
||||
|
||||
throw new FireflyException($result, 0, $e);
|
||||
|
||||
@@ -29,6 +29,7 @@ use FireflyIII\Notifications\User\NewAccessToken;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Laravel\Passport\Events\AccessTokenCreated;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class APIEventHandler
|
||||
@@ -40,7 +41,7 @@ class APIEventHandler
|
||||
*/
|
||||
public function accessTokenCreated(AccessTokenCreated $event): void
|
||||
{
|
||||
app('log')->debug(__METHOD__);
|
||||
Log::debug(__METHOD__);
|
||||
|
||||
/** @var UserRepositoryInterface $repository */
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
@@ -52,17 +53,17 @@ class APIEventHandler
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getMessage();
|
||||
if (str_contains($message, 'Bcc')) {
|
||||
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
if (str_contains($message, 'RFC 2822')) {
|
||||
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ use FireflyIII\Notifications\Test\OwnerTestNotificationSlack;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
|
||||
|
||||
/**
|
||||
* Class AdminEventHandler.
|
||||
*/
|
||||
@@ -55,17 +56,17 @@ class AdminEventHandler
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getMessage();
|
||||
if (str_contains($message, 'Bcc')) {
|
||||
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
if (str_contains($message, 'RFC 2822')) {
|
||||
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,17 +78,17 @@ class AdminEventHandler
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getMessage();
|
||||
if (str_contains($message, 'Bcc')) {
|
||||
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
if (str_contains($message, 'RFC 2822')) {
|
||||
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,17 +108,17 @@ class AdminEventHandler
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getMessage();
|
||||
if (str_contains($message, 'Bcc')) {
|
||||
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
if (str_contains($message, 'RFC 2822')) {
|
||||
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +151,7 @@ class AdminEventHandler
|
||||
break;
|
||||
|
||||
default:
|
||||
app('log')->error(sprintf('Unknown channel "%s" in sendTestNotification method.', $event->channel));
|
||||
Log::error(sprintf('Unknown channel "%s" in sendTestNotification method.', $event->channel));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -161,17 +162,17 @@ class AdminEventHandler
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getMessage();
|
||||
if (str_contains($message, 'Bcc')) {
|
||||
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
if (str_contains($message, 'RFC 2822')) {
|
||||
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
Log::debug(sprintf('If you see no errors above this line, test notification was sent over channel "%s"', $event->channel));
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace FireflyIII\Handlers\Events;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Events\TriggeredAuditLog;
|
||||
use FireflyIII\Repositories\AuditLogEntry\ALERepositoryInterface;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class AuditEventHandler
|
||||
@@ -44,20 +45,20 @@ class AuditEventHandler
|
||||
];
|
||||
|
||||
if ($event->before === $event->after) {
|
||||
app('log')->debug('Will not store event log because before and after are the same.');
|
||||
Log::debug('Will not store event log because before and after are the same.');
|
||||
|
||||
return;
|
||||
}
|
||||
if ($event->before instanceof Carbon && $event->after instanceof Carbon && $event->before->eq($event->after)) {
|
||||
app('log')->debug('Will not store event log because before and after Carbon values are the same.');
|
||||
Log::debug('Will not store event log because before and after Carbon values are the same.');
|
||||
|
||||
return;
|
||||
}
|
||||
if ($event->before instanceof Carbon && $event->after instanceof Carbon) {
|
||||
$array['before'] = $event->before->toIso8601String();
|
||||
$array['after'] = $event->after->toIso8601String();
|
||||
app('log')->debug(sprintf('Converted "before" to "%s".', $event->before));
|
||||
app('log')->debug(sprintf('Converted "after" to "%s".', $event->after));
|
||||
Log::debug(sprintf('Converted "before" to "%s".', $event->before));
|
||||
Log::debug(sprintf('Converted "after" to "%s".', $event->after));
|
||||
}
|
||||
|
||||
/** @var ALERepositoryInterface $repository */
|
||||
|
||||
@@ -30,8 +30,10 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
use FireflyIII\Notifications\User\TransactionCreation;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\Transformers\TransactionGroupTransformer;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class AutomationHandler
|
||||
@@ -45,27 +47,27 @@ class AutomationHandler
|
||||
*/
|
||||
public function reportJournals(RequestedReportOnJournals $event): void
|
||||
{
|
||||
app('log')->debug('In reportJournals.');
|
||||
Log::debug('In reportJournals.');
|
||||
|
||||
/** @var UserRepositoryInterface $repository */
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
$user = $repository->find($event->userId);
|
||||
|
||||
/** @var bool $sendReport */
|
||||
$sendReport = app('preferences')->getForUser($user, 'notification_transaction_creation', false)->data;
|
||||
$sendReport = Preferences::getForUser($user, 'notification_transaction_creation', false)->data;
|
||||
|
||||
if (false === $sendReport) {
|
||||
app('log')->debug('Not sending report, because config says so.');
|
||||
Log::debug('Not sending report, because config says so.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (null === $user || 0 === $event->groups->count()) {
|
||||
app('log')->debug('No transaction groups in event, nothing to email about.');
|
||||
Log::debug('No transaction groups in event, nothing to email about.');
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->debug('Continue with message!');
|
||||
Log::debug('Continue with message!');
|
||||
|
||||
// transform groups into array:
|
||||
/** @var TransactionGroupTransformer $transformer */
|
||||
@@ -82,18 +84,18 @@ class AutomationHandler
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getMessage();
|
||||
if (str_contains($message, 'Bcc')) {
|
||||
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
if (str_contains($message, 'RFC 2822')) {
|
||||
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
app('log')->debug('If there is no error above this line, message was sent.');
|
||||
Log::debug('If there is no error above this line, message was sent.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ class DestroyedGroupEventHandler
|
||||
|
||||
private function triggerWebhooks(DestroyedTransactionGroup $destroyedGroupEvent): void
|
||||
{
|
||||
app('log')->debug('DestroyedTransactionGroup:triggerWebhooks');
|
||||
Log::debug('DestroyedTransactionGroup:triggerWebhooks');
|
||||
$group = $destroyedGroupEvent->transactionGroup;
|
||||
$user = $group->user;
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ use FireflyIII\Models\PiggyBankEvent;
|
||||
use FireflyIII\Models\Rule;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class PiggyBankEventHandler
|
||||
@@ -70,7 +71,7 @@ class PiggyBankEventHandler
|
||||
->exists()
|
||||
;
|
||||
if ($exists) {
|
||||
app('log')->warning('Already have event for this journal and piggy, will not create another.');
|
||||
Log::warning('Already have event for this journal and piggy, will not create another.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace FireflyIII\Handlers\Events\Model;
|
||||
use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;
|
||||
use FireflyIII\Events\Model\Rule\RuleActionFailedOnObject;
|
||||
use FireflyIII\Notifications\User\RuleActionFailed;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
@@ -42,11 +43,11 @@ class RuleHandler
|
||||
$rule = $ruleAction->rule;
|
||||
|
||||
/** @var bool $preference */
|
||||
$preference = app('preferences')->getForUser($rule->user, 'notification_rule_action_failures', true)->data;
|
||||
$preference = Preferences::getForUser($rule->user, 'notification_rule_action_failures', true)->data;
|
||||
if (false === $preference) {
|
||||
return;
|
||||
}
|
||||
app('log')->debug('Now in ruleActionFailedOnArray');
|
||||
Log::debug('Now in ruleActionFailedOnArray');
|
||||
$journal = $event->journal;
|
||||
$error = $event->error;
|
||||
$user = $ruleAction->rule->user;
|
||||
@@ -71,11 +72,11 @@ class RuleHandler
|
||||
$rule = $ruleAction->rule;
|
||||
|
||||
/** @var bool $preference */
|
||||
$preference = app('preferences')->getForUser($rule->user, 'notification_rule_action_failures', true)->data;
|
||||
$preference = Preferences::getForUser($rule->user, 'notification_rule_action_failures', true)->data;
|
||||
if (false === $preference) {
|
||||
return;
|
||||
}
|
||||
app('log')->debug('Now in ruleActionFailedOnObject');
|
||||
Log::debug('Now in ruleActionFailedOnObject');
|
||||
$journal = $event->journal;
|
||||
$error = $event->error;
|
||||
$user = $ruleAction->rule->user;
|
||||
|
||||
@@ -40,12 +40,13 @@ use FireflyIII\Notifications\Security\MFAManyFailedAttemptsNotification;
|
||||
use FireflyIII\Notifications\Security\MFAUsedBackupCodeNotification;
|
||||
use FireflyIII\Notifications\Security\NewBackupCodesNotification;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class MFAHandler
|
||||
{
|
||||
public function sendBackupFewLeftMail(MFABackupFewLeft $event): void
|
||||
{
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
|
||||
$user = $event->user;
|
||||
$count = $event->count;
|
||||
@@ -55,23 +56,23 @@ class MFAHandler
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getMessage();
|
||||
if (str_contains($message, 'Bcc')) {
|
||||
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
if (str_contains($message, 'RFC 2822')) {
|
||||
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
}
|
||||
|
||||
public function sendBackupNoLeftMail(MFABackupNoLeft $event): void
|
||||
{
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
|
||||
$user = $event->user;
|
||||
|
||||
@@ -80,23 +81,23 @@ class MFAHandler
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getMessage();
|
||||
if (str_contains($message, 'Bcc')) {
|
||||
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
if (str_contains($message, 'RFC 2822')) {
|
||||
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
}
|
||||
|
||||
public function sendMFADisabledMail(DisabledMFA $event): void
|
||||
{
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
|
||||
$user = $event->user;
|
||||
|
||||
@@ -105,23 +106,23 @@ class MFAHandler
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getMessage();
|
||||
if (str_contains($message, 'Bcc')) {
|
||||
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
if (str_contains($message, 'RFC 2822')) {
|
||||
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
}
|
||||
|
||||
public function sendMFAEnabledMail(EnabledMFA $event): void
|
||||
{
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
|
||||
$user = $event->user;
|
||||
|
||||
@@ -130,23 +131,23 @@ class MFAHandler
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getMessage();
|
||||
if (str_contains($message, 'Bcc')) {
|
||||
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
if (str_contains($message, 'RFC 2822')) {
|
||||
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
}
|
||||
|
||||
public function sendMFAFailedAttemptsMail(MFAManyFailedAttempts $event): void
|
||||
{
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
|
||||
$user = $event->user;
|
||||
$count = $event->count;
|
||||
@@ -156,23 +157,23 @@ class MFAHandler
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getMessage();
|
||||
if (str_contains($message, 'Bcc')) {
|
||||
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
if (str_contains($message, 'RFC 2822')) {
|
||||
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
}
|
||||
|
||||
public function sendNewMFABackupCodesMail(MFANewBackupCodes $event): void
|
||||
{
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
|
||||
$user = $event->user;
|
||||
|
||||
@@ -181,23 +182,23 @@ class MFAHandler
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getMessage();
|
||||
if (str_contains($message, 'Bcc')) {
|
||||
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
if (str_contains($message, 'RFC 2822')) {
|
||||
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
}
|
||||
|
||||
public function sendUsedBackupCodeMail(MFAUsedBackupCode $event): void
|
||||
{
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
|
||||
$user = $event->user;
|
||||
|
||||
@@ -206,17 +207,17 @@ class MFAHandler
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getMessage();
|
||||
if (str_contains($message, 'Bcc')) {
|
||||
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
if (str_contains($message, 'RFC 2822')) {
|
||||
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,12 +51,14 @@ use FireflyIII\Notifications\User\UserLogin;
|
||||
use FireflyIII\Notifications\User\UserNewPassword;
|
||||
use FireflyIII\Notifications\User\UserRegistration as UserRegistrationNotification;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Auth\Events\Login;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
|
||||
|
||||
/**
|
||||
* Class UserEventHandler.
|
||||
*
|
||||
@@ -76,7 +78,7 @@ class UserEventHandler
|
||||
|
||||
// first user ever?
|
||||
if (1 === $repository->count()) {
|
||||
app('log')->debug('User count is one, attach role.');
|
||||
Log::debug('User count is one, attach role.');
|
||||
$repository->attachRole($event->user, 'owner');
|
||||
}
|
||||
}
|
||||
@@ -100,10 +102,10 @@ class UserEventHandler
|
||||
if (null === $role) {
|
||||
// create role, does not exist. Very strange situation so let's raise a big fuss about it.
|
||||
$role = $repository->createRole('owner', 'Site Owner', 'User runs this instance of FF3');
|
||||
app('log')->error('Could not find role "owner". This is weird.');
|
||||
Log::error('Could not find role "owner". This is weird.');
|
||||
}
|
||||
|
||||
app('log')->info(sprintf('Gave user #%d role #%d ("%s")', $user->id, $role->id, $role->name));
|
||||
Log::info(sprintf('Gave user #%d role #%d ("%s")', $user->id, $role->id, $role->name));
|
||||
// give user the role
|
||||
$repository->attachRole($user, 'owner');
|
||||
}
|
||||
@@ -174,9 +176,10 @@ class UserEventHandler
|
||||
$user = $event->user;
|
||||
if ($repository->hasRole($user, 'demo')) {
|
||||
// set user back to English.
|
||||
app('preferences')->setForUser($user, 'language', 'en_US');
|
||||
app('preferences')->setForUser($user, 'locale', 'equal');
|
||||
app('preferences')->mark();
|
||||
Preferences::setForUser($user, 'language', 'en_US');
|
||||
Preferences::setForUser($user, 'locale', 'equal');
|
||||
Preferences::setForUser($user, 'anonymous', false);
|
||||
Preferences::mark();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,7 +191,7 @@ class UserEventHandler
|
||||
return; // do not email demo user.
|
||||
}
|
||||
|
||||
$list = app('preferences')->getForUser($user, 'login_ip_history', [])->data;
|
||||
$list = Preferences::getForUser($user, 'login_ip_history', [])->data;
|
||||
if (!is_array($list)) {
|
||||
$list = [];
|
||||
}
|
||||
@@ -201,28 +204,28 @@ class UserEventHandler
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getMessage();
|
||||
if (str_contains($message, 'Bcc')) {
|
||||
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
if (str_contains($message, 'RFC 2822')) {
|
||||
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
}
|
||||
$list[$index]['notified'] = true;
|
||||
}
|
||||
|
||||
app('preferences')->setForUser($user, 'login_ip_history', $list);
|
||||
Preferences::setForUser($user, 'login_ip_history', $list);
|
||||
}
|
||||
|
||||
public function sendAdminRegistrationNotification(RegisteredUser $event): void
|
||||
{
|
||||
$sendMail = (bool) app('fireflyconfig')->get('notification_admin_new_reg', true)->data;
|
||||
$sendMail = (bool)app('fireflyconfig')->get('notification_admin_new_reg', true)->data;
|
||||
if ($sendMail) {
|
||||
$owner = $event->owner;
|
||||
|
||||
@@ -231,17 +234,17 @@ class UserEventHandler
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getMessage();
|
||||
if (str_contains($message, 'Bcc')) {
|
||||
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
if (str_contains($message, 'RFC 2822')) {
|
||||
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -257,14 +260,14 @@ class UserEventHandler
|
||||
$newEmail = $event->newEmail;
|
||||
$oldEmail = $event->oldEmail;
|
||||
$user = $event->user;
|
||||
$token = app('preferences')->getForUser($user, 'email_change_confirm_token', 'invalid');
|
||||
$token = Preferences::getForUser($user, 'email_change_confirm_token', 'invalid');
|
||||
$url = route('profile.confirm-email-change', [$token->data]);
|
||||
|
||||
try {
|
||||
Mail::to($newEmail)->send(new ConfirmEmailChangeMail($newEmail, $oldEmail, $url));
|
||||
} catch (Exception $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
|
||||
throw new FireflyException($e->getMessage(), 0, $e);
|
||||
}
|
||||
@@ -281,15 +284,15 @@ class UserEventHandler
|
||||
$newEmail = $event->newEmail;
|
||||
$oldEmail = $event->oldEmail;
|
||||
$user = $event->user;
|
||||
$token = app('preferences')->getForUser($user, 'email_change_undo_token', 'invalid');
|
||||
$hashed = hash('sha256', sprintf('%s%s', (string) config('app.key'), $oldEmail));
|
||||
$token = Preferences::getForUser($user, 'email_change_undo_token', 'invalid');
|
||||
$hashed = hash('sha256', sprintf('%s%s', (string)config('app.key'), $oldEmail));
|
||||
$url = route('profile.undo-email-change', [$token->data, $hashed]);
|
||||
|
||||
try {
|
||||
Mail::to($oldEmail)->send(new UndoEmailChangeMail($newEmail, $oldEmail, $url));
|
||||
} catch (Exception $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
|
||||
throw new FireflyException($e->getMessage(), 0, $e);
|
||||
}
|
||||
@@ -302,17 +305,17 @@ class UserEventHandler
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getMessage();
|
||||
if (str_contains($message, 'Bcc')) {
|
||||
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
if (str_contains($message, 'RFC 2822')) {
|
||||
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,17 +329,17 @@ class UserEventHandler
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getMessage();
|
||||
if (str_contains($message, 'Bcc')) {
|
||||
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
if (str_contains($message, 'RFC 2822')) {
|
||||
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,8 +355,8 @@ class UserEventHandler
|
||||
try {
|
||||
Mail::to($invitee)->send(new InvitationMail($invitee, $admin, $url));
|
||||
} catch (Exception $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
|
||||
throw new FireflyException($e->getMessage(), 0, $e);
|
||||
}
|
||||
@@ -365,24 +368,24 @@ class UserEventHandler
|
||||
*/
|
||||
public function sendRegistrationMail(RegisteredUser $event): void
|
||||
{
|
||||
$sendMail = (bool) app('fireflyconfig')->get('notification_user_new_reg', true)->data;
|
||||
$sendMail = (bool)app('fireflyconfig')->get('notification_user_new_reg', true)->data;
|
||||
if ($sendMail) {
|
||||
try {
|
||||
Notification::send($event->user, new UserRegistrationNotification());
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getMessage();
|
||||
if (str_contains($message, 'Bcc')) {
|
||||
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
if (str_contains($message, 'RFC 2822')) {
|
||||
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -416,7 +419,7 @@ class UserEventHandler
|
||||
break;
|
||||
|
||||
default:
|
||||
app('log')->error(sprintf('Unknown channel "%s" in (user) sendTestNotification method.', $event->channel));
|
||||
Log::error(sprintf('Unknown channel "%s" in (user) sendTestNotification method.', $event->channel));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -427,56 +430,56 @@ class UserEventHandler
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getMessage();
|
||||
if (str_contains($message, 'Bcc')) {
|
||||
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
if (str_contains($message, 'RFC 2822')) {
|
||||
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
Log::debug(sprintf('If you see no errors above this line, test notification was sent over channel "%s"', $event->channel));
|
||||
}
|
||||
|
||||
public function storeUserIPAddress(ActuallyLoggedIn $event): void
|
||||
{
|
||||
app('log')->debug('Now in storeUserIPAddress');
|
||||
Log::debug('Now in storeUserIPAddress');
|
||||
$user = $event->user;
|
||||
|
||||
if ($user->hasRole('demo')) {
|
||||
app('log')->debug('Do not log demo user logins');
|
||||
Log::debug('Do not log demo user logins');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
/** @var array $preference */
|
||||
$preference = app('preferences')->getForUser($user, 'login_ip_history', [])->data;
|
||||
$preference = Preferences::getForUser($user, 'login_ip_history', [])->data;
|
||||
} catch (FireflyException $e) {
|
||||
// don't care.
|
||||
app('log')->error($e->getMessage());
|
||||
Log::error($e->getMessage());
|
||||
|
||||
return;
|
||||
}
|
||||
$inArray = false;
|
||||
$ip = request()->ip();
|
||||
app('log')->debug(sprintf('User logging in from IP address %s', $ip));
|
||||
Log::debug(sprintf('User logging in from IP address %s', $ip));
|
||||
|
||||
// update array if in array
|
||||
foreach ($preference as $index => $row) {
|
||||
if ($row['ip'] === $ip) {
|
||||
app('log')->debug('Found IP in array, refresh time.');
|
||||
Log::debug('Found IP in array, refresh time.');
|
||||
$preference[$index]['time'] = now(config('app.timezone'))->format('Y-m-d H:i:s');
|
||||
$inArray = true;
|
||||
}
|
||||
// clean up old entries (6 months)
|
||||
$carbon = Carbon::createFromFormat('Y-m-d H:i:s', $preference[$index]['time']);
|
||||
if ($carbon instanceof Carbon && $carbon->diffInMonths(today(), true) > 6) {
|
||||
app('log')->debug(sprintf('Entry for %s is very old, remove it.', $row['ip']));
|
||||
Log::debug(sprintf('Entry for %s is very old, remove it.', $row['ip']));
|
||||
unset($preference[$index]);
|
||||
}
|
||||
}
|
||||
@@ -491,8 +494,8 @@ class UserEventHandler
|
||||
$preference = array_values($preference);
|
||||
|
||||
/** @var bool $send */
|
||||
$send = app('preferences')->getForUser($user, 'notification_user_login', true)->data;
|
||||
app('preferences')->setForUser($user, 'login_ip_history', $preference);
|
||||
$send = Preferences::getForUser($user, 'notification_user_login', true)->data;
|
||||
Preferences::setForUser($user, 'login_ip_history', $preference);
|
||||
|
||||
if (false === $inArray && true === $send) {
|
||||
event(new DetectedNewIPAddress($user));
|
||||
|
||||
@@ -36,6 +36,7 @@ use FireflyIII\Support\Http\Api\ExchangeRateConverter;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
||||
/**
|
||||
* Class AccountObserver
|
||||
*/
|
||||
@@ -75,7 +76,7 @@ class AccountObserver
|
||||
*/
|
||||
public function deleting(Account $account): void
|
||||
{
|
||||
app('log')->debug('Observe "deleting" of an account.');
|
||||
Log::debug('Observe "deleting" of an account.');
|
||||
|
||||
$repository = app(AttachmentRepositoryInterface::class);
|
||||
$repository->setUser($account->user);
|
||||
|
||||
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Handlers\Observer;
|
||||
|
||||
use FireflyIII\Models\Attachment;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class AttachmentObserver
|
||||
@@ -32,7 +33,7 @@ class AttachmentObserver
|
||||
{
|
||||
public function deleting(Attachment $attachment): void
|
||||
{
|
||||
app('log')->debug('Observe "deleting" of an attachment.');
|
||||
Log::debug('Observe "deleting" of an attachment.');
|
||||
$attachment->notes()->delete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ use FireflyIII\Support\Facades\Amount;
|
||||
use FireflyIII\Support\Http\Api\ExchangeRateConverter;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
||||
/**
|
||||
* Class BillObserver
|
||||
*/
|
||||
@@ -65,7 +66,7 @@ class BillObserver
|
||||
$repository = app(AttachmentRepositoryInterface::class);
|
||||
$repository->setUser($bill->user);
|
||||
|
||||
// app('log')->debug('Observe "deleting" of a bill.');
|
||||
// Log::debug('Observe "deleting" of a bill.');
|
||||
/** @var Attachment $attachment */
|
||||
foreach ($bill->attachments()->get() as $attachment) {
|
||||
$repository->destroy($attachment);
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace FireflyIII\Handlers\Observer;
|
||||
use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class CategoryObserver
|
||||
@@ -34,7 +35,7 @@ class CategoryObserver
|
||||
{
|
||||
public function deleting(Category $category): void
|
||||
{
|
||||
app('log')->debug('Observe "deleting" of a category.');
|
||||
Log::debug('Observe "deleting" of a category.');
|
||||
|
||||
$repository = app(AttachmentRepositoryInterface::class);
|
||||
$repository->setUser($category->user);
|
||||
|
||||
@@ -30,6 +30,7 @@ use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||
use FireflyIII\Support\Http\Api\ExchangeRateConverter;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
||||
/**
|
||||
* Class PiggyBankObserver
|
||||
*/
|
||||
@@ -66,7 +67,7 @@ class PiggyBankObserver
|
||||
*/
|
||||
public function deleting(PiggyBank $piggyBank): void
|
||||
{
|
||||
app('log')->debug('Observe "deleting" of a piggy bank.');
|
||||
Log::debug('Observe "deleting" of a piggy bank.');
|
||||
|
||||
$repository = app(AttachmentRepositoryInterface::class);
|
||||
$repository->setUser($piggyBank->accounts()->first()->user);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user