Skip to content

Commit be3a1fe

Browse files
committed
Merge branch 'release/0.6.0'
# Conflicts: # app/Http/Controllers/Import/MapController.php # config/importer.php
2 parents 37c0735 + dc64d38 commit be3a1fe

22 files changed

Lines changed: 572 additions & 317 deletions

File tree

.env.example

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ SPECTRE_SECRET=
5959
#
6060
USE_CACHE=false
6161

62+
#
63+
# If set to true, the data import will not complain about running into duplicates.
64+
# This will give you cleaner import mails if you run regular imports.
65+
#
66+
# Of course, if something goes wrong *because* the transaction is a duplicate you will
67+
# NEVER know unless you start digging in your log files. So be careful with this.
68+
#
69+
IGNORE_DUPLICATE_ERRORS=false
70+
6271
#
6372
# Auto import settings. Due to security constraints, you MUST enable each feature individually.
6473
# You must also set a secret. The secret is used for the web routes.

app/Handlers/Events/ImportedTransactionsEventHandler.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,15 @@ public function sendReportOverMail(ImportedTransactions $event): void
5454
'warnings' => $event->warnings,
5555
'errors' => $event->errors,
5656
];
57-
app('log')->info('Will send report message.');
58-
app('log')->debug('If no error below this line, mail was sent!');
59-
Mail::to(config('mail.destination'))->send(new ImportReportMail($log));
60-
app('log')->debug('If no error above this line, mail was sent!');
57+
if (count($event->messages) > 0 || count($event->warnings) > 0 || count($event->errors) > 0) {
58+
app('log')->info('Will send report message.');
59+
app('log')->debug('If no error below this line, mail was sent!');
60+
Mail::to(config('mail.destination'))->send(new ImportReportMail($log));
61+
app('log')->debug('If no error above this line, mail was sent!');
62+
}
63+
if (0 === count($event->messages) && 0 === count($event->warnings) && 0 === count($event->errors)) {
64+
app('log')->info('There is nothing to report, will not send a message.');
65+
}
6166
}
6267

6368
}

app/Http/Controllers/DebugController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function index(Request $request)
6767
$isDocker = env('IS_DOCKER', false);
6868

6969
if(file_exists('/var/www/counter-main.txt')) {
70-
$buildNr = file_get_contents('/var/www/counter-main.txt');
70+
$buildNr = trim(file_get_contents('/var/www/counter-main.txt'));
7171
}
7272

7373
// get latest log file:

app/Http/Controllers/Import/MapController.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,14 @@ public function index()
8080
$roles = [];
8181

8282
if ('csv' === $configuration->getFlow()) {
83+
Log::debug('Get mapping data for CSV');
8384
$roles = $configuration->getRoles();
8485
$data = $this->getCSVMapInformation();
8586
}
8687

8788
// nordigen, spectre and others:
8889
if ('csv' !== $configuration->getFlow()) {
90+
Log::debug('Get mapping data for nordigen and spectre');
8991
$roles = [];
9092
$data = $this->getImporterMapInformation();
9193
}
@@ -94,6 +96,12 @@ public function index()
9496
if (0 === count($data)) {
9597
// set map config as complete.
9698
session()->put(Constants::MAPPING_COMPLETE_INDICATOR, true);
99+
100+
// if CSV, now ready for conversion
101+
if ('csv' === $configuration->getFlow()) {
102+
Log::debug('Its CSV, also set ready for conversion.');
103+
session()->put(Constants::READY_FOR_CONVERSION, true);
104+
}
97105
return redirect()->route('007-convert.index');
98106
}
99107

app/Http/Controllers/TokenController.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,25 +205,23 @@ public function submitClientId(Request $request)
205205
* This method will check if Firefly III accepts the access_token from the cookie
206206
* and the base URL (also from the cookie). The base_url is NEVER the vanity URL.§
207207
*
208-
* @param Request $request
209-
*
210208
* @return JsonResponse
211209
*/
212-
public function doValidate(Request $request): JsonResponse
210+
public function doValidate(): JsonResponse
213211
{
214212
Log::debug(sprintf('Now at %s', __METHOD__));
215213
$response = ['result' => 'OK', 'message' => null];
216214

217215
// get values from secret manager:
218216
$url = SecretManager::getBaseUrl();
219217
$token = SecretManager::getAccessToken();
220-
$request = new SystemInformationRequest($url, $token);
218+
$infoRequest = new SystemInformationRequest($url, $token);
221219

222-
$request->setVerify(config('importer.connection.verify'));
223-
$request->setTimeOut(config('importer.connection.timeout'));
220+
$infoRequest->setVerify(config('importer.connection.verify'));
221+
$infoRequest->setTimeOut(config('importer.connection.timeout'));
224222

225223
try {
226-
$result = $request->get();
224+
$result = $infoRequest->get();
227225
} catch (ApiHttpException $e) {
228226
Log::error(sprintf('Could not connect to Firefly III: %s', $e->getMessage()));
229227

app/Http/Request/AutoUploadRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function authorize(): bool
4545
public function rules(): array
4646
{
4747
return [
48-
'csv' => 'required|file',
48+
'csv' => 'file',
4949
'json' => 'required|file',
5050
];
5151

app/Services/CSV/Configuration/ConfigFileProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static function convertConfigFile(string $fileName): Configuration
5151
$content = StorageService::getContent($fileName);
5252
} catch (FileNotFoundException $e) {
5353
app('log')->error($e->getMessage());
54-
throw new ImporterErrorException(sprintf('Cpuld not find config file: %s', $e->getMessage()));
54+
throw new ImporterErrorException(sprintf('Could not find config file: %s', $e->getMessage()));
5555
}
5656
try {
5757
$json = json_decode($content, true, 512, JSON_THROW_ON_ERROR);

app/Services/Shared/Authentication/SecretManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class SecretManager
3737
public const ACCESS_TOKEN = 'access_token';
3838
public const BASE_URL = 'base_url';
3939
public const REFRESH_TOKEN = 'refresh_token';
40-
public const VANITY_URL = 'base_url';
40+
public const VANITY_URL = 'vanity_url';
4141

4242
/**
4343
* Will return true if the session / cookies hold valid secrets (access token, URLs)

app/Services/Shared/Configuration/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public static function fromRequest(array $array): self
164164
$delimiters = config('csv.delimiters_reversed');
165165
$object = new self;
166166
$object->version = self::VERSION;
167-
$object->headers = $array['headers'];
167+
$object->headers = $array['headers'] ?? false;
168168
$object->date = $array['date'];
169169
$object->defaultAccount = $array['default_account'];
170170
$object->delimiter = $delimiters[$array['delimiter']] ?? 'comma';

app/Services/Shared/Conversion/RoutineStatusManager.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,17 @@ public static function startOrFindConversion(string $identifier): ConversionStat
177177
{
178178
app('log')->debug(sprintf('Now in startOrFindConversion(%s)', $identifier));
179179
$disk = Storage::disk(self::DISK_NAME);
180-
app('log')->debug(sprintf('Try to see if file exists for conversion "%s".', $identifier));
180+
//app('log')->debug(sprintf('Try to see if file exists for conversion "%s".', $identifier));
181181
if ($disk->exists($identifier)) {
182-
app('log')->debug(sprintf('Status file exists for conversion "%s".', $identifier));
182+
//app('log')->debug(sprintf('Status file exists for conversion "%s".', $identifier));
183183
try {
184184
$array = json_decode($disk->get($identifier), true, 512, JSON_THROW_ON_ERROR);
185185
$status = ConversionStatus::fromArray($array);
186186
} catch (FileNotFoundException | JsonException $e) {
187187
app('log')->error($e->getMessage());
188188
$status = new ConversionStatus;
189189
}
190+
app('log')->debug(sprintf('Conversion status is "%s"', $status->status));
190191

191192
return $status;
192193

0 commit comments

Comments
 (0)