File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1212use Lang ;
1313use Accessory ;
1414use DB ;
15+ use Slack ;
16+ use Setting ;
17+ use Config ;
1518
1619class ViewAssetsController extends AuthorizedController
1720{
@@ -66,6 +69,37 @@ public function getRequestAsset($assetId = null) {
6669 $ logaction ->user_id = Sentry::getUser ()->id ;
6770 $ log = $ logaction ->logaction ('requested ' );
6871
72+ $ settings = Setting::getSettings ();
73+
74+ if ($ settings ->slack_endpoint ) {
75+
76+
77+ $ slack_settings = [
78+ 'username ' => $ settings ->botname ,
79+ 'channel ' => $ settings ->slack_channel ,
80+ 'link_names ' => true
81+ ];
82+
83+ $ client = new \Maknz \Slack \Client ($ settings ->slack_endpoint ,$ slack_settings );
84+
85+ try {
86+ $ client ->attach ([
87+ 'color ' => 'good ' ,
88+ 'fields ' => [
89+ [
90+ 'title ' => 'REQUESTED: ' ,
91+ 'value ' => strtoupper ($ logaction ->asset_type ).' asset < ' .Config::get ('app.url ' ).'/hardware/ ' .$ asset ->id .'/view ' .'| ' .$ asset ->showAssetName ().'> requested by < ' .Config::get ('app.url ' ).'/hardware/ ' .$ asset ->id .'/view ' .'| ' .Sentry::getUser ()->fullName ().'>. '
92+ ]
93+
94+ ]
95+ ])->send ('Asset Requested ' );
96+
97+ } catch (Exception $ e ) {
98+
99+ }
100+
101+ }
102+
69103 return Redirect::route ('requestable-assets ' )->with ('success ' )->with ('success ' , Lang::get ('admin/hardware/message.requests.success ' ));
70104 }
71105
You can’t perform that action at this time.
0 commit comments