Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getUserContext(state) {
const currentUser = getCurrentUser(state);
if (!currentUser) {
return {};
}
return {
userID: currentUser.id, // This can be changed to id after we upgrade to Sentry >= 0.14.10,
email: '',
username: '',
extra: {
locale: currentUser.locale,
roles: currentUser.roles,
},
};
}
// Only set experimental team if user is on that team
let experimentalPrimaryTeam = config.ExperimentalPrimaryTeam;
if (experimentalPrimaryTeam) {
const team = getTeamByName(state, experimentalPrimaryTeam);
if (team) {
const member = getMyTeamMember(state, team.id);
if (!member || !member.team_id) {
experimentalPrimaryTeam = null;
}
} else {
experimentalPrimaryTeam = null;
}
}
return {
currentUser: getCurrentUser(state),
isLicensed,
customBrandText,
customDescriptionText,
enableCustomBrand,
enableLdap,
enableOpenServer,
enableSaml,
enableSignInWithEmail,
enableSignInWithUsername,
enableSignUpWithEmail,
enableSignUpWithGitLab,
enableSignUpWithGoogle,
enableSignUpWithOffice365,
experimentalPrimaryTeam,
ldapLoginFieldName,
samlLoginButtonText,
() => {
if (getCurrentUser(getState()) != null) {
reconnect(false);
}
},
SYNC_INTERVAL_MILLISECONDS
function handleUserTypingEvent(msg) {
const state = getState();
const config = getConfig(state);
const currentUserId = getCurrentUserId(state);
const currentUser = getCurrentUser(state);
const userId = msg.data.user_id;
const data = {
id: msg.broadcast.channel_id + msg.data.parent_id,
userId,
now: Date.now(),
};
dispatch({
type: WebsocketEvents.TYPING,
data,
}, getState);
setTimeout(() => {
dispatch({
type: WebsocketEvents.STOP_TYPING,
let userFromPost = getUser(state, post.user_id);
if (!userFromPost) {
const missingProfileResponse = await dispatch(getProfilesByIds([post.user_id]));
if (missingProfileResponse.data && missingProfileResponse.data.length) {
userFromPost = missingProfileResponse.data[0];
}
}
let mentions = [];
if (msgProps.mentions) {
mentions = JSON.parse(msgProps.mentions);
}
const teamId = msgProps.team_id;
let channel = getChannel(state, post.channel_id);
const user = getCurrentUser(state);
const userStatus = getStatusForUserId(state, user.id);
const member = getMyChannelMember(state, post.channel_id);
if (!member || isChannelMuted(member) || userStatus === UserStatuses.DND || userStatus === UserStatuses.OUT_OF_OFFICE) {
return;
}
let notifyLevel = member && member.notify_props ? member.notify_props.desktop : NotificationLevels.DEFAULT;
if (notifyLevel === NotificationLevels.DEFAULT) {
notifyLevel = user && user.notify_props ? user.notify_props.desktop : NotificationLevels.ALL;
}
if (notifyLevel === NotificationLevels.NONE) {
return;
} else if (notifyLevel === NotificationLevels.MENTION && mentions.indexOf(user.id) === -1 && msgProps.channel_type !== Constants.DM_CHANNEL) {
return;
function mapStateToProps(state) {
const config = getConfig(state);
const enableUserCreation = config.EnableUserCreation === 'true';
const defaultChannel = getChannelsNameMapInCurrentTeam(state)[Constants.DEFAULT_CHANNEL];
const team = getCurrentTeam(state);
return {
enableUserCreation,
currentUser: getCurrentUser(state),
defaultChannelName: defaultChannel ? defaultChannel.display_name : '',
teamType: team ? team.type : '',
teamId: team ? team.id : '',
};
}
function mapStateToProps(state, ownProps) {
const license = getLicense(state);
const config = getConfig(state);
const showTermsOfService = shouldShowTermsOfService(state);
return {
currentUser: getCurrentUser(state),
currentChannelId: getCurrentChannelId(state),
mfaRequired: checkIfMFARequired(getCurrentUser(state), license, config, ownProps.match.url),
enableTimezone: config.ExperimentalTimezone === 'true',
showTermsOfService,
};
}
function mapStateToProps(state) {
const user = getCurrentUser(state);
const team = getCurrentTeam(state);
const config = getConfig(state);
const siteName = config.SiteName;
const enableCustomEmoji = config.EnableCustomEmoji === 'true';
const enableIncomingWebhooks = config.EnableIncomingWebhooks === 'true';
const enableOutgoingWebhooks = config.EnableOutgoingWebhooks === 'true';
const enableCommands = config.EnableCommands === 'true';
const enableOAuthServiceProvider = config.EnableOAuthServiceProvider === 'true';
let canCreateOrDeleteCustomEmoji = (haveISystemPermission(state, {permission: Permissions.CREATE_EMOJIS}) || haveISystemPermission(state, {permission: Permissions.DELETE_EMOJIS}));
if (!canCreateOrDeleteCustomEmoji) {
for (const t of getMyTeams(state)) {
if (haveITeamPermission(state, {team: t.id, permission: Permissions.CREATE_EMOJIS}) || haveITeamPermission(state, {team: t.id, permission: Permissions.DELETE_EMOJIS})) {
canCreateOrDeleteCustomEmoji = true;
function mapStateToProps(state) {
const currentUser = getCurrentUser(state);
if (!currentUser) {
return {};
}
const userId = currentUser.id;
return {
userId,
profilePicture: Client4.getProfilePictureUrl(userId, currentUser.last_picture_update),
autoResetPref: get(state, Preferences.CATEGORY_AUTO_RESET_MANUAL_STATUS, userId, ''),
status: getStatusForUserId(state, userId),
};
}
function mapStateToProps(state) {
const currentTeam = getCurrentTeam(state);
const currentUser = getCurrentUser(state);
const showTutorialTip = getInt(state, Preferences.TUTORIAL_STEP, currentUser.id) === TutorialSteps.MENU_POPOVER && !Utils.isMobile();
return {
currentUser,
teamDescription: currentTeam.description,
teamDisplayName: currentTeam.display_name,
teamId: currentTeam.id,
showTutorialTip,
};
}