@@ -69,11 +69,11 @@ class IssueFilter
6969class RecentIssues
7070 constructor : (@maxage ) ->
7171 @issues = []
72-
72+
7373 cleanup : ->
7474 for issue,time of @issues
7575 age = Math .round (((new Date ()).getTime () - time) / 1000 )
76- if age > @maxage
76+ if age > @maxage
7777 # console.log 'removing old issue', issue
7878 delete @issues [issue]
7979 0
@@ -83,7 +83,7 @@ class RecentIssues
8383 @issues [issue]?
8484
8585 add : (issue ,time ) ->
86- time = time || (new Date ()).getTime ()
86+ time = time || (new Date ()).getTime ()
8787 @issues [issue] = time
8888
8989
@@ -107,8 +107,17 @@ module.exports = (robot) ->
107107 if (process .env .HUBOT_JIRA_USER )
108108 authdata = new Buffer (process .env .HUBOT_JIRA_USER + ' :' + process .env .HUBOT_JIRA_PASSWORD ).toString (' base64' )
109109 httprequest = httprequest .header (' Authorization' , ' Basic ' + authdata)
110+
110111 httprequest .get () (err , res , body ) ->
112+ if err
113+ res .send " GET failed :( #{ err} "
114+ return
115+
116+ if res .statusCode is 200
111117 cb JSON .parse (body)
118+ else
119+ console .log (" res.statusCode = " + res .statusCode )
120+ console .log (" body = " + body)
112121
113122 watchers = (msg , issue , cb ) ->
114123 get msg, " issue/#{ issue} /watchers" , (watchers ) ->
@@ -156,12 +165,12 @@ module.exports = (robot) ->
156165 url : process .env .HUBOT_JIRA_URL + ' /browse/' + issues .key
157166
158167 cb " [#{ issue .key } ] #{ issue .summary } . #{ issue .assignee ()} / #{ issue .status } , #{ issue .fixVersion ()} #{ issue .url } "
159-
168+
160169 search = (msg , jql , cb ) ->
161170 get msg, " search/?jql=#{ escape (jql)} " , (result ) ->
162171 if result .errors ?
163172 return
164-
173+
165174 resultText = " I found #{ result .total } issues for your search. #{ process .env .HUBOT_JIRA_URL } /secure/IssueNavigator.jspa?reset=true&jqlQuery=#{ escape (jql)} "
166175 if result .issues .length <= maxlist
167176 cb resultText
@@ -177,22 +186,22 @@ module.exports = (robot) ->
177186
178187 watchers msg, msg .match [3 ], (text ) ->
179188 msg .send text
180-
189+
181190 robot .respond / search (for )? (. * )/ i , (msg ) ->
182191 if msg .message .user .id is robot .name
183192 return
184-
193+
185194 search msg, msg .match [2 ], (text ) ->
186195 msg .reply text
187-
196+
188197 robot .respond / ([^ \w \- ] | ^ )(\w + -[0-9 ] + )(?=[^ \w ] | $ )/ ig , (msg ) ->
189198 if msg .message .user .id is robot .name
190199 return
191200
192201 if (ignoredusers .some (user) -> user == msg .message .user .name )
193202 console .log ' ignoring user due to blacklist:' , msg .message .user .name
194203 return
195-
204+
196205 for matched in msg .match
197206 ticket = (matched .match / (\w + -[0-9 ] + )/ )[0 ]
198207 if ! recentissues .contains msg .message .user .room + ticket
@@ -216,7 +225,7 @@ module.exports = (robot) ->
216225 robot .respond / (use )? filter (. * )/ i , (msg ) ->
217226 name = msg .match [2 ]
218227 filter = filters .get name
219-
228+
220229 if not filter
221230 msg .reply " Sorry, could not find filter #{ name} "
222231 return
0 commit comments