Combines the following repositories into one: https://github.com/mattermost/mattermost-server https://github.com/mattermost/mattermost-webapp https://github.com/mattermost/focalboard https://github.com/mattermost/mattermost-plugin-playbooks
54 строки
1.4 KiB
TypeScript
54 строки
1.4 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {AppCallResponseTypes} from 'mattermost-redux/constants/apps';
|
|
import {AppCall, AppCallRequest, AppCallResponse, AppCallValues, AppContext, AppExpand, AppSelectOption} from '@mattermost/types/apps';
|
|
|
|
export const appsPluginID = 'com.mattermost.apps';
|
|
|
|
export function createCallContext(
|
|
appID: string,
|
|
location?: string,
|
|
channelID?: string,
|
|
teamID?: string,
|
|
postID?: string,
|
|
rootID?: string,
|
|
): AppContext {
|
|
return {
|
|
app_id: appID,
|
|
location,
|
|
channel_id: channelID,
|
|
team_id: teamID,
|
|
post_id: postID,
|
|
root_id: rootID,
|
|
};
|
|
}
|
|
|
|
export function createCallRequest(
|
|
call: AppCall,
|
|
context: AppContext,
|
|
defaultExpand: AppExpand = {},
|
|
values?: AppCallValues,
|
|
rawCommand?: string,
|
|
): AppCallRequest {
|
|
return {
|
|
...call,
|
|
context,
|
|
values,
|
|
expand: {
|
|
...defaultExpand,
|
|
...call.expand,
|
|
},
|
|
raw_command: rawCommand,
|
|
};
|
|
}
|
|
|
|
export const makeCallErrorResponse = (errMessage: string): AppCallResponse<any> => {
|
|
return {
|
|
type: AppCallResponseTypes.ERROR,
|
|
text: errMessage,
|
|
};
|
|
};
|
|
|
|
export const filterEmptyOptions = (option: AppSelectOption) => option.value && !option.value.match(/^[ \t]+$/);
|