Move Delete Option from Post to Message

This commit is contained in:
Jan Oberhauser 2019-12-06 22:33:26 +01:00
parent 6f2154aaf8
commit 731aeca5c5

View file

@ -53,10 +53,6 @@ export class Mattermost implements INodeType {
name: 'User',
value: 'user',
},
{
name: 'Post',
value: 'post',
},
],
default: 'message',
description: 'The resource to operate on.',
@ -110,6 +106,11 @@ export class Mattermost implements INodeType {
},
},
options: [
{
name: 'Delete',
value: 'delete',
description: 'Soft deletes a post, by marking the post as deleted in the database.',
},
{
name: 'Post',
value: 'post',
@ -295,6 +296,28 @@ export class Mattermost implements INodeType {
// message
// ----------------------------------
// ----------------------------------
// message:delete
// ----------------------------------
{
displayName: 'Post ID',
name: 'postId',
type: 'string',
required: true,
displayOptions: {
show: {
resource: [
'message',
],
operation: [
'delete',
],
},
},
default: '',
description: 'ID of the post to delete',
},
// ----------------------------------
// message:post
// ----------------------------------
@ -600,51 +623,7 @@ export class Mattermost implements INodeType {
default: '',
description: 'User GUID'
},
// ----------------------------------
// post
// ----------------------------------
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'post',
],
},
},
options: [
{
name: 'Delete',
value: 'delete',
description: 'Soft deletes a post, by marking the post as deleted in the database. Soft deleted posts will not be returned in post queries.',
},
],
default: '',
description: 'The operation to perform.',
},
// ----------------------------------
// post:delete
// ----------------------------------
{
displayName: 'Post ID',
name: 'postId',
type: 'string',
required: true,
displayOptions: {
show: {
resource: [
'post',
],
operation: [
'delete',
],
},
},
default: '',
description: 'ID of the post to delete',
},
],
};
@ -797,7 +776,15 @@ export class Mattermost implements INodeType {
endpoint = `channels/${channelId}/stats`;
}
} else if (resource === 'message') {
if (operation === 'post') {
if (operation === 'delete') {
// ----------------------------------
// message:delete
// ----------------------------------
const postId = this.getNodeParameter('postId', i) as string;
requestMethod = 'DELETE';
endpoint = `posts/${postId}`;
} else if (operation === 'post') {
// ----------------------------------
// message:post
// ----------------------------------
@ -842,15 +829,6 @@ export class Mattermost implements INodeType {
requestMethod = 'DELETE';
endpoint = `users/${userId}`;
}
} else if (resource === 'post') {
if (operation === 'delete') {
// ----------------------------------
// post:delete
// ----------------------------------
const postId = this.getNodeParameter('postId', i) as string;
requestMethod = 'DELETE';
endpoint = `posts/${postId}`;
}
}
else {
throw new Error(`The resource "${resource}" is not known!`);