summaryrefslogtreecommitdiffstats
path: root/web/react/utils/client.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'web/react/utils/client.jsx')
-rw-r--r--web/react/utils/client.jsx32
1 files changed, 29 insertions, 3 deletions
diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx
index 5aab80d01..da0b74081 100644
--- a/web/react/utils/client.jsx
+++ b/web/react/utils/client.jsx
@@ -279,24 +279,33 @@ module.exports.getAudits = function(userId, success, error) {
});
};
-module.exports.getMe = function(success, error) {
+module.exports.getMeSynchronous = function(success, error) {
+ var currentUser = null;
$.ajax({
+ async: false,
url: "/api/v1/users/me",
dataType: 'json',
contentType: 'application/json',
type: 'GET',
- success: success,
+ success: function gotUser(data, textStatus, xhr) {
+ currentUser = data;
+ if (success) {
+ success(data, textStatus, xhr);
+ }
+ },
error: function(xhr, status, err) {
var ieChecker = window.navigator.userAgent; // This and the condition below is used to check specifically for browsers IE10 & 11 to suppress a 200 'OK' error from appearing on login
if (xhr.status != 200 || !(ieChecker.indexOf("Trident/7.0") > 0 || ieChecker.indexOf("Trident/6.0") > 0)) {
if (error) {
- e = handleError("getMe", xhr, status, err);
+ e = handleError('getMeSynchronous', xhr, status, err);
error(e);
};
};
}
});
+
+ return currentUser;
};
module.exports.inviteMembers = function(data, success, error) {
@@ -429,6 +438,23 @@ module.exports.createChannel = function(channel, success, error) {
module.exports.track('api', 'api_channels_create', channel.type, 'name', channel.name);
};
+module.exports.createDirectChannel = function(channel, userId, success, error) {
+ $.ajax({
+ url: '/api/v1/channels/create_direct',
+ dataType: 'json',
+ contentType: 'application/json',
+ type: 'POST',
+ data: JSON.stringify({user_id: userId}),
+ success: success,
+ error: function(xhr, status, err) {
+ var e = handleError('createDirectChannel', xhr, status, err);
+ error(e);
+ }
+ });
+
+ module.exports.track('api', 'api_channels_create_direct', channel.type, 'name', channel.name);
+};
+
module.exports.updateChannel = function(channel, success, error) {
$.ajax({
url: "/api/v1/channels/update",