mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-15 09:04:07 -08:00
2c146cca62
Co-authored-by: Giulio Andreini <andreini@netseven.it>
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import type { IExecuteFunctions, ILoadOptionsFunctions, INodeListSearchItems } from 'n8n-workflow';
|
|
|
|
export function prepareMessage(
|
|
this: IExecuteFunctions | ILoadOptionsFunctions,
|
|
message: string,
|
|
contentType: string,
|
|
includeLinkToWorkflow: boolean,
|
|
instanceId?: string,
|
|
) {
|
|
if (includeLinkToWorkflow) {
|
|
const { id } = this.getWorkflow();
|
|
const link = `${this.getInstanceBaseUrl()}workflow/${id}?utm_source=n8n-internal&utm_medium=powered_by&utm_campaign=${encodeURIComponent(
|
|
'n8n-nodes-base.microsoftTeams',
|
|
)}${instanceId ? '_' + instanceId : ''}`;
|
|
contentType = 'html';
|
|
message = `${message}<br><br><em> Powered by <a href="${link}">this n8n workflow</a> </em>`;
|
|
}
|
|
|
|
return {
|
|
body: {
|
|
contentType,
|
|
content: message,
|
|
},
|
|
};
|
|
}
|
|
|
|
export function filterSortSearchListItems(items: INodeListSearchItems[], filter?: string) {
|
|
return items
|
|
.filter(
|
|
(item) =>
|
|
!filter ||
|
|
item.name.toLowerCase().includes(filter.toLowerCase()) ||
|
|
item.value.toString().toLowerCase().includes(filter.toLowerCase()),
|
|
)
|
|
.sort((a, b) => {
|
|
if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) {
|
|
return -1;
|
|
}
|
|
if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) {
|
|
return 1;
|
|
}
|
|
return 0;
|
|
});
|
|
}
|