Add Slack:getPermalink (#1370)

* Add chat.getPermalink interface in Slack Nodes.

*  Small improvements to #1366

Co-authored-by: tumf <y.takahara@gmail.com>
This commit is contained in:
Jan 2021-01-23 12:18:39 +01:00 committed by GitHub
commit cb5460d3c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 64 additions and 4 deletions

View file

@ -239,14 +239,14 @@ export const fileFields = [
description: 'Show truncated file info for files hidden due to being too old, and the team who owns the file being over the file limit.',
},
{
displayName: 'TS From',
displayName: 'Timestamp From',
name: 'tsFrom',
type: 'string',
default: '',
description: 'Filter files created after this timestamp (inclusive).',
},
{
displayName: 'TS To',
displayName: 'Timestamp To',
name: 'tsTo',
type: 'string',
default: '',

View file

@ -15,6 +15,11 @@ export const messageOperations = [
},
},
options: [
{
name: 'Get Permalink',
value: 'getPermalink',
description: 'Get Permanent Link of a message',
},
{
name: 'Post',
value: 'post',
@ -38,6 +43,49 @@ export const messageOperations = [
export const messageFields = [
/* ----------------------------------------------------------------------- */
/* message:getPermalink
/* ----------------------------------------------------------------------- */
{
displayName: 'Channel',
name: 'channelId',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getChannels',
},
required: true,
default: '',
displayOptions: {
show: {
resource: [
'message',
],
operation: [
'getPermalink',
],
},
},
description: 'Channel containing the message.',
},
{
displayName: 'Timestamp',
name: 'timestamp',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'message',
],
operation: [
'getPermalink',
],
},
},
description: `Timestamp of the message to get permanent link.`,
},
/* -------------------------------------------------------------------------- */
/* message:post/postEphemeral */
/* -------------------------------------------------------------------------- */
@ -1631,4 +1679,5 @@ export const messageFields = [
},
],
},
] as INodeProperties[];

View file

@ -103,14 +103,14 @@ export class Slack implements INodeType {
description: INodeTypeDescription = {
displayName: 'Slack',
name: 'slack',
icon: 'file:slack.png',
icon: 'file:slack.svg',
group: ['output'],
version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Consume Slack API',
defaults: {
name: 'Slack',
color: '#BB2244',
color: '#E01E5A',
},
inputs: ['main'],
outputs: ['main'],
@ -795,6 +795,16 @@ export class Slack implements INodeType {
Object.assign(body, updateFields);
responseData = await slackApiRequest.call(this, 'POST', '/chat.update', body, qs);
}
//https://api.slack.com/methods/chat.getPermalink
if (operation === 'getPermalink') {
const channel = this.getNodeParameter('channelId', i) as string;
const timestamp = this.getNodeParameter('timestamp', i) as string;
const qs = {
channel,
message_ts: timestamp,
};
responseData = await slackApiRequest.call(this, 'GET', '/chat.getPermalink', {}, qs);
}
}
if (resource === 'reaction') {
const channel = this.getNodeParameter('channelId', i) as string;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 150.852 150.852" fill="#fff" fill-rule="evenodd" stroke="#000" stroke-linecap="round" stroke-linejoin="round"><use xlink:href="#A" x=".926" y=".926"/><symbol id="A" overflow="visible"><g stroke-width="1.852"><path d="M40.741 93.55c0-8.735 6.607-15.772 14.815-15.772s14.815 7.037 14.815 15.772v38.824c0 8.737-6.607 15.774-14.815 15.774s-14.815-7.037-14.815-15.772z" fill="#e01e5a" stroke="#e01e5a"/><path d="M93.55 107.408c-8.735 0-15.772-6.607-15.772-14.815s7.037-14.815 15.772-14.815h38.826c8.735 0 15.772 6.607 15.772 14.815s-7.037 14.815-15.772 14.815z" fill="#ecb22d" stroke="#ecb22d"/><path d="M77.778 15.772C77.778 7.037 84.385 0 92.593 0s14.815 7.037 14.815 15.772v38.826c0 8.735-6.607 15.772-14.815 15.772s-14.815-7.037-14.815-15.772z" fill="#2fb67c" stroke="#2fb67c"/><path d="M15.772 70.371C7.037 70.371 0 63.763 0 55.556s7.037-14.815 15.772-14.815h38.826c8.735 0 15.772 6.607 15.772 14.815s-7.037 14.815-15.772 14.815z" fill="#36c5f1" stroke="#36c5f1"/><g stroke-linejoin="miter"><path d="M77.778 133.333c0 8.208 6.607 14.815 14.815 14.815s14.815-6.607 14.815-14.815-6.607-14.815-14.815-14.815H77.778z" fill="#ecb22d" stroke="#ecb22d"/><path d="M133.334 70.371h-14.815V55.556c0-8.207 6.607-14.815 14.815-14.815s14.815 6.607 14.815 14.815-6.607 14.815-14.815 14.815z" fill="#2fb67c" stroke="#2fb67c"/><path d="M14.815 77.778H29.63v14.815c0 8.207-6.607 14.815-14.815 14.815S0 100.8 0 92.593s6.607-14.815 14.815-14.815z" fill="#e01e5a" stroke="#e01e5a"/><path d="M70.371 14.815V29.63H55.556c-8.207 0-14.815-6.607-14.815-14.815S47.348 0 55.556 0s14.815 6.607 14.815 14.815z" fill="#36c5f1" stroke="#36c5f1"/></g></g></symbol></svg>

After

Width:  |  Height:  |  Size: 1.7 KiB