diff --git a/packages/nodes-base/nodes/Mattermost/Mattermost.node.ts b/packages/nodes-base/nodes/Mattermost/Mattermost.node.ts index e6ff3b86b2..e4618f5919 100644 --- a/packages/nodes-base/nodes/Mattermost/Mattermost.node.ts +++ b/packages/nodes-base/nodes/Mattermost/Mattermost.node.ts @@ -1520,11 +1520,11 @@ export class Mattermost implements INodeType { const returnData: INodePropertyOptions[] = []; let name: string; for (const data of responseData) { - if (data.delete_at !== 0) { + if (data.delete_at !== 0 || (!data.display_name || !data.name)) { continue; } - name = `${data.name} (${data.type === 'O' ? 'public' : 'private'})`; + name = `${data.team_display_name} - ${data.display_name || data.name} (${data.type === 'O' ? 'public' : 'private'})`; returnData.push({ name, @@ -1532,6 +1532,12 @@ export class Mattermost implements INodeType { }); } + returnData.sort((a, b) => { + if (a.name < b.name) { return -1; } + if (a.name > b.name) { return 1; } + return 0; + }); + return returnData; }, @@ -1548,17 +1554,18 @@ export class Mattermost implements INodeType { const returnData: INodePropertyOptions[] = []; let name: string; for (const data of responseData) { - if (data.delete_at !== 0) { + if (data.delete_at !== 0 || (!data.display_name || !data.name)) { continue; } const channelTypes: IDataObject = { + 'D': 'direct', + 'G': 'group', 'O': 'public', 'P': 'private', - 'D': 'direct', }; - name = `${data.name} (${channelTypes[data.type as string]})`; + name = `${data.display_name} (${channelTypes[data.type as string]})`; returnData.push({ name, @@ -1566,6 +1573,12 @@ export class Mattermost implements INodeType { }); } + returnData.sort((a, b) => { + if (a.name < b.name) { return -1; } + if (a.name > b.name) { return 1; } + return 0; + }); + return returnData; }, @@ -1593,6 +1606,12 @@ export class Mattermost implements INodeType { }); } + returnData.sort((a, b) => { + if (a.name < b.name) { return -1; } + if (a.name > b.name) { return 1; } + return 0; + }); + return returnData; }, async getUsers(this: ILoadOptionsFunctions): Promise { @@ -1616,6 +1635,12 @@ export class Mattermost implements INodeType { }); } + returnData.sort((a, b) => { + if (a.name < b.name) { return -1; } + if (a.name > b.name) { return 1; } + return 0; + }); + return returnData; }, },