mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
✨ Add binary data support to Telegram Node (#2249)
* ✨ Add binary upload for Telegram * ⚡ Improvements to #2247 Co-authored-by: pemontto <pemontto@gmail.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
BINARY_ENCODING,
|
||||
IExecuteFunctions,
|
||||
IHookFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
@@ -10,7 +11,7 @@ import {
|
||||
} from 'request';
|
||||
|
||||
import {
|
||||
IDataObject, NodeApiError, NodeOperationError,
|
||||
IBinaryData, IDataObject, NodeApiError, NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
// Interface in n8n
|
||||
@@ -142,7 +143,7 @@ export function addAdditionalFields(this: IExecuteFunctions, body: IDataObject,
|
||||
* @param {object} body
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, method: string, endpoint: string, body: object, query?: IDataObject, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, method: string, endpoint: string, body: IDataObject, query?: IDataObject, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = await this.getCredentials('telegramApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
@@ -152,12 +153,11 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa
|
||||
query = query || {};
|
||||
|
||||
const options: OptionsWithUri = {
|
||||
headers: {
|
||||
},
|
||||
headers: {},
|
||||
method,
|
||||
uri: `https://api.telegram.org/bot${credentials.accessToken}/${endpoint}`,
|
||||
body,
|
||||
qs: query,
|
||||
uri: `https://api.telegram.org/bot${credentials.accessToken}/${endpoint}`,
|
||||
json: true,
|
||||
};
|
||||
|
||||
@@ -192,3 +192,7 @@ export function getImageBySize(photos: IDataObject[], size: string): IDataObject
|
||||
|
||||
return photos[index];
|
||||
}
|
||||
|
||||
export function getPropertyName(operation: string) {
|
||||
return operation.replace('send', '').toLowerCase();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user