mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 04:04:06 -08:00
⚡ Improve channel selection on Mattermost node
This commit is contained in:
parent
7168b1780e
commit
a6cf9bceb3
|
@ -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<INodePropertyOptions[]> {
|
||||
|
@ -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;
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue