mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
⚡ Minor improvements on Rocketchat Node
This commit is contained in:
parent
4ec458d56b
commit
70d2a988cc
|
@ -1,4 +1,4 @@
|
||||||
import {
|
import {
|
||||||
OptionsWithUri,
|
OptionsWithUri,
|
||||||
} from 'request';
|
} from 'request';
|
||||||
|
|
||||||
|
@ -16,7 +16,11 @@ export async function rocketchatApiRequest(this: IExecuteFunctions | ILoadOption
|
||||||
}
|
}
|
||||||
|
|
||||||
const headerWithAuthentication = Object.assign({}, headers,
|
const headerWithAuthentication = Object.assign({}, headers,
|
||||||
{ 'X-Auth-Token': credentials.authKey, 'X-User-Id': credentials.userId });
|
{
|
||||||
|
'X-Auth-Token': credentials.authKey,
|
||||||
|
'X-User-Id': credentials.userId,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: headerWithAuthentication,
|
headers: headerWithAuthentication,
|
||||||
|
|
|
@ -412,12 +412,12 @@ export class Rocketchat implements INodeType {
|
||||||
const text = this.getNodeParameter('text', i) as string;
|
const text = this.getNodeParameter('text', i) as string;
|
||||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||||
const jsonActive = this.getNodeParameter('jsonParameters', i) as boolean;
|
const jsonActive = this.getNodeParameter('jsonParameters', i) as boolean;
|
||||||
|
|
||||||
const body: IPostMessageBody = {
|
const body: IPostMessageBody = {
|
||||||
channel,
|
channel,
|
||||||
text,
|
text,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (options.alias) {
|
if (options.alias) {
|
||||||
body.alias = options.alias as string;
|
body.alias = options.alias as string;
|
||||||
}
|
}
|
||||||
|
@ -427,7 +427,7 @@ export class Rocketchat implements INodeType {
|
||||||
if (options.emoji) {
|
if (options.emoji) {
|
||||||
body.emoji = options.emoji as string;
|
body.emoji = options.emoji as string;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!jsonActive) {
|
if (!jsonActive) {
|
||||||
const optionsAttachments = this.getNodeParameter('attachments', i) as IDataObject[];
|
const optionsAttachments = this.getNodeParameter('attachments', i) as IDataObject[];
|
||||||
if (optionsAttachments.length > 0) {
|
if (optionsAttachments.length > 0) {
|
||||||
|
@ -493,7 +493,7 @@ export class Rocketchat implements INodeType {
|
||||||
} else {
|
} else {
|
||||||
body.attachments = validateJSON(this.getNodeParameter('attachmentsJson', i) as string);
|
body.attachments = validateJSON(this.getNodeParameter('attachmentsJson', i) as string);
|
||||||
}
|
}
|
||||||
|
|
||||||
responseData = await rocketchatApiRequest.call(this, '/chat', 'POST', 'postMessage', body);
|
responseData = await rocketchatApiRequest.call(this, '/chat', 'POST', 'postMessage', body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue