File tree Expand file tree Collapse file tree 4 files changed +64
-5
lines changed
Expand file tree Collapse file tree 4 files changed +64
-5
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,14 @@ The channel in slack that the notification should be displayed in in Slack.
7070
7171The username that will send the message in Slack.
7272
73+ ###iconURL
74+
75+ URL to an image to use as the message's icon.
76+
77+ ###iconEmoji
78+
79+ Slack emoji code to use as the message's icon (like ` :heart_eyes_cat: ` or ` :saxophone: ` ).
80+
7381## Customization
7482
7583` ember-cli-deploy-slack ` will send default messages on the ` didDeploy ` - and
Original file line number Diff line number Diff line change @@ -136,12 +136,16 @@ module.exports = {
136136
137137 var channel = this . readConfig ( 'channel' ) ;
138138 var username = this . readConfig ( 'username' ) ;
139+ var iconURL = this . readConfig ( 'iconURL' ) ;
140+ var iconEmoji = this . readConfig ( 'iconEmoji' ) ;
139141
140142 return this . readConfig ( 'slackNotifier' ) || new SlackNotifier ( {
141143 enabled : enabled ,
142144 webhookURL : webhookURL ,
143145 channel : channel ,
144- username : username
146+ username : username ,
147+ iconURL : iconURL ,
148+ iconEmoji : iconEmoji
145149 } ) ;
146150 }
147151 } ) ;
Original file line number Diff line number Diff line change @@ -6,10 +6,7 @@ module.exports = CoreObject.extend({
66 init : function ( data ) {
77 this . _super ( data ) ;
88
9- this . slack = new Slack ( this . webhookURL , {
10- channel : this . channel ,
11- username : this . username
12- } ) ;
9+ this . slack = new Slack ( this . webhookURL , this . _getSlackOptions ( ) ) ;
1310
1411 this . notify = function ( message ) {
1512 return new Promise ( function ( resolve , reject ) {
@@ -24,5 +21,19 @@ module.exports = CoreObject.extend({
2421 }
2522 } . bind ( this ) ) ;
2623 }
24+ } ,
25+
26+ _getSlackOptions : function ( ) {
27+ var options = {
28+ channel : this . channel ,
29+ username : this . username
30+ } ;
31+ if ( this . iconURL ) {
32+ options . icon_url = this . iconURL ;
33+ }
34+ if ( this . iconEmoji ) {
35+ options . icon_emoji = this . iconEmoji ;
36+ }
37+ return options ;
2738 }
2839} ) ;
Original file line number Diff line number Diff line change @@ -38,6 +38,42 @@ describe('SlackNotifier', function() {
3838 expect ( slack . username ) . to . eql ( USER_NAME ) ;
3939 } ) ;
4040
41+ describe ( '#_getSlackOptions' , function ( ) {
42+ it ( "snake_cases and adds `iconURL` and/or `iconEmoji` options if they are set" , function ( ) {
43+ var iconEmojiOnly = new SlackNotifier ( {
44+ enabled : true ,
45+ webhookURL : WEBHOOK_URL ,
46+ channel : CHANNEL ,
47+ username : USER_NAME ,
48+ iconEmoji : ':dromedary_camel:'
49+ } ) ;
50+ var bothOptions = new SlackNotifier ( {
51+ enabled : true ,
52+ webhookURL : WEBHOOK_URL ,
53+ channel : CHANNEL ,
54+ username : USER_NAME ,
55+ iconEmoji : ':dromedary_camel:' ,
56+ iconURL : 'http://placehold.it/128x128'
57+ } ) ;
58+
59+ expect ( slack . _getSlackOptions ( ) ) . to . eql ( {
60+ channel : CHANNEL ,
61+ username : USER_NAME
62+ } ) ;
63+ expect ( iconEmojiOnly . _getSlackOptions ( ) ) . to . eql ( {
64+ channel : CHANNEL ,
65+ username : USER_NAME ,
66+ icon_emoji : ':dromedary_camel:'
67+ } ) ;
68+ expect ( bothOptions . _getSlackOptions ( ) ) . to . eql ( {
69+ channel : CHANNEL ,
70+ username : USER_NAME ,
71+ icon_emoji : ':dromedary_camel:' ,
72+ icon_url : 'http://placehold.it/128x128'
73+ } ) ;
74+ } ) ;
75+ } ) ;
76+
4177 describe ( 'enabled' , function ( ) {
4278 describe ( '#notify' , function ( ) {
4379 it ( 'is callable' , function ( ) {
You can’t perform that action at this time.
0 commit comments