mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
⚡ Fix some issues with Zulip
This commit is contained in:
@@ -219,7 +219,7 @@ export class Zulip implements INodeType {
|
||||
}
|
||||
}
|
||||
};
|
||||
responseData = await zulipApiRequest.call(this, 'POST', '/user_uploads', {}, {}, undefined, { formData } );
|
||||
responseData = await zulipApiRequest.call(this, 'POST', '/user_uploads', {}, {}, undefined, { formData });
|
||||
responseData.uri = `${credentials!.url}${responseData.uri}`;
|
||||
}
|
||||
}
|
||||
@@ -247,6 +247,7 @@ export class Zulip implements INodeType {
|
||||
}
|
||||
|
||||
responseData = await zulipApiRequest.call(this, 'GET', `/streams`, body);
|
||||
responseData = responseData.streams;
|
||||
}
|
||||
|
||||
if (operation === 'getSubscribed') {
|
||||
@@ -257,10 +258,10 @@ export class Zulip implements INodeType {
|
||||
}
|
||||
|
||||
responseData = await zulipApiRequest.call(this, 'GET', `/users/me/subscriptions`, body);
|
||||
responseData = responseData.subscriptions;
|
||||
}
|
||||
|
||||
if (operation === 'create') {
|
||||
|
||||
const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean;
|
||||
|
||||
if (jsonParameters) {
|
||||
@@ -278,20 +279,18 @@ export class Zulip implements INodeType {
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
|
||||
if (additionalFields.subscriptions) {
|
||||
//@ts-ignore
|
||||
body.subscriptions = JSON.stringify(additionalFields.subscriptions.properties);
|
||||
}
|
||||
const subscriptions = this.getNodeParameter('subscriptions', i) as IDataObject;
|
||||
body.subscriptions = JSON.stringify(subscriptions.properties);
|
||||
|
||||
if (additionalFields.inviteOnly) {
|
||||
body.invite_only = additionalFields.inviteOnly as boolean;
|
||||
}
|
||||
if (additionalFields.principals) {
|
||||
const principals : string[] = [];
|
||||
const principals: string[] = [];
|
||||
//@ts-ignore
|
||||
additionalFields.principals.properties.map((principal : IPrincipal) => {
|
||||
additionalFields.principals.properties.map((principal: IPrincipal) => {
|
||||
principals.push(principal.email);
|
||||
});
|
||||
body.principals = JSON.stringify(principals);
|
||||
@@ -368,7 +367,7 @@ export class Zulip implements INodeType {
|
||||
}
|
||||
|
||||
if (resource === 'user') {
|
||||
const body : IUser = {};
|
||||
const body: IUser = {};
|
||||
|
||||
if (operation === 'get') {
|
||||
const userId = this.getNodeParameter('userId', i) as string;
|
||||
@@ -396,6 +395,7 @@ export class Zulip implements INodeType {
|
||||
}
|
||||
|
||||
responseData = await zulipApiRequest.call(this, 'GET', `/users`, body);
|
||||
responseData = responseData.members;
|
||||
}
|
||||
|
||||
if (operation === 'create') {
|
||||
@@ -407,7 +407,7 @@ export class Zulip implements INodeType {
|
||||
responseData = await zulipApiRequest.call(this, 'POST', `/users`, body);
|
||||
}
|
||||
|
||||
if (operation === 'update') {
|
||||
if (operation === 'update') {
|
||||
const userId = this.getNodeParameter('userId', i) as string;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
|
||||
@@ -434,19 +434,10 @@ export class Zulip implements INodeType {
|
||||
responseData = await zulipApiRequest.call(this, 'DELETE', `/users/${userId}`, body);
|
||||
}
|
||||
}
|
||||
// Specific checks because API returns multiple objects within 1 object with each key name
|
||||
if (responseData.members) {
|
||||
returnData.push.apply(returnData, responseData.members as IDataObject[]);
|
||||
}
|
||||
|
||||
if (responseData.streams) {
|
||||
returnData.push.apply(returnData, responseData.streams as IDataObject[]);
|
||||
}
|
||||
|
||||
if (responseData.subscriptions) {
|
||||
returnData.push.apply(returnData, responseData.subscriptions as IDataObject[]);
|
||||
}
|
||||
else {
|
||||
if (Array.isArray(responseData)) {
|
||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||
} else {
|
||||
returnData.push(responseData as IDataObject);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user