mattermost-redux
Version:
Common code (API client, Redux stores, logic, utility functions) for building a Mattermost client
34 lines (33 loc) • 1.5 kB
JavaScript
;
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.getServerLimits = getServerLimits;
const action_types_1 = require("mattermost-redux/action_types");
const errors_1 = require("mattermost-redux/actions/errors");
const helpers_1 = require("mattermost-redux/actions/helpers");
const client_1 = require("mattermost-redux/client");
function getServerLimits() {
return async (dispatch, getState) => {
// All users can fetch server limits - server handles permission filtering
let response;
try {
response = await client_1.Client4.getServerLimits();
}
catch (err) {
(0, helpers_1.forceLogoutIfNecessary)(err, dispatch, getState);
dispatch((0, errors_1.logError)(err));
return { error: err };
}
const data = {
activeUserCount: response?.data?.activeUserCount ?? 0,
maxUsersLimit: response?.data?.maxUsersLimit ?? 0,
maxUsersHardLimit: response?.data?.maxUsersHardLimit ?? 0,
// Post history limit fields from server response
lastAccessiblePostTime: response?.data?.lastAccessiblePostTime ?? 0,
postHistoryLimit: response?.data?.postHistoryLimit ?? 0,
};
dispatch({ type: action_types_1.LimitsTypes.RECEIVED_APP_LIMITS, data });
return { data };
};
}