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.
70
70
71
71
The username that will send the message in Slack.
72
72
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
+
73
81
## Customization
74
82
75
83
` 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 = {
136
136
137
137
var channel = this . readConfig ( 'channel' ) ;
138
138
var username = this . readConfig ( 'username' ) ;
139
+ var iconURL = this . readConfig ( 'iconURL' ) ;
140
+ var iconEmoji = this . readConfig ( 'iconEmoji' ) ;
139
141
140
142
return this . readConfig ( 'slackNotifier' ) || new SlackNotifier ( {
141
143
enabled : enabled ,
142
144
webhookURL : webhookURL ,
143
145
channel : channel ,
144
- username : username
146
+ username : username ,
147
+ iconURL : iconURL ,
148
+ iconEmoji : iconEmoji
145
149
} ) ;
146
150
}
147
151
} ) ;
Original file line number Diff line number Diff line change @@ -6,10 +6,7 @@ module.exports = CoreObject.extend({
6
6
init : function ( data ) {
7
7
this . _super ( data ) ;
8
8
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 ( ) ) ;
13
10
14
11
this . notify = function ( message ) {
15
12
return new Promise ( function ( resolve , reject ) {
@@ -24,5 +21,19 @@ module.exports = CoreObject.extend({
24
21
}
25
22
} . bind ( this ) ) ;
26
23
}
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 ;
27
38
}
28
39
} ) ;
Original file line number Diff line number Diff line change @@ -38,6 +38,42 @@ describe('SlackNotifier', function() {
38
38
expect ( slack . username ) . to . eql ( USER_NAME ) ;
39
39
} ) ;
40
40
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
+
41
77
describe ( 'enabled' , function ( ) {
42
78
describe ( '#notify' , function ( ) {
43
79
it ( 'is callable' , function ( ) {
You can’t perform that action at this time.
0 commit comments