lbry.com/lib/thirdparty/Slack.class.php
2019-10-09 14:28:25 -04:00

24 lines
840 B
PHP

<?php
class Slack
{
public static function sendErrorIfProd($e, $alert = true)
{
if ($e instanceof Throwable) {
$e = Debug::exceptionToString($e);
}
$slackErrorNotificationUrl = Config::get(Config::SLACK_ERROR_NOTIFICATION_URL);
if ($slackErrorNotificationUrl) {
Curl::post($slackErrorNotificationUrl, ['text' => ($alert ? '<!channel> ' : '') . Request::getRelativeUri() . "\n" . $e], ['json_data' => true]);
}
}
public static function slackGrin()
{
$slackErrorNotificationUrl = Config::get(Config::SLACK_ERROR_NOTIFICATION_URL);
if ($slackErrorNotificationUrl) {
Curl::post($slackErrorNotificationUrl, ['text' => '<@U1R0URBC1> Failed to parse html on ' . Request::getRelativeUri()], ['json_data' => true]);
}
}
}