mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-12 15:44:06 -08:00
fix(Mattermost Node): Change loadOptions to fetch all items (#9413)
This commit is contained in:
parent
92a1d65c4b
commit
1377e212c7
|
@ -1,12 +1,12 @@
|
||||||
import type { IDataObject, ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow';
|
import type { IDataObject, ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow';
|
||||||
import { NodeOperationError } from 'n8n-workflow';
|
import { NodeOperationError } from 'n8n-workflow';
|
||||||
|
|
||||||
import { apiRequest } from '../transport';
|
import { apiRequestAllItems } from '../transport';
|
||||||
|
|
||||||
// Get all the available channels
|
// Get all the available channels
|
||||||
export async function getChannels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
export async function getChannels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||||
const endpoint = 'channels';
|
const endpoint = 'channels';
|
||||||
const responseData = await apiRequest.call(this, 'GET', endpoint, {});
|
const responseData = await apiRequestAllItems.call(this, 'GET', endpoint, {});
|
||||||
|
|
||||||
if (responseData === undefined) {
|
if (responseData === undefined) {
|
||||||
throw new NodeOperationError(this.getNode(), 'No data got returned');
|
throw new NodeOperationError(this.getNode(), 'No data got returned');
|
||||||
|
@ -25,7 +25,7 @@ export async function getChannels(this: ILoadOptionsFunctions): Promise<INodePro
|
||||||
|
|
||||||
returnData.push({
|
returnData.push({
|
||||||
name,
|
name,
|
||||||
value: data.id,
|
value: data.id as string,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ export async function getChannelsInTeam(
|
||||||
): Promise<INodePropertyOptions[]> {
|
): Promise<INodePropertyOptions[]> {
|
||||||
const teamId = this.getCurrentNodeParameter('teamId');
|
const teamId = this.getCurrentNodeParameter('teamId');
|
||||||
const endpoint = `users/me/teams/${teamId}/channels`;
|
const endpoint = `users/me/teams/${teamId}/channels`;
|
||||||
const responseData = await apiRequest.call(this, 'GET', endpoint, {});
|
const responseData = await apiRequestAllItems.call(this, 'GET', endpoint, {});
|
||||||
|
|
||||||
if (responseData === undefined) {
|
if (responseData === undefined) {
|
||||||
throw new NodeOperationError(this.getNode(), 'No data got returned');
|
throw new NodeOperationError(this.getNode(), 'No data got returned');
|
||||||
|
@ -72,7 +72,7 @@ export async function getChannelsInTeam(
|
||||||
|
|
||||||
returnData.push({
|
returnData.push({
|
||||||
name,
|
name,
|
||||||
value: data.id,
|
value: data.id as string,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ export async function getChannelsInTeam(
|
||||||
|
|
||||||
export async function getTeams(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
export async function getTeams(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||||
const endpoint = 'users/me/teams';
|
const endpoint = 'users/me/teams';
|
||||||
const responseData = await apiRequest.call(this, 'GET', endpoint, {});
|
const responseData = await apiRequestAllItems.call(this, 'GET', endpoint, {});
|
||||||
|
|
||||||
if (responseData === undefined) {
|
if (responseData === undefined) {
|
||||||
throw new NodeOperationError(this.getNode(), 'No data got returned');
|
throw new NodeOperationError(this.getNode(), 'No data got returned');
|
||||||
|
@ -108,7 +108,7 @@ export async function getTeams(this: ILoadOptionsFunctions): Promise<INodeProper
|
||||||
|
|
||||||
returnData.push({
|
returnData.push({
|
||||||
name,
|
name,
|
||||||
value: data.id,
|
value: data.id as string,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ export async function getTeams(this: ILoadOptionsFunctions): Promise<INodeProper
|
||||||
|
|
||||||
export async function getUsers(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
export async function getUsers(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||||
const endpoint = 'users';
|
const endpoint = 'users';
|
||||||
const responseData = await apiRequest.call(this, 'GET', endpoint, {});
|
const responseData = await apiRequestAllItems.call(this, 'GET', endpoint, {});
|
||||||
|
|
||||||
if (responseData === undefined) {
|
if (responseData === undefined) {
|
||||||
throw new NodeOperationError(this.getNode(), 'No data got returned');
|
throw new NodeOperationError(this.getNode(), 'No data got returned');
|
||||||
|
@ -140,8 +140,8 @@ export async function getUsers(this: ILoadOptionsFunctions): Promise<INodeProper
|
||||||
}
|
}
|
||||||
|
|
||||||
returnData.push({
|
returnData.push({
|
||||||
name: data.username,
|
name: data.username as string,
|
||||||
value: data.id,
|
value: data.id as string,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue