mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-13 05:47:31 -08:00
Modified returnData display logic, fixed subscription/principal data packing
This commit is contained in:
parent
011c78ad8e
commit
17b6872bc0
|
@ -1,7 +1,7 @@
|
||||||
export interface IStream {
|
export interface IStream {
|
||||||
subscriptions?: [{}];
|
subscriptions?: string;
|
||||||
invite_only?: boolean;
|
invite_only?: boolean;
|
||||||
principals?: string[];
|
principals?: string;
|
||||||
authorization_errors_fatal?: boolean;
|
authorization_errors_fatal?: boolean;
|
||||||
history_public_to_subscribers?: boolean;
|
history_public_to_subscribers?: boolean;
|
||||||
stream_post_policy?: number;
|
stream_post_policy?: number;
|
||||||
|
@ -16,5 +16,12 @@ export interface IStream {
|
||||||
new_name?: string;
|
new_name?: string;
|
||||||
is_private?: boolean;
|
is_private?: boolean;
|
||||||
is_announcement_only?: boolean;
|
is_announcement_only?: boolean;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
export interface ISubscription {
|
||||||
|
[value : string] : string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IPrincipal {
|
||||||
|
email: string;
|
||||||
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ export const userFields = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Short Name',
|
displayName: 'Short Name',
|
||||||
name: 'fullName',
|
name: 'shortName',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
required: true,
|
required: true,
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
|
|
|
@ -23,7 +23,7 @@ import {
|
||||||
import { snakeCase } from 'change-case';
|
import { snakeCase } from 'change-case';
|
||||||
import { streamFields, streamOperations } from './StreamDescription';
|
import { streamFields, streamOperations } from './StreamDescription';
|
||||||
import { userOperations, userFields } from './UserDescription';
|
import { userOperations, userFields } from './UserDescription';
|
||||||
import { IStream } from './StreamInterface';
|
import { IStream, ISubscription, IPrincipal } from './StreamInterface';
|
||||||
import { validateJSON } from './GenericFunctions';
|
import { validateJSON } from './GenericFunctions';
|
||||||
import { IUser } from './UserInterface';
|
import { IUser } from './UserInterface';
|
||||||
|
|
||||||
|
@ -283,14 +283,18 @@ export class Zulip implements INodeType {
|
||||||
|
|
||||||
if (additionalFields.subscriptions) {
|
if (additionalFields.subscriptions) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
body.subscriptions = additionalFields.subscriptions.properties as [{}];
|
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;
|
||||||
}
|
}
|
||||||
if (additionalFields.principals) {
|
if (additionalFields.principals) {
|
||||||
|
const principals : string[] = [];
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
body.principals = additionalFields.principals.properties as string[];
|
additionalFields.principals.properties.map((principal : IPrincipal) => {
|
||||||
|
principals.push(principal.email);
|
||||||
|
});
|
||||||
|
body.principals = JSON.stringify(principals);
|
||||||
}
|
}
|
||||||
if (additionalFields.authorizationErrorsFatal) {
|
if (additionalFields.authorizationErrorsFatal) {
|
||||||
body.authorization_errors_fatal = additionalFields.authorizationErrorsFatal as boolean;
|
body.authorization_errors_fatal = additionalFields.authorizationErrorsFatal as boolean;
|
||||||
|
@ -312,7 +316,7 @@ export class Zulip implements INodeType {
|
||||||
if (operation === 'delete') {
|
if (operation === 'delete') {
|
||||||
const streamId = this.getNodeParameter('streamId', i) as string;
|
const streamId = this.getNodeParameter('streamId', i) as string;
|
||||||
|
|
||||||
responseData = await zulipApiRequest.call(this, 'POST', `/streams/${streamId}`, {});
|
responseData = await zulipApiRequest.call(this, 'DELETE', `/streams/${streamId}`, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operation === 'update') {
|
if (operation === 'update') {
|
||||||
|
@ -430,9 +434,18 @@ export class Zulip implements INodeType {
|
||||||
responseData = await zulipApiRequest.call(this, 'DELETE', `/users/${userId}`, body);
|
responseData = await zulipApiRequest.call(this, 'DELETE', `/users/${userId}`, body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Array.isArray(responseData)) {
|
if (responseData.members) {
|
||||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
returnData.push.apply(returnData, responseData.members as IDataObject[]);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if (responseData.streams) {
|
||||||
|
returnData.push.apply(returnData, responseData.streams as IDataObject[]);
|
||||||
|
}
|
||||||
|
|
||||||
|
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