PLT-2057 User as a first class object (#2648)
* Adding TeamMember to system * Fixing all unit tests on the backend * Fixing merge conflicts * Fixing merge conflict * Adding javascript unit tests * Adding TeamMember to system * Fixing all unit tests on the backend * Fixing merge conflicts * Fixing merge conflict * Adding javascript unit tests * Adding client side unit test * Cleaning up the clint side tests * Fixing msg * Adding more client side unit tests * Adding more using tests * Adding last bit of client side unit tests and adding make cmd * Fixing bad merge * Fixing libraries * Updating to new client side API * Fixing borken unit test * Fixing unit tests * ugg...trying to beat gofmt * ugg...trying to beat gofmt * Cleaning up remainder of the server side routes * Adding inital load api * Increased coverage of webhook unit tests (#2660) * Adding loading ... to root html * Fixing bad merge * Removing explicit content type so superagent will guess corectly (#2685) * Fixing merge and unit tests * Adding create team UI * Fixing signup flows * Adding LDAP unit tests and enterprise unit test helper (#2702) * Add the ability to reset MFA from the commandline (#2706) * Fixing compliance unit tests * Fixing client side tests * Adding open server to system console * Moving websocket connection * Fixing unit test * Fixing unit tests * Fixing unit tests * Adding nickname and more LDAP unit tests (#2717) * Adding join open teams * Cleaning up all TODOs in the code * Fixing web sockets * Removing unused webockets file * PLT-2533 Add the ability to reset a user's MFA from the system console (#2715) * Add the ability to reset a user's MFA from the system console * Add client side unit test for adminResetMfa * Reorganizing authentication to fix LDAP error message (#2723) * Fixing failing unit test * Initial upgrade db code * Adding upgrade script * Fixing upgrade script after running on core * Update OAuth and Claim routes to work with user model changes (#2739) * Fixing perminant deletion. Adding ability to delete all user and the entire database (#2740) * Fixing team invite ldap login call (#2741) * Fixing bluebar and some img stuff * Fix all the different file upload web utils (#2743) * Fixing invalid session redirect (#2744) * Redirect on bad channel name (#2746) * Fixing a bunch of issue and removing dead code * Patch to fix error message on leave channel (#2747) * Setting EnableOpenServer to false by default * Fixing config * Fixing upgrade * Fixing reported bugs * Bug fixes for PLT-2057 * PLT-2563 Redo password recovery to use a database table (#2745) * Redo password recovery to use a database table * Update reset password audits * Split out admin and user reset password APIs to be separate * Delete password recovery when user is permanently deleted * Consolidate password resetting into a single function * Removed private channels as an option for outgoing webhooks (#2752) * PLT-2577/PLT-2552 Fixes for backstage (#2753) * Added URL to incoming webhook list * Fixed client functions for adding/removing integrations * Disallowed slash commands without trigger words * Fixed clientside handling of errors on AddCommand page * Minor auth cleanup (#2758) * Changed EditPostModal to just close if you save without making any changes (#2759) * Renamed client -> Client in async_client.jsx and fixed eslint warnings (#2756) * Fixed url in channel info modal (#2755) * Fixing reported issues * Moving to version 3 of the apis * Fixing command unit tests (#2760) * Adding team admins * Fixing DM issue * Fixing eslint error * Properly set EditPostModal's originalText state in all cases (#2762) * Update client config check to assume features is defined if server is licensed (#2772) * Fixing url link * Fixing issue with websocket crashing when sending messages to different teams
Этот коммит содержится в:
@@ -2,7 +2,7 @@
|
||||
// See License.txt for license information.
|
||||
|
||||
import $ from 'jquery';
|
||||
import * as client from './client.jsx';
|
||||
import Client from './web_client.jsx';
|
||||
import * as GlobalActions from 'action_creators/global_actions.jsx';
|
||||
import AppDispatcher from '../dispatcher/app_dispatcher.jsx';
|
||||
import BrowserStore from 'stores/browser_store.jsx';
|
||||
@@ -11,6 +11,7 @@ import PreferenceStore from 'stores/preference_store.jsx';
|
||||
import PostStore from 'stores/post_store.jsx';
|
||||
import UserStore from 'stores/user_store.jsx';
|
||||
import * as utils from './utils.jsx';
|
||||
import ErrorStore from 'stores/error_store.jsx';
|
||||
|
||||
import Constants from './constants.jsx';
|
||||
const ActionTypes = Constants.ActionTypes;
|
||||
@@ -19,6 +20,8 @@ const StatTypes = Constants.StatTypes;
|
||||
// Used to track in progress async calls
|
||||
const callTracker = {};
|
||||
|
||||
const ASYNC_CLIENT_TIMEOUT = 5000;
|
||||
|
||||
export function dispatchError(err, method) {
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_ERROR,
|
||||
@@ -36,7 +39,7 @@ function isCallInProgress(callName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (utils.getTimestamp() - callTracker[callName] > 5000) {
|
||||
if (utils.getTimestamp() - callTracker[callName] > ASYNC_CLIENT_TIMEOUT) {
|
||||
//console.log('AsyncClient call ' + callName + ' expired after more than 5 seconds');
|
||||
return false;
|
||||
}
|
||||
@@ -51,16 +54,12 @@ export function getChannels(checkVersion) {
|
||||
|
||||
callTracker.getChannels = utils.getTimestamp();
|
||||
|
||||
return client.getChannels(
|
||||
(data, textStatus, xhr) => {
|
||||
return Client.getChannels(
|
||||
(data) => {
|
||||
callTracker.getChannels = 0;
|
||||
|
||||
if (xhr.status === 304 || !data) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (checkVersion) {
|
||||
var serverVersion = xhr.getResponseHeader('X-Version-ID');
|
||||
var serverVersion = Client.getServerVersion();
|
||||
|
||||
if (serverVersion !== BrowserStore.getLastServerVersion()) {
|
||||
if (!BrowserStore.getLastServerVersion() || BrowserStore.getLastServerVersion() === '') {
|
||||
@@ -93,14 +92,10 @@ export function getChannel(id) {
|
||||
|
||||
callTracker['getChannel' + id] = utils.getTimestamp();
|
||||
|
||||
client.getChannel(id,
|
||||
(data, textStatus, xhr) => {
|
||||
Client.getChannel(id,
|
||||
(data) => {
|
||||
callTracker['getChannel' + id] = 0;
|
||||
|
||||
if (xhr.status === 304 || !data) {
|
||||
return;
|
||||
}
|
||||
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_CHANNEL,
|
||||
channel: data.channel,
|
||||
@@ -131,13 +126,17 @@ export function updateLastViewedAt(id) {
|
||||
}
|
||||
|
||||
callTracker[`updateLastViewed${channelId}`] = utils.getTimestamp();
|
||||
client.updateLastViewedAt(
|
||||
Client.updateLastViewedAt(
|
||||
channelId,
|
||||
() => {
|
||||
callTracker.updateLastViewed = 0;
|
||||
ErrorStore.clearLastError();
|
||||
ErrorStore.emitChange();
|
||||
},
|
||||
(err) => {
|
||||
callTracker.updateLastViewed = 0;
|
||||
var count = ErrorStore.getConnectionErrorCount();
|
||||
ErrorStore.setConnectionErrorCount(count + 1);
|
||||
dispatchError(err, 'updateLastViewedAt');
|
||||
}
|
||||
);
|
||||
@@ -150,21 +149,17 @@ export function getMoreChannels(force) {
|
||||
|
||||
if (ChannelStore.getMoreAll().loading || force) {
|
||||
callTracker.getMoreChannels = utils.getTimestamp();
|
||||
client.getMoreChannels(
|
||||
function getMoreChannelsSuccess(data, textStatus, xhr) {
|
||||
Client.getMoreChannels(
|
||||
(data) => {
|
||||
callTracker.getMoreChannels = 0;
|
||||
|
||||
if (xhr.status === 304 || !data) {
|
||||
return;
|
||||
}
|
||||
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_MORE_CHANNELS,
|
||||
channels: data.channels,
|
||||
members: data.members
|
||||
});
|
||||
},
|
||||
function getMoreChannelsFailure(err) {
|
||||
(err) => {
|
||||
callTracker.getMoreChannels = 0;
|
||||
dispatchError(err, 'getMoreChannels');
|
||||
}
|
||||
@@ -187,16 +182,12 @@ export function getChannelExtraInfo(id, memberLimit) {
|
||||
|
||||
callTracker['getChannelExtraInfo_' + channelId] = utils.getTimestamp();
|
||||
|
||||
client.getChannelExtraInfo(
|
||||
Client.getChannelExtraInfo(
|
||||
channelId,
|
||||
memberLimit,
|
||||
(data, textStatus, xhr) => {
|
||||
(data) => {
|
||||
callTracker['getChannelExtraInfo_' + channelId] = 0;
|
||||
|
||||
if (xhr.status === 304 || !data) {
|
||||
return;
|
||||
}
|
||||
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_CHANNEL_EXTRA_INFO,
|
||||
extra_info: data
|
||||
@@ -210,53 +201,90 @@ export function getChannelExtraInfo(id, memberLimit) {
|
||||
}
|
||||
}
|
||||
|
||||
export function getTeamMembers(teamId) {
|
||||
if (isCallInProgress('getTeamMembers')) {
|
||||
return;
|
||||
}
|
||||
|
||||
callTracker.getTeamMembers = utils.getTimestamp();
|
||||
Client.getTeamMembers(
|
||||
teamId,
|
||||
(data) => {
|
||||
callTracker.getTeamMembers = 0;
|
||||
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_MEMBERS_FOR_TEAM,
|
||||
team_members: data
|
||||
});
|
||||
},
|
||||
(err) => {
|
||||
callTracker.getTeamMembers = 0;
|
||||
dispatchError(err, 'getTeamMembers');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export function getProfiles() {
|
||||
if (isCallInProgress('getProfiles')) {
|
||||
return;
|
||||
}
|
||||
|
||||
callTracker.getProfiles = utils.getTimestamp();
|
||||
client.getProfiles(
|
||||
function getProfilesSuccess(data, textStatus, xhr) {
|
||||
Client.getProfiles(
|
||||
(data) => {
|
||||
callTracker.getProfiles = 0;
|
||||
|
||||
if (xhr.status === 304 || !data) {
|
||||
return;
|
||||
}
|
||||
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_PROFILES,
|
||||
profiles: data
|
||||
});
|
||||
},
|
||||
function getProfilesFailure(err) {
|
||||
(err) => {
|
||||
callTracker.getProfiles = 0;
|
||||
dispatchError(err, 'getProfiles');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export function getDirectProfiles() {
|
||||
if (isCallInProgress('getDirectProfiles')) {
|
||||
return;
|
||||
}
|
||||
|
||||
callTracker.getDirectProfiles = utils.getTimestamp();
|
||||
Client.getDirectProfiles(
|
||||
(data) => {
|
||||
callTracker.getDirectProfiles = 0;
|
||||
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_DIRECT_PROFILES,
|
||||
profiles: data
|
||||
});
|
||||
},
|
||||
(err) => {
|
||||
callTracker.getDirectProfiles = 0;
|
||||
dispatchError(err, 'getDirectProfiles');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export function getSessions() {
|
||||
if (isCallInProgress('getSessions')) {
|
||||
return;
|
||||
}
|
||||
|
||||
callTracker.getSessions = utils.getTimestamp();
|
||||
client.getSessions(
|
||||
Client.getSessions(
|
||||
UserStore.getCurrentId(),
|
||||
function getSessionsSuccess(data, textStatus, xhr) {
|
||||
(data) => {
|
||||
callTracker.getSessions = 0;
|
||||
|
||||
if (xhr.status === 304 || !data) {
|
||||
return;
|
||||
}
|
||||
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_SESSIONS,
|
||||
sessions: data
|
||||
});
|
||||
},
|
||||
function getSessionsFailure(err) {
|
||||
(err) => {
|
||||
callTracker.getSessions = 0;
|
||||
dispatchError(err, 'getSessions');
|
||||
}
|
||||
@@ -269,21 +297,17 @@ export function getAudits() {
|
||||
}
|
||||
|
||||
callTracker.getAudits = utils.getTimestamp();
|
||||
client.getAudits(
|
||||
Client.getAudits(
|
||||
UserStore.getCurrentId(),
|
||||
function getAuditsSuccess(data, textStatus, xhr) {
|
||||
(data) => {
|
||||
callTracker.getAudits = 0;
|
||||
|
||||
if (xhr.status === 304 || !data) {
|
||||
return;
|
||||
}
|
||||
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_AUDITS,
|
||||
audits: data
|
||||
});
|
||||
},
|
||||
function getAuditsFailure(err) {
|
||||
(err) => {
|
||||
callTracker.getAudits = 0;
|
||||
dispatchError(err, 'getAudits');
|
||||
}
|
||||
@@ -296,14 +320,10 @@ export function getLogs() {
|
||||
}
|
||||
|
||||
callTracker.getLogs = utils.getTimestamp();
|
||||
client.getLogs(
|
||||
(data, textStatus, xhr) => {
|
||||
Client.getLogs(
|
||||
(data) => {
|
||||
callTracker.getLogs = 0;
|
||||
|
||||
if (xhr.status === 304 || !data) {
|
||||
return;
|
||||
}
|
||||
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_LOGS,
|
||||
logs: data
|
||||
@@ -322,14 +342,10 @@ export function getServerAudits() {
|
||||
}
|
||||
|
||||
callTracker.getServerAudits = utils.getTimestamp();
|
||||
client.getServerAudits(
|
||||
(data, textStatus, xhr) => {
|
||||
Client.getServerAudits(
|
||||
(data) => {
|
||||
callTracker.getServerAudits = 0;
|
||||
|
||||
if (xhr.status === 304 || !data) {
|
||||
return;
|
||||
}
|
||||
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_SERVER_AUDITS,
|
||||
audits: data
|
||||
@@ -348,14 +364,10 @@ export function getComplianceReports() {
|
||||
}
|
||||
|
||||
callTracker.getComplianceReports = utils.getTimestamp();
|
||||
client.getComplianceReports(
|
||||
(data, textStatus, xhr) => {
|
||||
Client.getComplianceReports(
|
||||
(data) => {
|
||||
callTracker.getComplianceReports = 0;
|
||||
|
||||
if (xhr.status === 304 || !data) {
|
||||
return;
|
||||
}
|
||||
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_SERVER_COMPLIANCE_REPORTS,
|
||||
complianceReports: data
|
||||
@@ -374,14 +386,10 @@ export function getConfig() {
|
||||
}
|
||||
|
||||
callTracker.getConfig = utils.getTimestamp();
|
||||
client.getConfig(
|
||||
(data, textStatus, xhr) => {
|
||||
Client.getConfig(
|
||||
(data) => {
|
||||
callTracker.getConfig = 0;
|
||||
|
||||
if (xhr.status === 304 || !data) {
|
||||
return;
|
||||
}
|
||||
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_CONFIG,
|
||||
config: data
|
||||
@@ -400,14 +408,10 @@ export function getAllTeams() {
|
||||
}
|
||||
|
||||
callTracker.getAllTeams = utils.getTimestamp();
|
||||
client.getAllTeams(
|
||||
(data, textStatus, xhr) => {
|
||||
Client.getAllTeams(
|
||||
(data) => {
|
||||
callTracker.getAllTeams = 0;
|
||||
|
||||
if (xhr.status === 304 || !data) {
|
||||
return;
|
||||
}
|
||||
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_ALL_TEAMS,
|
||||
teams: data
|
||||
@@ -420,27 +424,45 @@ export function getAllTeams() {
|
||||
);
|
||||
}
|
||||
|
||||
export function getAllTeamListings() {
|
||||
if (isCallInProgress('getAllTeamListings')) {
|
||||
return;
|
||||
}
|
||||
|
||||
callTracker.getAllTeamListings = utils.getTimestamp();
|
||||
Client.getAllTeamListings(
|
||||
(data) => {
|
||||
callTracker.getAllTeamListings = 0;
|
||||
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_ALL_TEAM_LISTINGS,
|
||||
teams: data
|
||||
});
|
||||
},
|
||||
(err) => {
|
||||
callTracker.getAllTeams = 0;
|
||||
dispatchError(err, 'getAllTeamListings');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export function search(terms) {
|
||||
if (isCallInProgress('search_' + String(terms))) {
|
||||
return;
|
||||
}
|
||||
|
||||
callTracker['search_' + String(terms)] = utils.getTimestamp();
|
||||
client.search(
|
||||
Client.search(
|
||||
terms,
|
||||
function searchSuccess(data, textStatus, xhr) {
|
||||
(data) => {
|
||||
callTracker['search_' + String(terms)] = 0;
|
||||
|
||||
if (xhr.status === 304 || !data) {
|
||||
return;
|
||||
}
|
||||
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_SEARCH,
|
||||
results: data
|
||||
});
|
||||
},
|
||||
function searchFailure(err) {
|
||||
(err) => {
|
||||
callTracker['search_' + String(terms)] = 0;
|
||||
dispatchError(err, 'search');
|
||||
}
|
||||
@@ -478,15 +500,11 @@ export function getPostsPage(id, maxPosts) {
|
||||
if (channelId != null) {
|
||||
callTracker['getPostsPage_' + channelId] = utils.getTimestamp();
|
||||
|
||||
client.getPostsPage(
|
||||
Client.getPostsPage(
|
||||
channelId,
|
||||
0,
|
||||
numPosts,
|
||||
(data, textStatus, xhr) => {
|
||||
if (xhr.status === 304 || !data) {
|
||||
return;
|
||||
}
|
||||
|
||||
(data) => {
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_POSTS,
|
||||
id: channelId,
|
||||
@@ -536,14 +554,10 @@ export function getPosts(id) {
|
||||
|
||||
callTracker['getPosts_' + channelId] = utils.getTimestamp();
|
||||
|
||||
client.getPosts(
|
||||
Client.getPosts(
|
||||
channelId,
|
||||
latestPostTime,
|
||||
(data, textStatus, xhr) => {
|
||||
if (xhr.status === 304 || !data) {
|
||||
return;
|
||||
}
|
||||
|
||||
(data) => {
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_POSTS,
|
||||
id: channelId,
|
||||
@@ -573,16 +587,12 @@ export function getPostsBefore(postId, offset, numPost) {
|
||||
return;
|
||||
}
|
||||
|
||||
client.getPostsBefore(
|
||||
Client.getPostsBefore(
|
||||
channelId,
|
||||
postId,
|
||||
offset,
|
||||
numPost,
|
||||
(data, textStatus, xhr) => {
|
||||
if (xhr.status === 304 || !data) {
|
||||
return;
|
||||
}
|
||||
|
||||
(data) => {
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_POSTS,
|
||||
id: channelId,
|
||||
@@ -612,16 +622,12 @@ export function getPostsAfter(postId, offset, numPost) {
|
||||
return;
|
||||
}
|
||||
|
||||
client.getPostsAfter(
|
||||
Client.getPostsAfter(
|
||||
channelId,
|
||||
postId,
|
||||
offset,
|
||||
numPost,
|
||||
(data, textStatus, xhr) => {
|
||||
if (xhr.status === 304 || !data) {
|
||||
return;
|
||||
}
|
||||
|
||||
(data) => {
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_POSTS,
|
||||
id: channelId,
|
||||
@@ -647,14 +653,10 @@ export function getMe() {
|
||||
}
|
||||
|
||||
callTracker.getMe = utils.getTimestamp();
|
||||
return client.getMe(
|
||||
(data, textStatus, xhr) => {
|
||||
return Client.getMe(
|
||||
(data) => {
|
||||
callTracker.getMe = 0;
|
||||
|
||||
if (xhr.status === 304 || !data) {
|
||||
return;
|
||||
}
|
||||
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_ME,
|
||||
me: data
|
||||
@@ -684,14 +686,10 @@ export function getStatuses() {
|
||||
}
|
||||
|
||||
callTracker.getStatuses = utils.getTimestamp();
|
||||
client.getStatuses(teammateIds,
|
||||
(data, textStatus, xhr) => {
|
||||
Client.getStatuses(teammateIds,
|
||||
(data) => {
|
||||
callTracker.getStatuses = 0;
|
||||
|
||||
if (xhr.status === 304 || !data) {
|
||||
return;
|
||||
}
|
||||
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_STATUSES,
|
||||
statuses: data
|
||||
@@ -710,20 +708,16 @@ export function getMyTeam() {
|
||||
}
|
||||
|
||||
callTracker.getMyTeam = utils.getTimestamp();
|
||||
return client.getMyTeam(
|
||||
function getMyTeamSuccess(data, textStatus, xhr) {
|
||||
return Client.getMyTeam(
|
||||
(data) => {
|
||||
callTracker.getMyTeam = 0;
|
||||
|
||||
if (xhr.status === 304 || !data) {
|
||||
return;
|
||||
}
|
||||
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_MY_TEAM,
|
||||
team: data
|
||||
});
|
||||
},
|
||||
function getMyTeamFailure(err) {
|
||||
(err) => {
|
||||
callTracker.getMyTeam = 0;
|
||||
dispatchError(err, 'getMyTeam');
|
||||
}
|
||||
@@ -736,14 +730,10 @@ export function getAllPreferences() {
|
||||
}
|
||||
|
||||
callTracker.getAllPreferences = utils.getTimestamp();
|
||||
client.getAllPreferences(
|
||||
(data, textStatus, xhr) => {
|
||||
Client.getAllPreferences(
|
||||
(data) => {
|
||||
callTracker.getAllPreferences = 0;
|
||||
|
||||
if (xhr.status === 304 || !data) {
|
||||
return;
|
||||
}
|
||||
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_PREFERENCES,
|
||||
preferences: data
|
||||
@@ -768,15 +758,13 @@ export function savePreference(category, name, value, success, error) {
|
||||
}
|
||||
|
||||
export function savePreferences(preferences, success, error) {
|
||||
client.savePreferences(
|
||||
Client.savePreferences(
|
||||
preferences,
|
||||
(data, textStatus, xhr) => {
|
||||
if (xhr.status !== 304) {
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_PREFERENCES,
|
||||
preferences
|
||||
});
|
||||
}
|
||||
(data) => {
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_PREFERENCES,
|
||||
preferences
|
||||
});
|
||||
|
||||
if (success) {
|
||||
success(data);
|
||||
@@ -793,12 +781,12 @@ export function savePreferences(preferences, success, error) {
|
||||
}
|
||||
|
||||
export function getSuggestedCommands(command, suggestionId, component) {
|
||||
client.listCommands(
|
||||
Client.listCommands(
|
||||
(data) => {
|
||||
var matches = [];
|
||||
data.forEach((cmd) => {
|
||||
if (('/' + cmd.trigger).indexOf(command) === 0) {
|
||||
let s = '/' + cmd.trigger;
|
||||
const s = '/' + cmd.trigger;
|
||||
let hint = '';
|
||||
if (cmd.auto_complete_hint && cmd.auto_complete_hint.length !== 0) {
|
||||
hint = cmd.auto_complete_hint;
|
||||
@@ -842,7 +830,7 @@ export function getFileInfo(filename) {
|
||||
|
||||
callTracker[callName] = utils.getTimestamp();
|
||||
|
||||
client.getFileInfo(
|
||||
Client.getFileInfo(
|
||||
filename,
|
||||
(data) => {
|
||||
callTracker[callName] = 0;
|
||||
@@ -870,7 +858,7 @@ export function getStandardAnalytics(teamId) {
|
||||
|
||||
callTracker[callName] = utils.getTimestamp();
|
||||
|
||||
client.getAnalytics(
|
||||
Client.getAnalytics(
|
||||
'standard',
|
||||
teamId,
|
||||
(data) => {
|
||||
@@ -923,7 +911,7 @@ export function getAdvancedAnalytics(teamId) {
|
||||
|
||||
callTracker[callName] = utils.getTimestamp();
|
||||
|
||||
client.getAnalytics(
|
||||
Client.getAnalytics(
|
||||
'extra_counts',
|
||||
teamId,
|
||||
(data) => {
|
||||
@@ -980,7 +968,7 @@ export function getPostsPerDayAnalytics(teamId) {
|
||||
|
||||
callTracker[callName] = utils.getTimestamp();
|
||||
|
||||
client.getAnalytics(
|
||||
Client.getAnalytics(
|
||||
'post_counts_day',
|
||||
teamId,
|
||||
(data) => {
|
||||
@@ -1014,7 +1002,7 @@ export function getUsersPerDayAnalytics(teamId) {
|
||||
|
||||
callTracker[callName] = utils.getTimestamp();
|
||||
|
||||
client.getAnalytics(
|
||||
Client.getAnalytics(
|
||||
'user_counts_with_posts_day',
|
||||
teamId,
|
||||
(data) => {
|
||||
@@ -1048,7 +1036,7 @@ export function getRecentAndNewUsersAnalytics(teamId) {
|
||||
|
||||
callTracker[callName] = utils.getTimestamp();
|
||||
|
||||
client.getProfilesForTeam(
|
||||
Client.getProfilesForTeam(
|
||||
teamId,
|
||||
(users) => {
|
||||
const stats = {};
|
||||
@@ -1129,7 +1117,7 @@ export function listIncomingHooks() {
|
||||
|
||||
callTracker.listIncomingHooks = utils.getTimestamp();
|
||||
|
||||
client.listIncomingHooks(
|
||||
Client.listIncomingHooks(
|
||||
(data) => {
|
||||
callTracker.listIncomingHooks = 0;
|
||||
|
||||
@@ -1152,7 +1140,7 @@ export function listOutgoingHooks() {
|
||||
|
||||
callTracker.listOutgoingHooks = utils.getTimestamp();
|
||||
|
||||
client.listOutgoingHooks(
|
||||
Client.listOutgoingHooks(
|
||||
(data) => {
|
||||
callTracker.listOutgoingHooks = 0;
|
||||
|
||||
@@ -1169,7 +1157,7 @@ export function listOutgoingHooks() {
|
||||
}
|
||||
|
||||
export function addIncomingHook(hook, success, error) {
|
||||
client.addIncomingHook(
|
||||
Client.addIncomingHook(
|
||||
hook,
|
||||
(data) => {
|
||||
AppDispatcher.handleServerAction({
|
||||
@@ -1192,7 +1180,7 @@ export function addIncomingHook(hook, success, error) {
|
||||
}
|
||||
|
||||
export function addOutgoingHook(hook, success, error) {
|
||||
client.addOutgoingHook(
|
||||
Client.addOutgoingHook(
|
||||
hook,
|
||||
(data) => {
|
||||
AppDispatcher.handleServerAction({
|
||||
@@ -1215,8 +1203,8 @@ export function addOutgoingHook(hook, success, error) {
|
||||
}
|
||||
|
||||
export function deleteIncomingHook(id) {
|
||||
client.deleteIncomingHook(
|
||||
{id},
|
||||
Client.deleteIncomingHook(
|
||||
id,
|
||||
() => {
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.REMOVED_INCOMING_WEBHOOK,
|
||||
@@ -1230,8 +1218,8 @@ export function deleteIncomingHook(id) {
|
||||
}
|
||||
|
||||
export function deleteOutgoingHook(id) {
|
||||
client.deleteOutgoingHook(
|
||||
{id},
|
||||
Client.deleteOutgoingHook(
|
||||
id,
|
||||
() => {
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.REMOVED_OUTGOING_WEBHOOK,
|
||||
@@ -1245,8 +1233,8 @@ export function deleteOutgoingHook(id) {
|
||||
}
|
||||
|
||||
export function regenOutgoingHookToken(id) {
|
||||
client.regenOutgoingHookToken(
|
||||
{id},
|
||||
Client.regenOutgoingHookToken(
|
||||
id,
|
||||
(data) => {
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.UPDATED_OUTGOING_WEBHOOK,
|
||||
@@ -1266,7 +1254,7 @@ export function listTeamCommands() {
|
||||
|
||||
callTracker.listTeamCommands = utils.getTimestamp();
|
||||
|
||||
client.listTeamCommands(
|
||||
Client.listTeamCommands(
|
||||
(data) => {
|
||||
callTracker.listTeamCommands = 0;
|
||||
|
||||
@@ -1283,7 +1271,7 @@ export function listTeamCommands() {
|
||||
}
|
||||
|
||||
export function addCommand(command, success, error) {
|
||||
client.addCommand(
|
||||
Client.addCommand(
|
||||
command,
|
||||
(data) => {
|
||||
AppDispatcher.handleServerAction({
|
||||
@@ -1306,8 +1294,8 @@ export function addCommand(command, success, error) {
|
||||
}
|
||||
|
||||
export function deleteCommand(id) {
|
||||
client.deleteCommand(
|
||||
{id},
|
||||
Client.deleteCommand(
|
||||
id,
|
||||
() => {
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.REMOVED_COMMAND,
|
||||
@@ -1321,8 +1309,8 @@ export function deleteCommand(id) {
|
||||
}
|
||||
|
||||
export function regenCommandToken(id) {
|
||||
client.regenCommandToken(
|
||||
{id},
|
||||
Client.regenCommandToken(
|
||||
id,
|
||||
(data) => {
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.UPDATED_COMMAND,
|
||||
|
||||
@@ -9,6 +9,7 @@ import UserProfile from 'components/user_profile.jsx';
|
||||
import ChannelStore from 'stores/channel_store.jsx';
|
||||
import Constants from 'utils/constants.jsx';
|
||||
import * as GlobalActions from 'action_creators/global_actions.jsx';
|
||||
import Client from 'utils/web_client.jsx';
|
||||
|
||||
import React from 'react';
|
||||
import {FormattedMessage, FormattedHTMLMessage, FormattedDate} from 'react-intl';
|
||||
@@ -40,7 +41,7 @@ export function createDMIntroMessage(channel) {
|
||||
<div className='post-profile-img__container channel-intro-img'>
|
||||
<img
|
||||
className='post-profile-img'
|
||||
src={'/api/v1/users/' + teammate.id + '/image?time=' + teammate.update_at}
|
||||
src={Client.getUsersRoute() + '/' + teammate.id + '/image?time=' + teammate.update_at}
|
||||
height='50'
|
||||
width='50'
|
||||
/>
|
||||
|
||||
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@@ -61,6 +61,7 @@ export default {
|
||||
RECEIVED_ADD_MENTION: null,
|
||||
|
||||
RECEIVED_PROFILES: null,
|
||||
RECEIVED_DIRECT_PROFILES: null,
|
||||
RECEIVED_ME: null,
|
||||
RECEIVED_SESSIONS: null,
|
||||
RECEIVED_AUDITS: null,
|
||||
@@ -92,6 +93,9 @@ export default {
|
||||
RECEIVED_SERVER_AUDITS: null,
|
||||
RECEIVED_SERVER_COMPLIANCE_REPORTS: null,
|
||||
RECEIVED_ALL_TEAMS: null,
|
||||
RECEIVED_ALL_TEAM_LISTINGS: null,
|
||||
RECEIVED_TEAM_MEMBERS: null,
|
||||
RECEIVED_MEMBERS_FOR_TEAM: null,
|
||||
|
||||
RECEIVED_LOCALE: null,
|
||||
|
||||
@@ -205,6 +209,7 @@ export default {
|
||||
LDAP_SERVICE: 'ldap',
|
||||
USERNAME_SERVICE: 'username',
|
||||
SIGNIN_CHANGE: 'signin_change',
|
||||
PASSWORD_CHANGE: 'password_change',
|
||||
SIGNIN_VERIFIED: 'verified',
|
||||
SESSION_EXPIRED: 'expired',
|
||||
POST_CHUNK_SIZE: 60,
|
||||
|
||||
@@ -10,9 +10,8 @@ import PreferenceStore from 'stores/preference_store.jsx';
|
||||
import TeamStore from 'stores/team_store.jsx';
|
||||
import Constants from 'utils/constants.jsx';
|
||||
var ActionTypes = Constants.ActionTypes;
|
||||
import * as Client from './client.jsx';
|
||||
import * as AsyncClient from './async_client.jsx';
|
||||
import * as client from './client.jsx';
|
||||
import Client from './web_client.jsx';
|
||||
|
||||
import React from 'react';
|
||||
import {browserHistory} from 'react-router';
|
||||
@@ -1114,7 +1113,7 @@ export function fileSizeToString(bytes) {
|
||||
|
||||
// Converts a filename (like those attached to Post objects) to a url that can be used to retrieve attachments from the server.
|
||||
export function getFileUrl(filename) {
|
||||
return getWindowLocationOrigin() + '/api/v1/files/get' + filename;
|
||||
return getWindowLocationOrigin() + Client.getFilesRoute() + '/get' + filename;
|
||||
}
|
||||
|
||||
// Gets the name of a file (including extension) from a given url or file path.
|
||||
@@ -1210,13 +1209,17 @@ export function importSlack(file, success, error) {
|
||||
formData.append('filesize', file.size);
|
||||
formData.append('importFrom', 'slack');
|
||||
|
||||
client.importSlack(formData, success, error);
|
||||
Client.importSlack(formData, success, error);
|
||||
}
|
||||
|
||||
export function getTeamURLFromAddressBar() {
|
||||
return window.location.origin + '/' + window.location.pathname.split('/')[1];
|
||||
}
|
||||
|
||||
export function getTeamNameFromUrl() {
|
||||
return window.location.pathname.split('/')[1];
|
||||
}
|
||||
|
||||
export function getTeamURLNoOriginFromAddressBar() {
|
||||
return '/' + window.location.pathname.split('/')[1];
|
||||
}
|
||||
@@ -1263,16 +1266,11 @@ export function openDirectChannelToUser(user, successCb, errorCb) {
|
||||
};
|
||||
|
||||
Client.createDirectChannel(
|
||||
channel,
|
||||
user.id,
|
||||
(data) => {
|
||||
Client.getChannel(
|
||||
data.id,
|
||||
(data2, textStatus, xhr) => {
|
||||
if (xhr.status === 304 || !data2) {
|
||||
return;
|
||||
}
|
||||
|
||||
(data2) => {
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_CHANNEL,
|
||||
channel: data2.channel,
|
||||
@@ -1400,7 +1398,7 @@ export function localizeMessage(id, defaultMessage) {
|
||||
}
|
||||
|
||||
export function getProfilePicSrcForPost(post, timestamp) {
|
||||
let src = '/api/v1/users/' + post.user_id + '/image?time=' + timestamp;
|
||||
let src = Client.getUsersRoute() + '/' + post.user_id + '/image?time=' + timestamp;
|
||||
if (post.props && post.props.from_webhook && global.window.mm_config.EnablePostIconOverride === 'true') {
|
||||
if (post.props.override_icon_url) {
|
||||
src = post.props.override_icon_url;
|
||||
|
||||
67
webapp/utils/web_client.jsx
Обычный файл
67
webapp/utils/web_client.jsx
Обычный файл
@@ -0,0 +1,67 @@
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import Client from '../client/client.jsx';
|
||||
import TeamStore from '../stores/team_store.jsx';
|
||||
import BrowserStore from '../stores/browser_store.jsx';
|
||||
import * as GlobalActions from 'action_creators/global_actions.jsx';
|
||||
|
||||
const HTTP_UNAUTHORIZED = 401;
|
||||
|
||||
class WebClientClass extends Client {
|
||||
constructor() {
|
||||
super();
|
||||
this.enableLogErrorsToConsole(true);
|
||||
TeamStore.addChangeListener(this.onTeamStoreChanged);
|
||||
}
|
||||
|
||||
onTeamStoreChanged = () => {
|
||||
this.setTeamId(TeamStore.getCurrentId());
|
||||
}
|
||||
|
||||
track = (category, action, label, property, value) => {
|
||||
if (global.window && global.window.analytics) {
|
||||
global.window.analytics.track(action, {category, label, property, value});
|
||||
}
|
||||
}
|
||||
|
||||
trackPage = () => {
|
||||
if (global.window && global.window.analytics) {
|
||||
global.window.analytics.page();
|
||||
}
|
||||
}
|
||||
|
||||
handleError = (err, res) => { // eslint-disable-line no-unused-vars
|
||||
if (err.status === HTTP_UNAUTHORIZED) {
|
||||
GlobalActions.emitUserLoggedOutEvent('/login');
|
||||
}
|
||||
}
|
||||
|
||||
// not sure why but super.login doesn't work if using an () => arrow functions.
|
||||
// I think this might be a webpack issue.
|
||||
webLogin(email, username, password, token, success, error) {
|
||||
this.login(
|
||||
email,
|
||||
username,
|
||||
password,
|
||||
token,
|
||||
(data) => {
|
||||
this.track('api', 'api_users_login_success', '', 'email', data.email);
|
||||
BrowserStore.signalLogin();
|
||||
|
||||
if (success) {
|
||||
success(data);
|
||||
}
|
||||
},
|
||||
(err) => {
|
||||
this.track('api', 'api_users_login_fail', name, 'email', email);
|
||||
if (error) {
|
||||
error(err);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
var WebClient = new WebClientClass();
|
||||
export default WebClient;
|
||||
Ссылка в новой задаче
Block a user