Skip to content

Commit

Permalink
Adding blocks to slack message update
Browse files Browse the repository at this point in the history
  • Loading branch information
mjquinlan2000 committed Nov 15, 2021
1 parent 0022c7e commit 81ee1fd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
23 changes: 22 additions & 1 deletion packages/nodes-base/nodes/Slack/MessageDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ export const messageFields = [
displayName: 'Text',
name: 'text',
type: 'string',
required: true,
required: false,
default: '',
displayOptions: {
show: {
Expand Down Expand Up @@ -566,6 +566,27 @@ export const messageFields = [
},
],
},
{
displayName: 'Blocks',
name: 'blocksJson',
type: 'json',
default: '',
required: false,
typeOptions: {
alwaysOpenEditWindow: true,
},
displayOptions: {
show: {
resource: [
'message',
],
operation: [
'update',
]
},
},
description: 'The blocks to add',
},
{
displayName: 'Blocks',
name: 'blocksUi',
Expand Down
7 changes: 7 additions & 0 deletions packages/nodes-base/nodes/Slack/Slack.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,14 @@ export class Slack implements INodeType {
}
}
body['attachments'] = attachments;
const blocksJson = this.getNodeParameter('blocksJson', i, []) as string;

if (blocksJson !== '' && validateJSON(blocksJson) === undefined) {
throw new NodeOperationError(this.getNode(), 'Blocks it is not a valid json');
}
if (blocksJson !== '') {
body.blocks = blocksJson;
}
// Add all the other options to the request
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
Object.assign(body, updateFields);
Expand Down

0 comments on commit 81ee1fd

Please sign in to comment.