summaryrefslogtreecommitdiff
path: root/src/admin.clj
diff options
context:
space:
mode:
Diffstat (limited to 'src/admin.clj')
-rw-r--r--src/admin.clj43
1 files changed, 29 insertions, 14 deletions
diff --git a/src/admin.clj b/src/admin.clj
index ef33aa2..f0b6453 100644
--- a/src/admin.clj
+++ b/src/admin.clj
@@ -173,21 +173,36 @@ AND cancelled = false
(.setAttribute st "mailtemps" (lookup-templates "template/mail" "welcome"))
(.toString st))))
+(defn debug-reg-email [session params]
+ (send-registration-email (params :nick)
+ (params :to)
+ (params :template))
+ (str "Sent registration mail to " (params :to)))
+
+(defn debug-reset-email [session params]
+ )
+
+(def *debug-action-map* {"regemail" debug-reg-email
+ "resetemail" debug-reset-email})
+
+(defn format-unknown-action [action]
+ (html [:h2 {"color" "red"} ["Unknown action " action]]))
+
+(defn format-debug-exception [action e]
+ (html
+ [:h2 {"color" "red"}
+ ["Caught exception in " action " -- " (.getMessage e)]]
+ :br
+ [:pre (exception-to-string e)]))
+
(defn debug-commmand! [session params]
(if-vip
- (let [action (:action params)
- msg (try
- (cond (= action "regemail")
- (do (send-registration-email (params :nick)
- (params :to)
- (params :template))
- (str "Sent registration mail to " (params :to)))
- :else (str "Unknown action: " action))
- (catch Exception e
- (str "<h2 color=\"red\">Caught Exception in " action " --"
- (.getMessage e)
- "</h2><br><pre>"
- (exception-to-string e)
- "</pre>")))]
+ (let [action (s/lower-case (:action params))
+ func (*debug-action-map* action)
+ msg (if func
+ (try (func session params)
+ (catch Exception e
+ (format-debug-exception action e)))
+ (format-unknown-action action))]
[(flash-assoc :msg msg)
(redirect-to "/debug")])))