@@ -69,11 +69,11 @@ class IssueFilter
69
69
class RecentIssues
70
70
constructor : (@maxage ) ->
71
71
@issues = []
72
-
72
+
73
73
cleanup : ->
74
74
for issue,time of @issues
75
75
age = Math .round (((new Date ()).getTime () - time) / 1000 )
76
- if age > @maxage
76
+ if age > @maxage
77
77
# console.log 'removing old issue', issue
78
78
delete @issues [issue]
79
79
0
@@ -83,7 +83,7 @@ class RecentIssues
83
83
@issues [issue]?
84
84
85
85
add : (issue ,time ) ->
86
- time = time || (new Date ()).getTime ()
86
+ time = time || (new Date ()).getTime ()
87
87
@issues [issue] = time
88
88
89
89
@@ -107,8 +107,17 @@ module.exports = (robot) ->
107
107
if (process .env .HUBOT_JIRA_USER )
108
108
authdata = new Buffer (process .env .HUBOT_JIRA_USER + ' :' + process .env .HUBOT_JIRA_PASSWORD ).toString (' base64' )
109
109
httprequest = httprequest .header (' Authorization' , ' Basic ' + authdata)
110
+
110
111
httprequest .get () (err , res , body ) ->
112
+ if err
113
+ res .send " GET failed :( #{ err} "
114
+ return
115
+
116
+ if res .statusCode is 200
111
117
cb JSON .parse (body)
118
+ else
119
+ console .log (" res.statusCode = " + res .statusCode )
120
+ console .log (" body = " + body)
112
121
113
122
watchers = (msg , issue , cb ) ->
114
123
get msg, " issue/#{ issue} /watchers" , (watchers ) ->
@@ -156,12 +165,12 @@ module.exports = (robot) ->
156
165
url : process .env .HUBOT_JIRA_URL + ' /browse/' + issues .key
157
166
158
167
cb " [#{ issue .key } ] #{ issue .summary } . #{ issue .assignee ()} / #{ issue .status } , #{ issue .fixVersion ()} #{ issue .url } "
159
-
168
+
160
169
search = (msg , jql , cb ) ->
161
170
get msg, " search/?jql=#{ escape (jql)} " , (result ) ->
162
171
if result .errors ?
163
172
return
164
-
173
+
165
174
resultText = " I found #{ result .total } issues for your search. #{ process .env .HUBOT_JIRA_URL } /secure/IssueNavigator.jspa?reset=true&jqlQuery=#{ escape (jql)} "
166
175
if result .issues .length <= maxlist
167
176
cb resultText
@@ -177,22 +186,22 @@ module.exports = (robot) ->
177
186
178
187
watchers msg, msg .match [3 ], (text ) ->
179
188
msg .send text
180
-
189
+
181
190
robot .respond / search (for )? (. * )/ i , (msg ) ->
182
191
if msg .message .user .id is robot .name
183
192
return
184
-
193
+
185
194
search msg, msg .match [2 ], (text ) ->
186
195
msg .reply text
187
-
196
+
188
197
robot .respond / ([^ \w \- ] | ^ )(\w + -[0-9 ] + )(?=[^ \w ] | $ )/ ig , (msg ) ->
189
198
if msg .message .user .id is robot .name
190
199
return
191
200
192
201
if (ignoredusers .some (user) -> user == msg .message .user .name )
193
202
console .log ' ignoring user due to blacklist:' , msg .message .user .name
194
203
return
195
-
204
+
196
205
for matched in msg .match
197
206
ticket = (matched .match / (\w + -[0-9 ] + )/ )[0 ]
198
207
if ! recentissues .contains msg .message .user .room + ticket
@@ -216,7 +225,7 @@ module.exports = (robot) ->
216
225
robot .respond / (use )? filter (. * )/ i , (msg ) ->
217
226
name = msg .match [2 ]
218
227
filter = filters .get name
219
-
228
+
220
229
if not filter
221
230
msg .reply " Sorry, could not find filter #{ name} "
222
231
return
0 commit comments