mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
⚡ Fix some issues with Zulip
This commit is contained in:
parent
5e4fde6c6a
commit
b445eafccd
|
@ -62,4 +62,3 @@ export function validateJSON(json: string | undefined): any { // tslint:disable-
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,11 +33,11 @@ export const streamOperations = [
|
||||||
value: 'getSubscribed',
|
value: 'getSubscribed',
|
||||||
description: 'Get subscribed streams.',
|
description: 'Get subscribed streams.',
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
name: 'Update',
|
// name: 'Update',
|
||||||
value: 'update',
|
// value: 'update',
|
||||||
description: 'Update a stream.',
|
// description: 'Update a stream.',
|
||||||
},
|
// },
|
||||||
],
|
],
|
||||||
default: 'create',
|
default: 'create',
|
||||||
description: 'The operation to perform.',
|
description: 'The operation to perform.',
|
||||||
|
@ -86,9 +86,56 @@ export const streamFields = [
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
description: `JSON format parameters for stream creation.`,
|
description: `JSON format parameters for stream creation.`,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Subscriptions',
|
||||||
|
name: 'subscriptions',
|
||||||
|
type: 'fixedCollection',
|
||||||
|
default: {},
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'stream',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'create',
|
||||||
|
],
|
||||||
|
jsonParameters: [
|
||||||
|
false,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
required: true,
|
||||||
|
description: 'A list of dictionaries containing the the key name and value specifying the name of the stream to subscribe. If the stream does not exist a new stream is created.',
|
||||||
|
typeOptions: {
|
||||||
|
multipleValues: true,
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
displayName: 'Subscription Properties',
|
||||||
|
name: 'properties',
|
||||||
|
values: [
|
||||||
|
{
|
||||||
|
displayName: 'Name',
|
||||||
|
name: 'name',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
default: '',
|
||||||
|
description: 'Name of Subscription.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Description',
|
||||||
|
name: 'description',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
default: '',
|
||||||
|
description: 'Description of Subscription.',
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Additional Fields',
|
displayName: 'Additional Fields',
|
||||||
name: 'additionalFields',
|
name: 'additionalFields',
|
||||||
|
@ -141,6 +188,7 @@ export const streamFields = [
|
||||||
displayName: 'Principals',
|
displayName: 'Principals',
|
||||||
name: 'principals',
|
name: 'principals',
|
||||||
type: 'fixedCollection',
|
type: 'fixedCollection',
|
||||||
|
default: {},
|
||||||
description: 'A list of email addresses of the users that will be subscribed/unsubscribed to the streams specified in the subscriptions argument. If not provided, then the requesting user/bot is subscribed.',
|
description: 'A list of email addresses of the users that will be subscribed/unsubscribed to the streams specified in the subscriptions argument. If not provided, then the requesting user/bot is subscribed.',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
multipleValues: true,
|
multipleValues: true,
|
||||||
|
@ -162,40 +210,6 @@ export const streamFields = [
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
displayName: 'Subscriptions',
|
|
||||||
name: 'subscriptions',
|
|
||||||
type: 'fixedCollection',
|
|
||||||
required: true,
|
|
||||||
description: '"A list of dictionaries containing the the key name and value specifying the name of the stream to subscribe. If the stream does not exist a new stream is created.',
|
|
||||||
typeOptions: {
|
|
||||||
multipleValues: true,
|
|
||||||
},
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
displayName: 'Subscription Properties',
|
|
||||||
name: 'properties',
|
|
||||||
values: [
|
|
||||||
{
|
|
||||||
displayName: 'Name',
|
|
||||||
name: 'name',
|
|
||||||
type: 'string',
|
|
||||||
required: true,
|
|
||||||
default: '',
|
|
||||||
description: 'Name of Subscription.',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
displayName: 'Description',
|
|
||||||
name: 'description',
|
|
||||||
type: 'string',
|
|
||||||
required: true,
|
|
||||||
default: '',
|
|
||||||
description: 'Description of Subscription.',
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
displayName: 'Stream Post Policy',
|
displayName: 'Stream Post Policy',
|
||||||
name: 'streamPostPolicy',
|
name: 'streamPostPolicy',
|
||||||
|
@ -222,6 +236,7 @@ export const streamFields = [
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* stream:get all */
|
/* stream:get all */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
@ -279,6 +294,7 @@ export const streamFields = [
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* stream:get subscribed */
|
/* stream:get subscribed */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
@ -308,6 +324,7 @@ export const streamFields = [
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* stream:update */
|
/* stream:update */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
|
@ -33,11 +33,11 @@ export const userOperations = [
|
||||||
value: 'getAll',
|
value: 'getAll',
|
||||||
description: 'Get all users.',
|
description: 'Get all users.',
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
name: 'Update',
|
// name: 'Update',
|
||||||
value: 'update',
|
// value: 'update',
|
||||||
description: 'Update a user.',
|
// description: 'Update a user.',
|
||||||
},
|
// },
|
||||||
],
|
],
|
||||||
default: 'create',
|
default: 'create',
|
||||||
description: 'The operation to perform.',
|
description: 'The operation to perform.',
|
||||||
|
@ -120,6 +120,7 @@ export const userFields = [
|
||||||
default: '',
|
default: '',
|
||||||
description: 'The short name of the new user. Not user-visible.',
|
description: 'The short name of the new user. Not user-visible.',
|
||||||
},
|
},
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* user:get / getAll */
|
/* user:get / getAll */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
@ -174,6 +175,7 @@ export const userFields = [
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* user:update */
|
/* user:update */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
@ -237,6 +239,7 @@ export const userFields = [
|
||||||
displayName: 'Profile Data',
|
displayName: 'Profile Data',
|
||||||
name: 'profileData',
|
name: 'profileData',
|
||||||
type: 'fixedCollection',
|
type: 'fixedCollection',
|
||||||
|
default: {},
|
||||||
description: 'A dictionary containing the to be updated custom profile field data for the user.',
|
description: 'A dictionary containing the to be updated custom profile field data for the user.',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
multipleValues: true,
|
multipleValues: true,
|
||||||
|
@ -267,6 +270,7 @@ export const userFields = [
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* user:deactivate */
|
/* user:deactivate */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
|
@ -247,6 +247,7 @@ export class Zulip implements INodeType {
|
||||||
}
|
}
|
||||||
|
|
||||||
responseData = await zulipApiRequest.call(this, 'GET', `/streams`, body);
|
responseData = await zulipApiRequest.call(this, 'GET', `/streams`, body);
|
||||||
|
responseData = responseData.streams;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operation === 'getSubscribed') {
|
if (operation === 'getSubscribed') {
|
||||||
|
@ -257,10 +258,10 @@ export class Zulip implements INodeType {
|
||||||
}
|
}
|
||||||
|
|
||||||
responseData = await zulipApiRequest.call(this, 'GET', `/users/me/subscriptions`, body);
|
responseData = await zulipApiRequest.call(this, 'GET', `/users/me/subscriptions`, body);
|
||||||
|
responseData = responseData.subscriptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operation === 'create') {
|
if (operation === 'create') {
|
||||||
|
|
||||||
const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean;
|
const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean;
|
||||||
|
|
||||||
if (jsonParameters) {
|
if (jsonParameters) {
|
||||||
|
@ -278,13 +279,11 @@ export class Zulip implements INodeType {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||||
|
|
||||||
if (additionalFields.subscriptions) {
|
const subscriptions = this.getNodeParameter('subscriptions', i) as IDataObject;
|
||||||
//@ts-ignore
|
body.subscriptions = JSON.stringify(subscriptions.properties);
|
||||||
body.subscriptions = JSON.stringify(additionalFields.subscriptions.properties);
|
|
||||||
}
|
|
||||||
if (additionalFields.inviteOnly) {
|
if (additionalFields.inviteOnly) {
|
||||||
body.invite_only = additionalFields.inviteOnly as boolean;
|
body.invite_only = additionalFields.inviteOnly as boolean;
|
||||||
}
|
}
|
||||||
|
@ -396,6 +395,7 @@ export class Zulip implements INodeType {
|
||||||
}
|
}
|
||||||
|
|
||||||
responseData = await zulipApiRequest.call(this, 'GET', `/users`, body);
|
responseData = await zulipApiRequest.call(this, 'GET', `/users`, body);
|
||||||
|
responseData = responseData.members;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operation === 'create') {
|
if (operation === 'create') {
|
||||||
|
@ -434,19 +434,10 @@ export class Zulip implements INodeType {
|
||||||
responseData = await zulipApiRequest.call(this, 'DELETE', `/users/${userId}`, body);
|
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) {
|
if (Array.isArray(responseData)) {
|
||||||
returnData.push.apply(returnData, responseData.streams as IDataObject[]);
|
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||||
}
|
} else {
|
||||||
|
|
||||||
if (responseData.subscriptions) {
|
|
||||||
returnData.push.apply(returnData, responseData.subscriptions as IDataObject[]);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
returnData.push(responseData as IDataObject);
|
returnData.push(responseData as IDataObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue