Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
dispatch(batchActions([
{
type: UserTypes.RECEIVED_PROFILE_NOT_IN_TEAM,
data: {id: msg.data.team_id, user_id: msg.data.user_id},
},
{
type: TeamTypes.REMOVE_MEMBER_FROM_TEAM,
data: {team_id: msg.data.team_id, user_id: msg.data.user_id},
},
]));
if (getCurrentUserId(state) === msg.data.user_id) {
dispatch({type: TeamTypes.LEAVE_TEAM, data: {id: msg.data.team_id}});
// if they are on the team being removed redirect them to default team
if (getCurrentTeamId(state) === msg.data.team_id) {
if (!global.location.pathname.startsWith('/admin_console')) {
GlobalActions.redirectUserToDefaultTeam();
}
}
}
}
return async (dispatch, getState) => {
const state = getState();
const teamId = getCurrentTeamId(state);
let args = {
channel_id: channelId,
team_id: teamId,
root_id: rootId,
parent_id: rootId,
};
let {message} = draft;
const hookResult = await dispatch(runSlashCommandWillBePostedHooks(message, args));
if (hookResult.error) {
return {error: hookResult.error};
} else if (!hookResult.data.message && !hookResult.data.args) {
// do nothing with an empty return from a hook
return {};
return async (dispatch, getState) => {
const state = getState();
const channel = getChannel(state, channelId);
const currentTeamId = getCurrentTeamId(state);
const currentChannelId = getCurrentChannelId(state);
const sameChannel = channelId === currentChannelId;
const member = getMyChannelMember(state, channelId);
dispatch(setLoadMorePostsVisible(true));
// If the app is open from push notification, we already fetched the posts.
if (!fromPushNotification) {
dispatch(loadPostsIfNecessaryWithRetry(channelId));
}
const actions = [
selectChannel(channelId),
getChannelStats(channelId),
setChannelDisplayName(channel.display_name),
{
return async (dispatch, getState) => {
const {data} = await dispatch(getPostThread(postId));
if (!data) {
browserHistory.replace(`/error?type=${ErrorPageTypes.PERMALINK_NOT_FOUND}&returnTo=${returnTo}`);
return;
}
const state = getState();
const channelId = data.posts[data.order[0]].channel_id;
let channel = state.entities.channels.channels[channelId];
const teamId = getCurrentTeamId(state);
if (!channel) {
const {data: channelData} = await dispatch(getChannel(channelId));
if (!channelData) {
browserHistory.replace(`/error?type=${ErrorPageTypes.PERMALINK_NOT_FOUND}&returnTo=${returnTo}`);
return;
}
channel = channelData;
}
const myMember = state.entities.channels.myMembers[channelId];
if (!myMember) {
// If it's a DM or GM channel and we don't have a channel member for it already, user is not a member
const mapStateToProps = (state) => ({
user: getCurrentUser(state),
channel: getCurrentChannel(state),
isDefault: isCurrentChannelDefault(state),
isFavorite: isCurrentChannelFavorite(state),
isMuted: isCurrentChannelMuted(state),
isReadonly: isCurrentChannelReadOnly(state),
isArchived: isCurrentChannelArchived(state),
penultimateViewedChannelName: getPenultimateViewedChannelName(state) || getRedirectChannelNameForTeam(state, getCurrentTeamId(state)),
pluginMenuItems: state.plugins.components.ChannelHeader || [],
isLicensedForLDAPGroups: state.entities.general.license.LDAPGroups === 'true',
});
const value = ownProps.value.substring(0, cursorPosition);
const matchTerm = getMatchTermForAtMention(value, isSearch);
let teamMembers;
let inChannel;
let outChannel;
if (isSearch) {
teamMembers = filterMembersInCurrentTeam(state, matchTerm);
} else {
inChannel = filterMembersInChannel(state, matchTerm);
outChannel = filterMembersNotInChannel(state, matchTerm);
}
return {
currentChannelId,
currentTeamId: getCurrentTeamId(state),
defaultChannel: getDefaultChannel(state),
matchTerm,
teamMembers,
inChannel,
outChannel,
requestStatus: state.requests.users.autocompleteUsers.status,
theme: getTheme(state),
isLandscape: isLandscape(state),
};
}
function mapStateToProps(state) {
const menuAction = state.views.post.selectedMenuAction || {};
const data = menuAction.options || [];
return {
currentTeamId: getCurrentTeamId(state),
data,
dataSource: menuAction.dataSource,
onSelect: menuAction.onSelect,
theme: getTheme(state),
};
}
function mapStateToProps(state) {
return {
currentTeamId: getCurrentTeamId(state),
};
}
return async (dispatch, getState) => {
const state = getState();
const currentTeamId = getCurrentTeamId(state);
return dispatch(autocompleteUsers(prefix, currentTeamId, channelId));
};
}
function mapStateToProps(state) {
const config = getConfig(state);
const restrictDirectMessage = config.RestrictDirectMessage === General.RESTRICT_DIRECT_MESSAGE_ANY;
return {
restrictDirectMessage,
teammateNameDisplay: getTeammateNameDisplaySetting(state),
allProfiles: getUsers(state),
theme: getTheme(state),
currentDisplayName: state.views.channel.displayName,
currentUserId: getCurrentUserId(state),
currentTeamId: getCurrentTeamId(state),
isLandscape: isLandscape(state),
};
}