1
1
mirror of https://github.com/n8n-io/n8n.git synced 2024-11-13 05:35:28 +03:00

Minor Zulip-Node fixes

This commit is contained in:
Jan Oberhauser 2020-02-27 23:27:21 +01:00
parent a7845c92df
commit a46b050b15
3 changed files with 7 additions and 7 deletions

View File

@ -3,7 +3,6 @@ import { OptionsWithUri } from 'request';
import {
IExecuteFunctions,
ILoadOptionsFunctions,
BINARY_ENCODING
} from 'n8n-core';
import {
@ -20,14 +19,15 @@ export async function zulipApiRequest(this: IExecuteFunctions | IWebhookFunction
throw new Error('No credentials got returned!');
}
const base64Credentials = `${Buffer.from(`${credentials.email}:${credentials.apiKey}`).toString(BINARY_ENCODING)}`;
const endpoint = `${credentials.url}/api/v1`;
let options: OptionsWithUri = {
auth: {
user: credentials.email as string,
password: credentials.apiKey as string,
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
Authorization: `Basic ${base64Credentials}`,
},
method,
form: body,
@ -46,7 +46,7 @@ export async function zulipApiRequest(this: IExecuteFunctions | IWebhookFunction
return await this.helpers.request!(options);
} catch (error) {
if (error.response) {
let errorMessage = error.response.body.message || error.response.body.description || error.message;
const errorMessage = error.response.body.message || error.response.body.description || error.message;
throw new Error(`Zulip error response [${error.statusCode}]: ${errorMessage}`);
}
throw error;

View File

@ -1,6 +1,6 @@
export interface IMessage {
type?: string;
to?: string,
to?: string;
topic?: string;
content?: string;
propagat_mode?: string;

View File

@ -195,7 +195,7 @@ export class Zulip implements INodeType {
contentType: items[i].binary[binaryProperty].mimeType,
}
}
}
};
responseData = await zulipApiRequest.call(this, 'POST', '/user_uploads', {}, {}, undefined, { formData } );
responseData.uri = `${credentials!.url}${responseData.uri}`;
}