This commit is contained in:
Miłosz Szewczak 2020-04-13 23:14:16 +02:00 committed by GitHub
parent cc52ed596e
commit 031827e315
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -571,9 +571,8 @@ export class Mattermost implements INodeType {
default: '', default: '',
description: 'Icon which should appear next to footer.', description: 'Icon which should appear next to footer.',
}, },
{
displayName: 'Actions',
{ displayName: 'Actions',
name: 'actions', name: 'actions',
placeholder: 'Add Actions', placeholder: 'Add Actions',
description: 'Actions to add to message.', description: 'Actions to add to message.',
@ -594,8 +593,6 @@ export class Mattermost implements INodeType {
default: '', default: '',
description: 'Name of the Action.', description: 'Name of the Action.',
}, },
{ {
displayName: 'Integration', displayName: 'Integration',
name: 'integration', name: 'integration',
@ -619,8 +616,6 @@ export class Mattermost implements INodeType {
default: '', default: '',
description: 'URL of the Integration.', description: 'URL of the Integration.',
}, },
// context
{ {
displayName: 'Context', displayName: 'Context',
name: 'context', name: 'context',
@ -655,44 +650,14 @@ export class Mattermost implements INodeType {
}, },
], ],
}, },
] ]
}, },
], ],
}, },
] ]
}, },
], ],
}, },
{ {
displayName: 'Fields', displayName: 'Fields',
name: 'fields', name: 'fields',
@ -997,9 +962,7 @@ export class Mattermost implements INodeType {
body.message = this.getNodeParameter('message', i) as string; body.message = this.getNodeParameter('message', i) as string;
const attachments = this.getNodeParameter('attachments', i, []) as unknown as IAttachment[]; const attachments = this.getNodeParameter('attachments', i, []) as unknown as IAttachment[];
console.log('----');
console.dir(attachments);
console.log('----');
// The node does save the fields data differently than the API // The node does save the fields data differently than the API
// expects so fix the data befre we send the request // expects so fix the data befre we send the request
for (const attachment of attachments) { for (const attachment of attachments) {
@ -1020,58 +983,35 @@ export class Mattermost implements INodeType {
// Move the field-content up // Move the field-content up
// @ts-ignore // @ts-ignore
attachment.actions = attachment.actions.item; attachment.actions = attachment.actions.item;
console.log(attachment.actions );
} else { } else {
// If it does not have any items set remove it // If it does not have any items set remove it
delete attachment.actions; delete attachment.actions;
} }
} }
} }
const util = require('util');
console.log('&&&&');
//console.dir(attachments);
console.log(util.inspect(attachments, false, null, true /* enable colors */));
console.log('&&&&');
const arr = attachments; const arr = attachments;
for (const att of arr) { for (const att of arr) {
if (Array.isArray(att.actions)) if (Array.isArray(att.actions))
for (const attaction of att.actions) { for (const attaction of att.actions) {
if (attaction.integration.item !== undefined) { if (attaction.integration.item !== undefined) {
attaction.integration = attaction.integration.item; attaction.integration = attaction.integration.item;
if (Array.isArray(attaction.integration.context.property)) { if (Array.isArray(attaction.integration.context.property)) {
var tmpcontex = {}; var tmpcontex = {};
for (const attactionintegprop of attaction.integration.context.property ) { for (const attactionintegprop of attaction.integration.context.property ) {
Object.assign(tmpcontex, { [attactionintegprop.name] : attactionintegprop.value } ); Object.assign(tmpcontex, { [attactionintegprop.name] : attactionintegprop.value } );
} }
delete attaction.integration.context; delete attaction.integration.context;
attaction.integration.context = tmpcontex; attaction.integration.context = tmpcontex;
} }
} }
} }
}; };
console.log('****111');
console.log(JSON.stringify(arr, null, 4));
console.log('****222');
console.log(JSON.stringify(attachments, null, 4));
console.log('****222aaa');
body.props = { body.props = {
attachments, attachments,
}; };
//console.log('####');
//console.dir(body);
//console.log('####');
console.log('****');
console.log(util.inspect(body, false, null, true /* enable colors */));
//console.dir(body);
//console.log('****111');
//console.log(JSON.stringify(body, null, 4));
console.log('****');
// Add all the other options to the request // Add all the other options to the request
const otherOptions = this.getNodeParameter('otherOptions', i) as IDataObject; const otherOptions = this.getNodeParameter('otherOptions', i) as IDataObject;
Object.assign(body, otherOptions); Object.assign(body, otherOptions);