mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -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 {
|
||||
subscriptions?: [{}];
|
||||
subscriptions?: string;
|
||||
invite_only?: boolean;
|
||||
principals?: string[];
|
||||
principals?: string;
|
||||
authorization_errors_fatal?: boolean;
|
||||
history_public_to_subscribers?: boolean;
|
||||
stream_post_policy?: number;
|
||||
|
@ -16,5 +16,12 @@ export interface IStream {
|
|||
new_name?: string;
|
||||
is_private?: 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',
|
||||
name: 'fullName',
|
||||
name: 'shortName',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
|
|
|
@ -23,7 +23,7 @@ import {
|
|||
import { snakeCase } from 'change-case';
|
||||
import { streamFields, streamOperations } from './StreamDescription';
|
||||
import { userOperations, userFields } from './UserDescription';
|
||||
import { IStream } from './StreamInterface';
|
||||
import { IStream, ISubscription, IPrincipal } from './StreamInterface';
|
||||
import { validateJSON } from './GenericFunctions';
|
||||
import { IUser } from './UserInterface';
|
||||
|
||||
|
@ -283,14 +283,18 @@ export class Zulip implements INodeType {
|
|||
|
||||
if (additionalFields.subscriptions) {
|
||||
//@ts-ignore
|
||||
body.subscriptions = additionalFields.subscriptions.properties as [{}];
|
||||
body.subscriptions = JSON.stringify(additionalFields.subscriptions.properties);
|
||||
}
|
||||
if (additionalFields.inviteOnly) {
|
||||
body.invite_only = additionalFields.inviteOnly as boolean;
|
||||
}
|
||||
if (additionalFields.principals) {
|
||||
const principals : string[] = [];
|
||||
//@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) {
|
||||
body.authorization_errors_fatal = additionalFields.authorizationErrorsFatal as boolean;
|
||||
|
@ -312,7 +316,7 @@ export class Zulip implements INodeType {
|
|||
if (operation === 'delete') {
|
||||
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') {
|
||||
|
@ -430,9 +434,18 @@ export class Zulip implements INodeType {
|
|||
responseData = await zulipApiRequest.call(this, 'DELETE', `/users/${userId}`, body);
|
||||
}
|
||||
}
|
||||
if (Array.isArray(responseData)) {
|
||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||
} else {
|
||||
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 {
|
||||
returnData.push(responseData as IDataObject);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue