How to use the mattermost-redux/selectors/entities/users.getCurrentUser function in mattermost-redux

To help you get started, we’ve selected a few mattermost-redux examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mattermost / mattermost-mobile / app / utils / sentry / index.js View on Github external
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,
        },
    };
}
github mattermost / mattermost-webapp / components / login / login_controller / index.js View on Github external
// 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,
github mattermost / mattermost-webapp / actions / websocket_actions.jsx View on Github external
() => {
            if (getCurrentUser(getState()) != null) {
                reconnect(false);
            }
        },
        SYNC_INTERVAL_MILLISECONDS
github mattermost / mattermost-webapp / actions / websocket_actions.jsx View on Github external
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,
github mattermost / mattermost-webapp / actions / notification_actions.jsx View on Github external
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;
github mattermost / mattermost-webapp / components / invite_member_modal / index.js View on Github external
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 : '',
    };
}
github mattermost / mattermost-webapp / components / logged_in / index.js View on Github external
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,
    };
}
github mattermost / mattermost-webapp / components / backstage / index.js View on Github external
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;
github mattermost / mattermost-webapp / components / status_dropdown / index.jsx View on Github external
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),
    };
}
github mattermost / mattermost-webapp / components / sidebar / header / dropdown / index.js View on Github external
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,
    };
}