From 77dd09bf509b8f450c04a9aa11a42b17d9777614 Mon Sep 17 00:00:00 2001 From: Trevor Hartman Date: Sat, 30 Mar 2019 08:54:37 -0600 Subject: [PATCH 1/2] Show an error in JIRA if no projects are configured on recent --- src/yetibot/commands/jira.clj | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/yetibot/commands/jira.clj b/src/yetibot/commands/jira.clj index c946a697..22583c18 100644 --- a/src/yetibot/commands/jira.clj +++ b/src/yetibot/commands/jira.clj @@ -233,11 +233,16 @@ {:yb/cat #{:issue}} [{:keys [settings]}] (binding [api/*jira-projects* (channel-projects settings)] - (report-if-error - #(api/recent) - (fn [res] - {:result/value (short-jira-list res) - :result/data (-> res :body :issues)})))) + (if api/*jira-projects* + (report-if-error + #(api/recent) + (fn [res] + {:result/value (short-jira-list res) + :result/data (-> res :body :issues)})) + {:result/error + "You don't have any JIRA projects configured for this channel. + Use `channel set jira-projects PROJECT1,PROJECT2` to configure 1 or more."} + ))) (defn search-cmd "jira search # return up to 15 issues matching across all configured projects" From b3e6bc5f97234e12e1545cbf265c3b6e9c54c470 Mon Sep 17 00:00:00 2001 From: Trevor Hartman Date: Mon, 1 Apr 2019 09:09:05 -0600 Subject: [PATCH 2/2] Add err handling in JIRA when user has not specified any projects --- src/yetibot/api/jira.clj | 3 ++- src/yetibot/commands/jira.clj | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/yetibot/api/jira.clj b/src/yetibot/api/jira.clj index c6f5ed7c..6b7d6cde 100644 --- a/src/yetibot/api/jira.clj +++ b/src/yetibot/api/jira.clj @@ -40,7 +40,8 @@ "Retrieve the list of configured projects for a channel, given its settings" [channel-settings] (when-let [setting (channel-settings jira-project-setting-key)] - (s/split setting #",\s*"))) + (info "channel-projects" (pr-str setting)) + (seq (remove s/blank? (s/split setting #",\s*"))))) (defn config [] (:value (get-config jira-schema [:jira]))) diff --git a/src/yetibot/commands/jira.clj b/src/yetibot/commands/jira.clj index 22583c18..e4ab83e5 100644 --- a/src/yetibot/commands/jira.clj +++ b/src/yetibot/commands/jira.clj @@ -233,6 +233,7 @@ {:yb/cat #{:issue}} [{:keys [settings]}] (binding [api/*jira-projects* (channel-projects settings)] + (info "recent" (pr-str api/*jira-projects*)) (if api/*jira-projects* (report-if-error #(api/recent) @@ -240,9 +241,8 @@ {:result/value (short-jira-list res) :result/data (-> res :body :issues)})) {:result/error - "You don't have any JIRA projects configured for this channel. - Use `channel set jira-projects PROJECT1,PROJECT2` to configure 1 or more."} - ))) + "You don't have any JIRA projects configured for this channel. Use `channel set jira-project PROJECT1,PROJECT2` to configure 1 or more." + }))) (defn search-cmd "jira search # return up to 15 issues matching across all configured projects"