summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2015-08-11 14:36:45 -0400
committerhmhealey <harrisonmhealey@gmail.com>2015-08-11 16:53:15 -0400
commit3f5993eedfd52a0497f7a537601b2d7c9e4d744d (patch)
tree0602f9646cb0f895a1369baf126d968a1c779cb6
parent4c7cdb20f074e2c06a08cd64a57060b8e8b64d2e (diff)
downloadchat-3f5993eedfd52a0497f7a537601b2d7c9e4d744d.tar.gz
chat-3f5993eedfd52a0497f7a537601b2d7c9e4d744d.tar.bz2
chat-3f5993eedfd52a0497f7a537601b2d7c9e4d744d.zip
Added initial api to allow clientside code to query serverside configuration
-rw-r--r--api/api.go1
-rw-r--r--api/config.go23
-rw-r--r--web/react/utils/client.jsx21
3 files changed, 45 insertions, 0 deletions
diff --git a/api/api.go b/api/api.go
index 2ea27ed9f..9770930f7 100644
--- a/api/api.go
+++ b/api/api.go
@@ -40,6 +40,7 @@ func InitApi() {
InitWebSocket(r)
InitFile(r)
InitCommand(r)
+ InitConfig(r)
templatesDir := utils.FindDir("api/templates")
l4g.Debug("Parsing server templates at %v", templatesDir)
diff --git a/api/config.go b/api/config.go
new file mode 100644
index 000000000..91097b4a1
--- /dev/null
+++ b/api/config.go
@@ -0,0 +1,23 @@
+// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package api
+
+import (
+ l4g "code.google.com/p/log4go"
+ "github.com/gorilla/mux"
+ "github.com/mattermost/platform/utils"
+ "net/http"
+ "strconv"
+)
+
+func InitConfig(r *mux.Router) {
+ l4g.Debug("Initializing config api routes")
+
+ sr := r.PathPrefix("/config").Subrouter()
+ sr.Handle("/get/bypass_email", ApiAppHandler(getBypassEmail)).Methods("GET")
+}
+
+func getBypassEmail(c *Context, w http.ResponseWriter, r *http.Request) {
+ w.Write([]byte(strconv.FormatBool(utils.Cfg.EmailSettings.ByPassEmail)))
+}
diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx
index 6a1f7c820..5b5d8dc32 100644
--- a/web/react/utils/client.jsx
+++ b/web/react/utils/client.jsx
@@ -849,3 +849,24 @@ module.exports.updateValetFeature = function(data, success, error) {
module.exports.track('api', 'api_teams_update_valet_feature');
};
+
+module.exports.isEmailEnabledSynchronous = function() {
+ var enabled = false;
+
+ $.ajax({
+ async: false,
+ url: '/api/v1/config/get/bypass_email',
+ dataType: 'json',
+ type: 'GET',
+ success: function(value) {
+ enabled = !value;
+ },
+ error: function(xhr, status, err) {
+ if (status != 200) {
+ handleError("isEmailEnabled", xhr, status, err);
+ }
+ }
+ });
+
+ return enabled;
+};