summaryrefslogtreecommitdiffstats
path: root/webapp/actions
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/actions')
-rw-r--r--webapp/actions/admin_actions.jsx404
-rw-r--r--webapp/actions/channel_actions.jsx172
-rw-r--r--webapp/actions/file_actions.jsx26
-rw-r--r--webapp/actions/global_actions.jsx26
-rw-r--r--webapp/actions/post_actions.jsx89
-rw-r--r--webapp/actions/team_actions.jsx53
-rw-r--r--webapp/actions/user_actions.jsx326
-rw-r--r--webapp/actions/webrtc_actions.jsx16
8 files changed, 1102 insertions, 10 deletions
diff --git a/webapp/actions/admin_actions.jsx b/webapp/actions/admin_actions.jsx
new file mode 100644
index 000000000..73b73c130
--- /dev/null
+++ b/webapp/actions/admin_actions.jsx
@@ -0,0 +1,404 @@
+// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+import Client from 'client/web_client.jsx';
+import * as AsyncClient from 'utils/async_client.jsx';
+import {browserHistory} from 'react-router/es6';
+
+export function revokeSession(altId, success, error) {
+ Client.revokeSession(altId,
+ () => {
+ AsyncClient.getSessions();
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function saveConfig(config, success, error) {
+ Client.saveConfig(
+ config,
+ () => {
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function reloadConfig(success, error) {
+ Client.reloadConfig(
+ () => {
+ AsyncClient.getConfig();
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function adminResetMfa(userId, success, error) {
+ Client.adminResetMfa(
+ userId,
+ () => {
+ AsyncClient.getUser(userId);
+
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function getClusterStatus(success, error) {
+ Client.getClusterStatus(
+ (data) => {
+ if (success) {
+ success(data);
+ }
+ },
+ (err) => {
+ AsyncClient.dispatchError(err, 'getClusterStatus');
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function saveComplianceReports(job, success, error) {
+ Client.saveComplianceReports(
+ job,
+ () => {
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function testEmail(config, success, error) {
+ Client.testEmail(
+ config,
+ () => {
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function ldapTest(success, error) {
+ Client.ldapTest(
+ () => {
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function invalidateAllCaches(success, error) {
+ Client.invalidateAllCaches(
+ () => {
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function recycleDatabaseConnection(success, error) {
+ Client.recycleDatabaseConnection(
+ () => {
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function adminResetPassword(userId, password, success, error) {
+ Client.adminResetPassword(
+ userId,
+ password,
+ () => {
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function samlCertificateStatus(success, error) {
+ Client.samlCertificateStatus(
+ (data) => {
+ if (success) {
+ success(data);
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function ldapSyncNow(success, error) {
+ Client.ldapSyncNow(
+ () => {
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function getOAuthAppInfo(clientId, success, error) {
+ Client.getOAuthAppInfo(
+ clientId,
+ (data) => {
+ if (success) {
+ success(data);
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function allowOAuth2(params, success, error) {
+ const responseType = params.response_type;
+ const clientId = params.client_id;
+ const redirectUri = params.redirect_uri;
+ const state = params.state;
+ const scope = params.scope;
+
+ Client.allowOAuth2(responseType, clientId, redirectUri, state, scope,
+ (data) => {
+ if (success) {
+ success(data);
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function emailToLdap(loginId, password, token, ldapId, ldapPassword, success, error) {
+ Client.emailToLdap(
+ loginId,
+ password,
+ token,
+ ldapId,
+ ldapPassword,
+ (data) => {
+ if (success) {
+ success(data);
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function emailToOAuth(loginId, password, token, newType, success, error) {
+ Client.emailToOAuth(
+ loginId,
+ password,
+ token,
+ newType,
+ (data) => {
+ if (success) {
+ success(data);
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function oauthToEmail(email, password, success, error) {
+ Client.oauthToEmail(
+ email,
+ password,
+ (data) => {
+ if (data.follow_link) {
+ browserHistory.push(data.follow_link);
+ }
+
+ if (success) {
+ success(data);
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function regenerateOAuthAppSecret(oauthAppId, success, error) {
+ Client.regenerateOAuthAppSecret(
+ oauthAppId,
+ (data) => {
+ if (success) {
+ success(data);
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function uploadBrandImage(brandImage, success, error) {
+ Client.uploadBrandImage(
+ brandImage,
+ () => {
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function uploadLicenseFile(file, success, error) {
+ Client.uploadLicenseFile(
+ file,
+ () => {
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function removeLicenseFile(success, error) {
+ Client.removeLicenseFile(
+ () => {
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function uploadCertificateFile(certificateFile, success, error) {
+ Client.uploadCertificateFile(
+ certificateFile,
+ () => {
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function removeCertificateFile(certificateId, success, error) {
+ Client.removeCertificateFile(
+ certificateId,
+ () => {
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
diff --git a/webapp/actions/channel_actions.jsx b/webapp/actions/channel_actions.jsx
index 204e6f9f1..4b4e3e10c 100644
--- a/webapp/actions/channel_actions.jsx
+++ b/webapp/actions/channel_actions.jsx
@@ -6,6 +6,7 @@ import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import TeamStore from 'stores/team_store.jsx';
import UserStore from 'stores/user_store.jsx';
import ChannelStore from 'stores/channel_store.jsx';
+import * as ChannelUtils from 'utils/channel_utils.jsx';
import PreferenceStore from 'stores/preference_store.jsx';
import {loadProfilesAndTeamMembersForDMSidebar} from 'actions/user_actions.jsx';
@@ -48,7 +49,14 @@ export function executeCommand(message, args, success, error) {
msg = '/shortcuts';
}
}
- Client.executeCommand(msg, args, success, error);
+ Client.executeCommand(msg, args, success,
+ (err) => {
+ AsyncClient.dispatchError(err, 'executeCommand');
+
+ if (error) {
+ error(err);
+ }
+ });
}
export function setChannelAsRead(channelIdParam) {
@@ -101,6 +109,9 @@ export function removeUserFromChannel(channelId, userId, success, error) {
}
UserStore.emitInChannelChange();
+ ChannelStore.removeMemberInChannel(channelId, userId);
+ ChannelStore.emitChange();
+
if (success) {
success(data);
}
@@ -115,6 +126,48 @@ export function removeUserFromChannel(channelId, userId, success, error) {
);
}
+export function makeUserChannelAdmin(channelId, userId, success, error) {
+ Client.updateChannelMemberRoles(
+ channelId,
+ userId,
+ 'channel_user channel_admin',
+ () => {
+ AsyncClient.getChannelMember(channelId, userId);
+ getChannelMembersForUserIds(channelId, [userId]);
+
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function makeUserChannelMember(channelId, userId, success, error) {
+ Client.updateChannelMemberRoles(
+ channelId,
+ userId,
+ 'channel_user',
+ () => {
+ AsyncClient.getChannelMember(channelId, userId);
+ getChannelMembersForUserIds(channelId, [userId]);
+
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
export function openDirectChannelToUser(user, success, error) {
const channelName = Utils.getDirectChannelName(UserStore.getCurrentId(), user.id);
const channel = ChannelStore.getByName(channelName);
@@ -311,3 +364,120 @@ export function createChannel(channel, success, error) {
}
);
}
+
+export function updateChannelPurpose(channelId, purposeValue, success, error) {
+ Client.updateChannelPurpose(
+ channelId,
+ purposeValue,
+ () => {
+ AsyncClient.getChannel(channelId);
+
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function updateChannelHeader(channelId, header, success, error) {
+ Client.updateChannelHeader(
+ channelId,
+ header,
+ (channelData) => {
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_CHANNEL,
+ channel: channelData
+ });
+
+ if (success) {
+ success(channelData);
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function getChannelMembersForUserIds(channelId, userIds, success, error) {
+ Client.getChannelMembersByIds(
+ channelId,
+ userIds,
+ (data) => {
+ const memberMap = {};
+ for (let i = 0; i < data.length; i++) {
+ memberMap[data[i].user_id] = data[i];
+ }
+
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_MEMBERS_IN_CHANNEL,
+ channel_id: channelId,
+ channel_members: memberMap
+ });
+
+ if (success) {
+ success(data);
+ }
+ },
+ (err) => {
+ AsyncClient.dispatchError(err, 'getChannelMembersByIds');
+
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function leaveChannel(channelId, success, error) {
+ Client.leaveChannel(channelId,
+ () => {
+ loadChannelsForCurrentUser();
+
+ if (ChannelUtils.isFavoriteChannelId(channelId)) {
+ unmarkFavorite(channelId);
+ }
+
+ const townsquare = ChannelStore.getByName('town-square');
+ browserHistory.push(TeamStore.getCurrentTeamRelativeUrl() + '/channels/' + townsquare.name);
+
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ AsyncClient.dispatchError(err, 'handleLeave');
+
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function deleteChannel(channelId, success, error) {
+ Client.deleteChannel(
+ channelId,
+ () => {
+ loadChannelsForCurrentUser();
+
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ AsyncClient.dispatchError(err, 'handleDelete');
+
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
diff --git a/webapp/actions/file_actions.jsx b/webapp/actions/file_actions.jsx
new file mode 100644
index 000000000..0399a2c28
--- /dev/null
+++ b/webapp/actions/file_actions.jsx
@@ -0,0 +1,26 @@
+// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+import * as AsyncClient from 'utils/async_client.jsx';
+import Client from 'client/web_client.jsx';
+
+export function uploadFile(file, name, channelId, clientId, success, error) {
+ Client.uploadFile(
+ file,
+ name,
+ channelId,
+ clientId,
+ (data) => {
+ if (success) {
+ success(data);
+ }
+ },
+ (err) => {
+ AsyncClient.dispatchError(err, 'uploadFile');
+
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
diff --git a/webapp/actions/global_actions.jsx b/webapp/actions/global_actions.jsx
index ea077d6eb..23e19f22f 100644
--- a/webapp/actions/global_actions.jsx
+++ b/webapp/actions/global_actions.jsx
@@ -256,7 +256,7 @@ export function emitLoadMorePostsFocusedTopEvent() {
}
export function loadMorePostsTop(id, isFocusPost) {
- const earliestPostId = PostStore.getEarliestPost(id).id;
+ const earliestPostId = PostStore.getEarliestPostFromPage(id).id;
if (PostStore.requestVisibilityIncrease(id, Constants.POST_CHUNK_SIZE)) {
loadPostsBefore(earliestPostId, 0, Constants.POST_CHUNK_SIZE, isFocusPost);
}
@@ -596,3 +596,27 @@ export function redirectUserToDefaultTeam() {
browserHistory.push('/select_team');
}
}
+
+requestOpenGraphMetadata.openGraphMetadataOnGoingRequests = {}; // Format: {<url>: true}
+export function requestOpenGraphMetadata(url) {
+ const onself = requestOpenGraphMetadata;
+
+ if (!onself.openGraphMetadataOnGoingRequests[url]) {
+ onself.openGraphMetadataOnGoingRequests[url] = true;
+
+ Client.getOpenGraphMetadata(url,
+ (data) => {
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECIVED_OPEN_GRAPH_METADATA,
+ url,
+ data
+ });
+ delete onself.openGraphMetadataOnGoingRequests[url];
+ },
+ (err) => {
+ AsyncClient.dispatchError(err, 'getOpenGraphMetadata');
+ delete onself.openGraphMetadataOnGoingRequests[url];
+ }
+ );
+ }
+}
diff --git a/webapp/actions/post_actions.jsx b/webapp/actions/post_actions.jsx
index 0e48fb0e8..61f193b66 100644
--- a/webapp/actions/post_actions.jsx
+++ b/webapp/actions/post_actions.jsx
@@ -115,12 +115,16 @@ export function getFlaggedPosts() {
);
}
-export function loadPosts(channelId = ChannelStore.getCurrentId()) {
+export function loadPosts(channelId = ChannelStore.getCurrentId(), isPost = false) {
const postList = PostStore.getAllPosts(channelId);
const latestPostTime = PostStore.getLatestPostFromPageTime(channelId);
- if (!postList || Object.keys(postList).length === 0 || postList.order.length < Constants.POST_CHUNK_SIZE || latestPostTime === 0) {
- loadPostsPage(channelId, Constants.POST_CHUNK_SIZE);
+ if (
+ !postList || Object.keys(postList).length === 0 ||
+ (!isPost && postList.order.length < Constants.POST_CHUNK_SIZE) ||
+ latestPostTime === 0
+ ) {
+ loadPostsPage(channelId, Constants.POST_CHUNK_SIZE, isPost);
return;
}
@@ -133,7 +137,8 @@ export function loadPosts(channelId = ChannelStore.getCurrentId()) {
id: channelId,
before: true,
numRequested: 0,
- post_list: data
+ post_list: data,
+ isPost
});
loadProfilesForPosts(data.posts);
@@ -145,7 +150,7 @@ export function loadPosts(channelId = ChannelStore.getCurrentId()) {
);
}
-export function loadPostsPage(channelId = ChannelStore.getCurrentId(), max = Constants.POST_CHUNK_SIZE) {
+export function loadPostsPage(channelId = ChannelStore.getCurrentId(), max = Constants.POST_CHUNK_SIZE, isPost = false) {
const postList = PostStore.getAllPosts(channelId);
// if we already have more than POST_CHUNK_SIZE posts,
@@ -167,7 +172,9 @@ export function loadPostsPage(channelId = ChannelStore.getCurrentId(), max = Con
before: true,
numRequested: numPosts,
checkLatest: true,
- post_list: data
+ checkEarliest: true,
+ post_list: data,
+ isPost
});
loadProfilesForPosts(data.posts);
@@ -195,6 +202,7 @@ export function loadPostsBefore(postId, offset, numPost, isPost) {
type: ActionTypes.RECEIVED_POSTS,
id: channelId,
before: true,
+ checkEarliest: true,
numRequested: numPost,
post_list: data,
isPost
@@ -363,7 +371,76 @@ export function createPost(post, doLoadPost, success, error) {
);
}
+export function updatePost(post, success, isPost) {
+ Client.updatePost(
+ post,
+ () => {
+ loadPosts(post.channel_id, isPost);
+
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ AsyncClient.dispatchError(err, 'updatePost');
+ });
+}
+
export function removePostFromStore(post) {
PostStore.removePost(post);
PostStore.emitChange();
}
+
+export function deletePost(channelId, post, success, error) {
+ Client.deletePost(
+ channelId,
+ post.id,
+ () => {
+ removePostFromStore(post);
+ if (post.id === PostStore.getSelectedPostId()) {
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_POST_SELECTED,
+ postId: null
+ });
+ }
+
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ AsyncClient.dispatchError(err, 'deletePost');
+
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function performSearch(terms, isMentionSearch, success, error) {
+ Client.search(
+ terms,
+ isMentionSearch,
+ (data) => {
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_SEARCH,
+ results: data,
+ is_mention_search: isMentionSearch
+ });
+
+ loadProfilesForPosts(data.posts);
+
+ if (success) {
+ success(data);
+ }
+ },
+ (err) => {
+ AsyncClient.dispatchError(err, 'search');
+
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
diff --git a/webapp/actions/team_actions.jsx b/webapp/actions/team_actions.jsx
index 3a86bada9..e23fe1e5d 100644
--- a/webapp/actions/team_actions.jsx
+++ b/webapp/actions/team_actions.jsx
@@ -60,7 +60,10 @@ export function removeUserFromTeam(teamId, userId, success, error) {
userId,
() => {
TeamStore.removeMemberInTeam(teamId, userId);
+ UserStore.removeProfileFromTeam(teamId, userId);
+ UserStore.emitInTeamChange();
AsyncClient.getUser(userId);
+ AsyncClient.getTeamStats(teamId);
if (success) {
success();
@@ -92,3 +95,53 @@ export function updateTeamMemberRoles(teamId, userId, newRoles, success, error)
}
);
}
+
+export function addUserToTeamFromInvite(data, hash, inviteId, success, error) {
+ Client.addUserToTeamFromInvite(
+ data,
+ hash,
+ inviteId,
+ (team) => {
+ if (success) {
+ success(team);
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function getInviteInfo(inviteId, success, error) {
+ Client.getInviteInfo(
+ inviteId,
+ (inviteData) => {
+ if (success) {
+ success(inviteData);
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function inviteMembers(data, success, error) {
+ Client.inviteMembers(
+ data,
+ () => {
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (err) {
+ error(err);
+ }
+ }
+ );
+}
diff --git a/webapp/actions/user_actions.jsx b/webapp/actions/user_actions.jsx
index 0f5fb0731..73a84a7c6 100644
--- a/webapp/actions/user_actions.jsx
+++ b/webapp/actions/user_actions.jsx
@@ -4,17 +4,22 @@
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import PreferenceStore from 'stores/preference_store.jsx';
+import BrowserStore from 'stores/browser_store.jsx';
import TeamStore from 'stores/team_store.jsx';
import UserStore from 'stores/user_store.jsx';
import ChannelStore from 'stores/channel_store.jsx';
+import * as GlobalActions from 'actions/global_actions.jsx';
+import {getChannelMembersForUserIds} from 'actions/channel_actions.jsx';
import {loadStatusesForProfilesList, loadStatusesForProfilesMap} from 'actions/status_actions.jsx';
import {getDirectChannelName} from 'utils/utils.jsx';
+
import * as AsyncClient from 'utils/async_client.jsx';
import Client from 'client/web_client.jsx';
import {ActionTypes, Preferences} from 'utils/constants.jsx';
+import {browserHistory} from 'react-router/es6';
export function switchFromLdapToEmail(email, password, token, ldapPassword, onSuccess, onError) {
Client.ldapToEmail(
@@ -58,6 +63,34 @@ export function loadProfilesAndTeamMembers(offset, limit, teamId = TeamStore.get
);
}
+export function loadProfilesAndTeamMembersAndChannelMembers(offset, limit, teamId = TeamStore.getCurrentId(), channelId = ChannelStore.getCurrentId(), success, error) {
+ Client.getProfilesInChannel(
+ channelId,
+ offset,
+ limit,
+ (data) => {
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_PROFILES_IN_CHANNEL,
+ profiles: data,
+ channel_id: channelId,
+ offset,
+ count: Object.keys(data).length
+ });
+
+ loadTeamMembersForProfilesMap(
+ data,
+ teamId,
+ () => {
+ loadChannelMembersForProfilesMap(data, channelId, success, error);
+ loadStatusesForProfilesMap(data);
+ });
+ },
+ (err) => {
+ AsyncClient.dispatchError(err, 'getProfilesInChannel');
+ }
+ );
+}
+
export function loadTeamMembersForProfilesMap(profiles, teamId = TeamStore.getCurrentId(), success, error) {
const membersToLoad = {};
for (const pid in profiles) {
@@ -132,6 +165,56 @@ function loadTeamMembersForProfiles(userIds, teamId, success, error) {
);
}
+export function loadChannelMembersForProfilesMap(profiles, channelId = ChannelStore.getCurrentId(), success, error) {
+ const membersToLoad = {};
+ for (const pid in profiles) {
+ if (!profiles.hasOwnProperty(pid)) {
+ continue;
+ }
+
+ if (!ChannelStore.hasActiveMemberInChannel(channelId, pid)) {
+ membersToLoad[pid] = true;
+ }
+ }
+
+ const list = Object.keys(membersToLoad);
+ if (list.length === 0) {
+ if (success) {
+ success({});
+ }
+ return;
+ }
+
+ getChannelMembersForUserIds(channelId, list, success, error);
+}
+
+export function loadTeamMembersAndChannelMembersForProfilesList(profiles, teamId = TeamStore.getCurrentId(), channelId = ChannelStore.getCurrentId(), success, error) {
+ loadTeamMembersForProfilesList(profiles, teamId, () => {
+ loadChannelMembersForProfilesList(profiles, channelId, success, error);
+ }, error);
+}
+
+export function loadChannelMembersForProfilesList(profiles, channelId = ChannelStore.getCurrentId(), success, error) {
+ const membersToLoad = {};
+ for (let i = 0; i < profiles.length; i++) {
+ const pid = profiles[i].id;
+
+ if (!ChannelStore.hasActiveMemberInChannel(channelId, pid)) {
+ membersToLoad[pid] = true;
+ }
+ }
+
+ const list = Object.keys(membersToLoad);
+ if (list.length === 0) {
+ if (success) {
+ success({});
+ }
+ return;
+ }
+
+ getChannelMembersForUserIds(channelId, list, success, error);
+}
+
function populateDMChannelsWithProfiles(userIds) {
const currentUserId = UserStore.getCurrentId();
@@ -348,10 +431,10 @@ export function updateUser(username, type, success, error) {
}
},
(err) => {
- AsyncClient.dispatchError(err, 'updateUser');
-
if (error) {
error(err);
+ } else {
+ AsyncClient.dispatchError(err, 'updateUser');
}
}
);
@@ -374,6 +457,24 @@ export function generateMfaSecret(success, error) {
);
}
+export function updateUserNotifyProps(data, success, error) {
+ Client.updateUserNotifyProps(
+ data,
+ () => {
+ AsyncClient.getMe();
+
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
export function updateUserRoles(userId, newRoles, success, error) {
Client.updateUserRoles(
userId,
@@ -412,6 +513,25 @@ export function activateMfa(code, success, error) {
);
}
+export function deactivateMfa(success, error) {
+ Client.updateMfa(
+ '',
+ false,
+ () => {
+ AsyncClient.getMe();
+
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
export function checkMfa(loginId, success, error) {
if (global.window.mm_config.EnableMultifactorAuthentication !== 'true') {
success(false);
@@ -449,3 +569,205 @@ export function updateActive(userId, active, success, error) {
}
);
}
+
+export function updatePassword(userId, currentPassword, newPassword, success, error) {
+ Client.updatePassword(userId, currentPassword, newPassword,
+ () => {
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function verifyEmail(uid, hid, success, error) {
+ Client.verifyEmail(
+ uid,
+ hid,
+ (data) => {
+ if (success) {
+ success(data);
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function resetPassword(code, password, success, error) {
+ Client.resetPassword(
+ code,
+ password,
+ () => {
+ browserHistory.push('/login?extra=' + ActionTypes.PASSWORD_CHANGE);
+
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function resendVerification(email, success, error) {
+ Client.resendVerification(
+ email,
+ () => {
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function loginById(userId, password, mfaToken, hash, success, error) {
+ Client.loginById(
+ userId,
+ password,
+ mfaToken,
+ hash,
+ () => {
+ if (hash > 0) {
+ BrowserStore.setGlobalItem(hash, JSON.stringify({usedBefore: true}));
+ }
+
+ GlobalActions.emitInitialLoad(
+ () => {
+ const query = this.props.location.query;
+ if (query.redirect_to) {
+ browserHistory.push(query.redirect_to);
+ } else {
+ GlobalActions.redirectUserToDefaultTeam();
+ }
+ }
+ );
+
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function createUserWithInvite(user, data, emailHash, inviteId, success, error) {
+ Client.createUserWithInvite(
+ user,
+ data,
+ emailHash,
+ inviteId,
+ (response) => {
+ if (success) {
+ success(response);
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function webLogin(loginId, password, token, success, error) {
+ Client.webLogin(
+ loginId,
+ password,
+ token,
+ () => {
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function webLoginByLdap(loginId, password, token, success, error) {
+ Client.webLoginByLdap(
+ loginId,
+ password,
+ token,
+ (data) => {
+ if (success) {
+ success(data);
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function getAuthorizedApps(success, error) {
+ Client.getAuthorizedApps(
+ (authorizedApps) => {
+ if (success) {
+ success(authorizedApps);
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ });
+}
+
+export function deauthorizeOAuthApp(appId, success, error) {
+ Client.deauthorizeOAuthApp(
+ appId,
+ () => {
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ });
+}
+
+export function uploadProfileImage(userPicture, success, error) {
+ Client.uploadProfileImage(
+ userPicture,
+ () => {
+ AsyncClient.getMe();
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
diff --git a/webapp/actions/webrtc_actions.jsx b/webapp/actions/webrtc_actions.jsx
index 444eee241..b096e1c33 100644
--- a/webapp/actions/webrtc_actions.jsx
+++ b/webapp/actions/webrtc_actions.jsx
@@ -4,6 +4,8 @@
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import {WebrtcActionTypes} from 'utils/constants.jsx';
+import Client from 'client/web_client.jsx';
+
export function initWebrtc(userId, isCalling) {
AppDispatcher.handleServerAction({
type: WebrtcActionTypes.INITIALIZE,
@@ -18,3 +20,17 @@ export function handle(message) {
message
});
}
+
+export function webrtcToken(success, error) {
+ Client.webrtcToken(
+ (data) => {
+ if (success) {
+ success(data);
+ }
+ },
+ () => {
+ if (error) {
+ error();
+ }
+ });
+}