[MM-34203] Send team id on bindings call (#5316)
* send team id on bindings call * lint
This commit is contained in:
parent
3eaa538707
commit
f3b7c3a978
2 changed files with 23 additions and 8 deletions
|
|
@ -2,10 +2,11 @@
|
|||
// See LICENSE.txt for license information.
|
||||
|
||||
import type {AppBinding, AppCallRequest, AppCallResponse, AppCallType} from '@mm-redux/types/apps';
|
||||
import {buildQueryString} from '@mm-redux/utils/helpers';
|
||||
|
||||
export interface ClientAppsMix {
|
||||
executeAppCall: (call: AppCallRequest, type: AppCallType) => Promise<AppCallResponse>;
|
||||
getAppsBindings: (userID: string, channelID: string) => Promise<AppBinding[]>;
|
||||
getAppsBindings: (userID: string, channelID: string, teamID: string) => Promise<AppBinding[]>;
|
||||
}
|
||||
|
||||
const ClientApps = (superclass: any) => class extends superclass {
|
||||
|
|
@ -25,9 +26,16 @@ const ClientApps = (superclass: any) => class extends superclass {
|
|||
);
|
||||
}
|
||||
|
||||
getAppsBindings = async (userID: string, channelID: string) => {
|
||||
getAppsBindings = async (userID: string, channelID: string, teamID: string) => {
|
||||
const params = {
|
||||
user_id: userID,
|
||||
channel_id: channelID,
|
||||
team_id: teamID,
|
||||
user_agent: 'mobile',
|
||||
};
|
||||
|
||||
return this.doFetch(
|
||||
this.getAppsProxyRoute() + `/api/v1/bindings?user_id=${userID}&channel_id=${channelID}&user_agent_type=mobile`,
|
||||
`${this.getAppsProxyRoute()}/api/v1/bindings${buildQueryString(params)}`,
|
||||
{method: 'get'},
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,22 @@
|
|||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {AppsTypes} from '@mm-redux/action_types';
|
||||
import {Client4} from '@client/rest';
|
||||
|
||||
import {ActionFunc} from '@mm-redux/types/actions';
|
||||
import {ActionFunc, DispatchFunc, GetStateFunc} from '@mm-redux/types/actions';
|
||||
import {getChannel} from '@mm-redux/selectors/entities/channels';
|
||||
|
||||
import {bindClientFunc} from './helpers';
|
||||
|
||||
export function fetchAppBindings(userID: string, channelID: string): ActionFunc {
|
||||
return bindClientFunc({
|
||||
clientFunc: () => Client4.getAppsBindings(userID, channelID),
|
||||
onSuccess: AppsTypes.RECEIVED_APP_BINDINGS,
|
||||
});
|
||||
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||
const channel = getChannel(getState(), channelID);
|
||||
const teamID = channel?.team_id || '';
|
||||
|
||||
return dispatch(bindClientFunc({
|
||||
clientFunc: () => Client4.getAppsBindings(userID, channelID, teamID),
|
||||
onSuccess: AppsTypes.RECEIVED_APP_BINDINGS,
|
||||
}));
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue