mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 23:45:10 +00:00
Make sure that errors in the incoming webhook url are caught.
This commit is contained in:
@@ -27,7 +27,9 @@ namespace FireflyIII\Handlers\Events\Model;
|
|||||||
use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;
|
use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;
|
||||||
use FireflyIII\Events\Model\Rule\RuleActionFailedOnObject;
|
use FireflyIII\Events\Model\Rule\RuleActionFailedOnObject;
|
||||||
use FireflyIII\Notifications\User\RuleActionFailed;
|
use FireflyIII\Notifications\User\RuleActionFailed;
|
||||||
|
use GuzzleHttp\Exception\ClientException;
|
||||||
use Illuminate\Support\Facades\Notification;
|
use Illuminate\Support\Facades\Notification;
|
||||||
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class RuleHandler
|
* Class RuleHandler
|
||||||
@@ -55,8 +57,11 @@ class RuleHandler
|
|||||||
$ruleTitle = $rule->title;
|
$ruleTitle = $rule->title;
|
||||||
$ruleLink = route('rules.edit', [$rule->id]);
|
$ruleLink = route('rules.edit', [$rule->id]);
|
||||||
$params = [$mainMessage, $groupTitle, $groupLink, $ruleTitle, $ruleLink];
|
$params = [$mainMessage, $groupTitle, $groupLink, $ruleTitle, $ruleLink];
|
||||||
|
try {
|
||||||
Notification::send($user, new RuleActionFailed($params));
|
Notification::send($user, new RuleActionFailed($params));
|
||||||
|
} catch(ClientException $e) {
|
||||||
|
Log::error(sprintf('[a] Error sending notification that the rule action failed: %s', $e->getMessage()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ruleActionFailedOnObject(RuleActionFailedOnObject $event): void
|
public function ruleActionFailedOnObject(RuleActionFailedOnObject $event): void
|
||||||
@@ -80,7 +85,10 @@ class RuleHandler
|
|||||||
$ruleTitle = $rule->title;
|
$ruleTitle = $rule->title;
|
||||||
$ruleLink = route('rules.edit', [$rule->id]);
|
$ruleLink = route('rules.edit', [$rule->id]);
|
||||||
$params = [$mainMessage, $groupTitle, $groupLink, $ruleTitle, $ruleLink];
|
$params = [$mainMessage, $groupTitle, $groupLink, $ruleTitle, $ruleLink];
|
||||||
|
try {
|
||||||
Notification::send($user, new RuleActionFailed($params));
|
Notification::send($user, new RuleActionFailed($params));
|
||||||
|
} catch(ClientException $e) {
|
||||||
|
Log::error(sprintf('[b] Error sending notification that the rule action failed: %s', $e->getMessage()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -112,11 +112,11 @@ class RuleActionFailed extends Notification
|
|||||||
$slackUrl = '';
|
$slackUrl = '';
|
||||||
}
|
}
|
||||||
if (UrlValidator::isValidWebhookURL((string)$slackUrl)) {
|
if (UrlValidator::isValidWebhookURL((string)$slackUrl)) {
|
||||||
app('log')->debug('Will send ruleActionFailed through Slack!');
|
app('log')->debug('Will send ruleActionFailed through Slack or Discord!');
|
||||||
|
|
||||||
return ['slack'];
|
return ['slack'];
|
||||||
}
|
}
|
||||||
app('log')->debug('Will NOT send ruleActionFailed through Slack');
|
app('log')->debug('Will NOT send ruleActionFailed through Slack or Discord');
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user