lib/lita/handlers/jira.rb in lita-jira-0.5.0 vs lib/lita/handlers/jira.rb in lita-jira-0.6.0

- old
+ new

@@ -12,10 +12,11 @@ config :context, required: true include ::JiraHelper::Issue include ::JiraHelper::Misc include ::JiraHelper::Regex + include ::JiraHelper::Utility route( /^jira\s#{ISSUE_PATTERN}$/, :summary, command: true, @@ -32,10 +33,19 @@ t('help.details.syntax') => t('help.details.desc') } ) route( + /^jira\smyissues$/, + :myissues, + command: true, + help: { + t('help.myissues.syntax') => t('help.myissues.desc') + } + ) + + route( /^jira\scomment\son\s#{ISSUE_PATTERN}\s#{COMMENT_PATTERN}$/, :comment, command: true, help: { t('help.comment.syntax') => t('help.comment.desc') @@ -76,9 +86,27 @@ response.match_data['subject'], response.match_data['summary']) return response.reply(t('error.request')) unless issue response.reply(t('issue.created', key: issue.key)) end + + # rubocop:disable Metrics/AbcSize + def myissues(response) + return response.reply(t('error.not_identified')) unless user_stored?(response.user) + + begin + issues = fetch_issues("assignee = '#{get_email(response.user)}' AND status not in (Closed)") + rescue + log.error('JIRA HTTPError') + response.reply(t('error.request')) + return + end + + return response.reply(t('myissues.empty')) unless issues.size > 0 + + response.reply(format_issues(issues)) + end + # rubocop:enable Metrics/AbcSize end Lita.register_handler(Jira) end end