File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -27,3 +27,7 @@ PROXY_METHOD=
2727PROXY_SERVER =
2828PROXY_USER =
2929PROXY_PASS =
30+
31+ SLACK_CHANNEL = channel-name
32+ SLACK_BOT_NAME = bot-name
33+ SLACK_WEBHOOK = endpoint
Original file line number Diff line number Diff line change 33namespace GitScrum \Services ;
44
55use GitScrum \Contracts \SlackInterface ;
6+ use Log ;
67use Maknz \Slack \Client ;
78
89
@@ -16,6 +17,9 @@ class SlackService implements SlackInterface
1617
1718 public function __construct ()
1819 {
20+ $ channel = env ('SLACK_CHANNEL ' , '' );
21+ $ username = env ('SLACK_BOT_NAME ' , '' );
22+ $ webhook = env ('SLACK_WEBHOOK ' , '' );
1923 $ this ->settings = [
2024 'channel ' => env ('SLACK_CHANNEL ' , '' ),
2125 'username ' => env ('SLACK_BOT_NAME ' , '' ),
@@ -36,6 +40,13 @@ public function __construct()
3640 */
3741 public function send ($ content , $ type = 0 )
3842 {
43+ if (empty ($ this ->client ->getEndpoint ()) || empty ($ this ->client ->getDefaultChannel ())
44+ || empty ($ this ->client ->getDefaultUsername ())) {
45+ Log::info ('One or more settings are missing, Slack notifications are not availables ' );
46+
47+ return ;
48+ }
49+
3950 $ message = $ this ->buildMessage ($ content , $ type );
4051 $ this ->client ->attach ([
4152 'title ' => $ content ['title ' ],
You can’t perform that action at this time.
0 commit comments