Skip to content

fix(Mattermost Node): Change loadOptions to fetch all items #9413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions packages/nodes-base/nodes/Mattermost/v1/methods/loadOptions.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { IDataObject, ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow';
import { NodeOperationError } from 'n8n-workflow';

import { apiRequest } from '../transport';
import { apiRequestAllItems } from '../transport';

// Get all the available channels
export async function getChannels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const endpoint = 'channels';
const responseData = await apiRequest.call(this, 'GET', endpoint, {});
const responseData = await apiRequestAllItems.call(this, 'GET', endpoint, {});

if (responseData === undefined) {
throw new NodeOperationError(this.getNode(), 'No data got returned');
Expand All @@ -25,7 +25,7 @@ export async function getChannels(this: ILoadOptionsFunctions): Promise<INodePro

returnData.push({
name,
value: data.id,
value: data.id as string,
});
}

Expand All @@ -48,7 +48,7 @@ export async function getChannelsInTeam(
): Promise<INodePropertyOptions[]> {
const teamId = this.getCurrentNodeParameter('teamId');
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) {
throw new NodeOperationError(this.getNode(), 'No data got returned');
Expand All @@ -72,7 +72,7 @@ export async function getChannelsInTeam(

returnData.push({
name,
value: data.id,
value: data.id as string,
});
}

Expand All @@ -91,7 +91,7 @@ export async function getChannelsInTeam(

export async function getTeams(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const endpoint = 'users/me/teams';
const responseData = await apiRequest.call(this, 'GET', endpoint, {});
const responseData = await apiRequestAllItems.call(this, 'GET', endpoint, {});

if (responseData === undefined) {
throw new NodeOperationError(this.getNode(), 'No data got returned');
Expand All @@ -108,7 +108,7 @@ export async function getTeams(this: ILoadOptionsFunctions): Promise<INodeProper

returnData.push({
name,
value: data.id,
value: data.id as string,
});
}

Expand All @@ -127,7 +127,7 @@ export async function getTeams(this: ILoadOptionsFunctions): Promise<INodeProper

export async function getUsers(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const endpoint = 'users';
const responseData = await apiRequest.call(this, 'GET', endpoint, {});
const responseData = await apiRequestAllItems.call(this, 'GET', endpoint, {});

if (responseData === undefined) {
throw new NodeOperationError(this.getNode(), 'No data got returned');
Expand All @@ -140,8 +140,8 @@ export async function getUsers(this: ILoadOptionsFunctions): Promise<INodeProper
}

returnData.push({
name: data.username,
value: data.id,
name: data.username as string,
value: data.id as string,
});
}

Expand Down