n8n/packages/nodes-base/nodes/Cisco/Webex/CiscoWebexTrigger.node.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

605 lines
14 KiB
TypeScript
Raw Normal View History

import { createHmac } from 'crypto';
import type {
IHookFunctions,
IWebhookFunctions,
IDataObject,
INodeType,
INodeTypeDescription,
IWebhookResponseData,
} from 'n8n-workflow';
import {
getAutomaticSecret,
getEvents,
mapResource,
webexApiRequest,
webexApiRequestAllItems,
} from './GenericFunctions';
export class CiscoWebexTrigger implements INodeType {
description: INodeTypeDescription = {
displayName: 'Webex by Cisco Trigger',
name: 'ciscoWebexTrigger',
refactor: Apply more `eslint-plugin-n8n-nodes-base` rules (#3534) * :zap: Update `lintfix` script * :zap: Run baseline `lintfix` * :fire: Remove unneeded exceptions (#3538) * :fire: Remove exceptions for `node-param-default-wrong-for-simplify` * :fire: Remove exceptions for `node-param-placeholder-miscased-id` * :zap: Update version * :shirt: Apply `node-param-placeholder-missing` (#3542) * :shirt: Apply `filesystem-wrong-cred-filename` (#3543) * :shirt: Apply `node-param-description-missing-from-dynamic-options` (#3545) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-class-description-empty-string` (#3546) * :shirt: Apply `node-class-description-icon-not-svg` (#3548) * :shirt: Apply `filesystem-wrong-node-filename` (#3549) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Expand lintings to credentials (#3550) * :shirt: Apply `node-param-multi-options-type-unsorted-items` (#3552) * :zap: fix * :zap: Minor fixes Co-authored-by: Michael Kret <michael.k@radency.com> * :shirt: Apply `node-param-description-wrong-for-dynamic-multi-options` (#3541) * :zap: Add new lint rule, node-param-description-wrong-for-dynamic-multi-options * :zap: Fix with updated linting rules * :zap: Minor fixes Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-description-boolean-without-whether` (#3553) * :zap: fix * Update packages/nodes-base/nodes/Clockify/ProjectDescription.ts Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply node-param-display-name-wrong-for-dynamic-multi-options (#3537) * :shirt: Add exceptions * :shirt: Add exception * :pencil2: Alphabetize rules * :zap: Restore `lintfix` command Co-authored-by: agobrech <45268029+agobrech@users.noreply.github.com> Co-authored-by: Omar Ajoue <krynble@gmail.com> Co-authored-by: Michael Kret <michael.k@radency.com> Co-authored-by: brianinoa <54530642+brianinoa@users.noreply.github.com> Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com>
2022-06-20 07:54:01 -07:00
// eslint-disable-next-line n8n-nodes-base/node-class-description-icon-not-svg
2021-08-05 10:06:28 -07:00
icon: 'file:ciscoWebex.png',
group: ['trigger'],
version: 1,
subtitle: '={{$parameter["resource"] + ":" + $parameter["event"]}}',
description: 'Starts the workflow when Cisco Webex events occur.',
defaults: {
feat(editor): Node creator actions (#4696) * WIP: Node Actions List UI * WIP: Recommended Actions and preseting of fields * WIP: Resource category * :art: Moved actions categorisation to the server * :label: Add missing INodeAction type * :sparkles: Improve SSR categorisation, fix adding of mixed actions * :recycle: Refactor CategorizedItems to composition api, style fixes * WIP: Adding multiple nodes * :recycle: Refactor rest of the NodeCreator component to composition API, conver globalLinkActions to composable * :sparkles: Allow actions dragging, fix search and refactor passing of actions to categorized items * :lipstick: Fix node actions title * Migrate to the pinia store, add posthog feature and various fixes * :bug: Fix filtering of trigger actions when not merged * fix: N8N-5439 — Do not use simple node item when at NodeHelperPanel root * :bug: Design review fixes * :bug: Fix disabling of merged actions * Fix trigger root filtering * :sparkles: Allow for custom node actions parser, introduce hubspot parser * :bug: Fix initial node params validation, fix position of second added node * :bug: Introduce operations category, removed canvas node names overrride, fix API actions display and prevent dragging of action nodes * :sparkles: Prevent NDV auto-open feature flag * :bug: Inject recommened action for trigger nodes without actions * Refactored NodeCreatorNode to Storybook, change filtering of merged nodes for the trigger helper panel, minor fixes * Improve rendering of app nodes and animation * Cleanup, any only enable accordion transition on triggerhelperpanel * Hide node creator scrollbars in Firefox * Minor styles fixes * Do not copy the array in rendering method * Removed unused props * Fix memory leak * Fix categorisation of regular nodes with a single resource * Implement telemetry calls for node actions * Move categorization to FE * Fix client side actions categorisation * Skip custom action show * Only load tooltip for NodeIcon if necessary * Fix lodash startCase import * Remove lodash.startcase * Cleanup * Fix node creator autofocus on "tab" * Prevent posthog getFeatureFlag from crashing * Debugging preview env search issues * Remove logs * Make sure the pre-filled params are update not overwritten * Get rid of transition in itemiterator * WIP: Rough version of NodeActions keyboard navigation, replace nodeCreator composable with Pinia store module * Rewrite to add support for ActionItem to ItemIterator and make CategorizedItems accept items props * Fix category item counter & cleanup * Add APIHint to actions search no-result, clean up NodeCreatorNode * Improve node actions no results message * Remove logging, fix filtering of recommended placeholder category * Remove unused NodeActions component and node merging feature falg * Do not show regular nodes without actions * Make sure to add manual trigger when adding http node via actions hint * Fixed api hint footer line height * Prevent pointer-events od NodeIcon img and remove "this" from template * Address PR points * Fix e2e specs * Make sure canvas ia loaded * Make sure canvas ia loaded before opening nodeCreator in e2e spec * Fix flaky workflows tags e2e getter * Imrpove node creator click outside UX, add manual node to regular nodes added from trigger panel * Add manual trigger node if dragging regular from trigger panel
2022-12-09 01:56:36 -08:00
name: 'Webex by Cisco Trigger',
},
inputs: [],
outputs: ['main'],
credentials: [
{
name: 'ciscoWebexOAuth2Api',
required: true,
},
],
webhooks: [
{
name: 'default',
httpMethod: 'POST',
responseMode: 'onReceived',
path: 'webhook',
},
],
properties: [
{
displayName: 'Resource',
name: 'resource',
type: 'options',
refactor: Apply more nodelinting rules (#3324) * :pencil2: Alphabetize lint rules * :fire: Remove duplicates * :zap: Update `lintfix` script * :shirt: Apply `node-param-operation-without-no-data-expression` (#3329) * :shirt: Apply `node-param-operation-without-no-data-expression` * :shirt: Add exceptions * :shirt: Apply `node-param-description-weak` (#3328) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-value-duplicate` (#3331) * :shirt: Apply `node-param-description-miscased-json` (#3337) * :shirt: Apply `node-param-display-name-excess-inner-whitespace` (#3335) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-type-options-missing-from-limit` (#3336) * Rule workig as intended * :pencil2: Uncomment rules Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-name-duplicate` (#3338) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-description-wrong-for-simplify` (#3334) * :zap: fix * :zap: exceptions * :zap: changed rule ignoring from file to line * :shirt: Apply `node-param-resource-without-no-data-expression` (#3339) * :shirt: Apply `node-param-display-name-untrimmed` (#3341) * :shirt: Apply `node-param-display-name-miscased-id` (#3340) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-resource-with-plural-option` (#3342) * :shirt: Apply `node-param-description-wrong-for-upsert` (#3333) * :zap: fix * :zap: replaced record with contact in description * :zap: fix Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-description-identical-to-name` (#3343) * :shirt: Apply `node-param-option-name-containing-star` (#3347) * :shirt: Apply `node-param-display-name-wrong-for-update-fields` (#3348) * :shirt: Apply `node-param-option-name-wrong-for-get-all` (#3345) * :zap: fix * :zap: exceptions * :shirt: Apply node-param-display-name-wrong-for-simplify (#3344) * Rule working as intended * Uncomented other rules * :shirt: Undo and add exceptions Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :zap: Alphabetize lint rules * :zap: Restore `lintfix` script Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com> Co-authored-by: agobrech <45268029+agobrech@users.noreply.github.com>
2022-05-20 14:47:24 -07:00
noDataExpression: true,
options: [
refactor: Apply more `eslint-plugin-n8n-nodes-base` autofixable rules (#3432) * :zap: Update `lintfix` script * :shirt: Remove unneeded lint exceptions * :shirt: Run baseline `lintfix` * :shirt: Apply `node-param-description-miscased-url` (#3441) * :shirt: Apply `rule node-param-placeholder-miscased-id` (#3443) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-name-wrong-for-upsert` (#3446) * :shirt: Apply `node-param-min-value-wrong-for-limit` (#3442) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * Apply `node-param-display-name-wrong-for-dynamic-options` (#3454) * :hammer: fix * :zap: Fix `Assigned To` fields Co-authored-by: Michael Kret <michael.k@radency.com> * :shirt: Apply `rule node-param-default-wrong-for-number` (#3453) * :shirt: Apply `node-param-default-wrong-for-string` (#3452) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * Apply `node-param-display-name-miscased` (#3449) * :hammer: fix * :hammer: exceptions * :zap: review fixes * :shirt: Apply `node-param-description-lowercase-first-char` (#3451) * :zap: fix * :zap: review fixes * :zap: fix Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-description-wrong-for-dynamic-options` (#3456) * Rule working as intended * Add rule * :fire: Remove repetitions * :shirt: Add exceptions Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Small fix for `node-param-description-wrong-for-dynamic-options` * :shirt: Apply `node-param-default-wrong-for-fixed-collection` (#3460) * :shirt: Apply `node-param-description-line-break-html-tag` (#3462) * :shirt: Run baseline `lintfix` * :shirt: Apply `node-param-options-type-unsorted-items` (#3459) * :zap: fix * :hammer: exceptions * Add exception for Salesmate and Zoom Co-authored-by: Michael Kret <michael.k@radency.com> Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :zap: Restore `lintfix` command Co-authored-by: Omar Ajoue <krynble@gmail.com> Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com> Co-authored-by: agobrech <45268029+agobrech@users.noreply.github.com> Co-authored-by: Michael Kret <michael.k@radency.com> Co-authored-by: brianinoa <54530642+brianinoa@users.noreply.github.com>
2022-06-03 10:23:49 -07:00
{
name: '[All]',
value: 'all',
},
{
name: 'Attachment Action',
value: 'attachmentAction',
},
{
name: 'Meeting',
value: 'meeting',
},
{
name: 'Membership',
value: 'membership',
},
{
name: 'Message',
value: 'message',
},
// {
// name: 'Telephony Call',
// value: 'telephonyCall',
// },
{
name: 'Recording',
value: 'recording',
},
{
name: 'Room',
value: 'room',
},
],
default: 'meeting',
required: true,
},
...getEvents(),
{
displayName: 'Resolve Data',
name: 'resolveData',
type: 'boolean',
displayOptions: {
show: {
resource: ['attachmentAction'],
},
},
default: true,
refactor: Apply more `eslint-plugin-n8n-nodes-base` rules (#3534) * :zap: Update `lintfix` script * :zap: Run baseline `lintfix` * :fire: Remove unneeded exceptions (#3538) * :fire: Remove exceptions for `node-param-default-wrong-for-simplify` * :fire: Remove exceptions for `node-param-placeholder-miscased-id` * :zap: Update version * :shirt: Apply `node-param-placeholder-missing` (#3542) * :shirt: Apply `filesystem-wrong-cred-filename` (#3543) * :shirt: Apply `node-param-description-missing-from-dynamic-options` (#3545) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-class-description-empty-string` (#3546) * :shirt: Apply `node-class-description-icon-not-svg` (#3548) * :shirt: Apply `filesystem-wrong-node-filename` (#3549) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Expand lintings to credentials (#3550) * :shirt: Apply `node-param-multi-options-type-unsorted-items` (#3552) * :zap: fix * :zap: Minor fixes Co-authored-by: Michael Kret <michael.k@radency.com> * :shirt: Apply `node-param-description-wrong-for-dynamic-multi-options` (#3541) * :zap: Add new lint rule, node-param-description-wrong-for-dynamic-multi-options * :zap: Fix with updated linting rules * :zap: Minor fixes Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-description-boolean-without-whether` (#3553) * :zap: fix * Update packages/nodes-base/nodes/Clockify/ProjectDescription.ts Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply node-param-display-name-wrong-for-dynamic-multi-options (#3537) * :shirt: Add exceptions * :shirt: Add exception * :pencil2: Alphabetize rules * :zap: Restore `lintfix` command Co-authored-by: agobrech <45268029+agobrech@users.noreply.github.com> Co-authored-by: Omar Ajoue <krynble@gmail.com> Co-authored-by: Michael Kret <michael.k@radency.com> Co-authored-by: brianinoa <54530642+brianinoa@users.noreply.github.com> Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com>
2022-06-20 07:54:01 -07:00
// eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether
description:
'By default the response only contain a reference to the data the user inputed. If this option gets activated, it will resolve the data automatically.',
},
{
displayName: 'Filters',
name: 'filters',
type: 'collection',
placeholder: 'Add Filter',
default: {},
options: [
{
displayName: 'Has Files',
name: 'hasFiles',
type: 'boolean',
displayOptions: {
show: {
'/resource': ['message'],
'/event': ['created', 'deleted'],
},
},
default: false,
refactor: Apply more `eslint-plugin-n8n-nodes-base` rules (#3534) * :zap: Update `lintfix` script * :zap: Run baseline `lintfix` * :fire: Remove unneeded exceptions (#3538) * :fire: Remove exceptions for `node-param-default-wrong-for-simplify` * :fire: Remove exceptions for `node-param-placeholder-miscased-id` * :zap: Update version * :shirt: Apply `node-param-placeholder-missing` (#3542) * :shirt: Apply `filesystem-wrong-cred-filename` (#3543) * :shirt: Apply `node-param-description-missing-from-dynamic-options` (#3545) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-class-description-empty-string` (#3546) * :shirt: Apply `node-class-description-icon-not-svg` (#3548) * :shirt: Apply `filesystem-wrong-node-filename` (#3549) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Expand lintings to credentials (#3550) * :shirt: Apply `node-param-multi-options-type-unsorted-items` (#3552) * :zap: fix * :zap: Minor fixes Co-authored-by: Michael Kret <michael.k@radency.com> * :shirt: Apply `node-param-description-wrong-for-dynamic-multi-options` (#3541) * :zap: Add new lint rule, node-param-description-wrong-for-dynamic-multi-options * :zap: Fix with updated linting rules * :zap: Minor fixes Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-description-boolean-without-whether` (#3553) * :zap: fix * Update packages/nodes-base/nodes/Clockify/ProjectDescription.ts Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply node-param-display-name-wrong-for-dynamic-multi-options (#3537) * :shirt: Add exceptions * :shirt: Add exception * :pencil2: Alphabetize rules * :zap: Restore `lintfix` command Co-authored-by: agobrech <45268029+agobrech@users.noreply.github.com> Co-authored-by: Omar Ajoue <krynble@gmail.com> Co-authored-by: Michael Kret <michael.k@radency.com> Co-authored-by: brianinoa <54530642+brianinoa@users.noreply.github.com> Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com>
2022-06-20 07:54:01 -07:00
description: 'Whether to limit to messages which contain file content attachments',
},
{
displayName: 'Is Locked',
name: 'isLocked',
type: 'boolean',
displayOptions: {
show: {
'/resource': ['room'],
'/event': ['created', 'updated'],
},
},
default: false,
refactor: Apply more `eslint-plugin-n8n-nodes-base` rules (#3534) * :zap: Update `lintfix` script * :zap: Run baseline `lintfix` * :fire: Remove unneeded exceptions (#3538) * :fire: Remove exceptions for `node-param-default-wrong-for-simplify` * :fire: Remove exceptions for `node-param-placeholder-miscased-id` * :zap: Update version * :shirt: Apply `node-param-placeholder-missing` (#3542) * :shirt: Apply `filesystem-wrong-cred-filename` (#3543) * :shirt: Apply `node-param-description-missing-from-dynamic-options` (#3545) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-class-description-empty-string` (#3546) * :shirt: Apply `node-class-description-icon-not-svg` (#3548) * :shirt: Apply `filesystem-wrong-node-filename` (#3549) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Expand lintings to credentials (#3550) * :shirt: Apply `node-param-multi-options-type-unsorted-items` (#3552) * :zap: fix * :zap: Minor fixes Co-authored-by: Michael Kret <michael.k@radency.com> * :shirt: Apply `node-param-description-wrong-for-dynamic-multi-options` (#3541) * :zap: Add new lint rule, node-param-description-wrong-for-dynamic-multi-options * :zap: Fix with updated linting rules * :zap: Minor fixes Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-description-boolean-without-whether` (#3553) * :zap: fix * Update packages/nodes-base/nodes/Clockify/ProjectDescription.ts Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply node-param-display-name-wrong-for-dynamic-multi-options (#3537) * :shirt: Add exceptions * :shirt: Add exception * :pencil2: Alphabetize rules * :zap: Restore `lintfix` command Co-authored-by: agobrech <45268029+agobrech@users.noreply.github.com> Co-authored-by: Omar Ajoue <krynble@gmail.com> Co-authored-by: Michael Kret <michael.k@radency.com> Co-authored-by: brianinoa <54530642+brianinoa@users.noreply.github.com> Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com>
2022-06-20 07:54:01 -07:00
description: 'Whether to limit to rooms that are locked',
},
{
displayName: 'Is Moderator',
name: 'isModerator',
type: 'boolean',
displayOptions: {
show: {
'/resource': ['membership'],
'/event': ['created', 'updated', 'deleted'],
},
},
default: false,
refactor: Apply more `eslint-plugin-n8n-nodes-base` rules (#3534) * :zap: Update `lintfix` script * :zap: Run baseline `lintfix` * :fire: Remove unneeded exceptions (#3538) * :fire: Remove exceptions for `node-param-default-wrong-for-simplify` * :fire: Remove exceptions for `node-param-placeholder-miscased-id` * :zap: Update version * :shirt: Apply `node-param-placeholder-missing` (#3542) * :shirt: Apply `filesystem-wrong-cred-filename` (#3543) * :shirt: Apply `node-param-description-missing-from-dynamic-options` (#3545) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-class-description-empty-string` (#3546) * :shirt: Apply `node-class-description-icon-not-svg` (#3548) * :shirt: Apply `filesystem-wrong-node-filename` (#3549) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Expand lintings to credentials (#3550) * :shirt: Apply `node-param-multi-options-type-unsorted-items` (#3552) * :zap: fix * :zap: Minor fixes Co-authored-by: Michael Kret <michael.k@radency.com> * :shirt: Apply `node-param-description-wrong-for-dynamic-multi-options` (#3541) * :zap: Add new lint rule, node-param-description-wrong-for-dynamic-multi-options * :zap: Fix with updated linting rules * :zap: Minor fixes Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-description-boolean-without-whether` (#3553) * :zap: fix * Update packages/nodes-base/nodes/Clockify/ProjectDescription.ts Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply node-param-display-name-wrong-for-dynamic-multi-options (#3537) * :shirt: Add exceptions * :shirt: Add exception * :pencil2: Alphabetize rules * :zap: Restore `lintfix` command Co-authored-by: agobrech <45268029+agobrech@users.noreply.github.com> Co-authored-by: Omar Ajoue <krynble@gmail.com> Co-authored-by: Michael Kret <michael.k@radency.com> Co-authored-by: brianinoa <54530642+brianinoa@users.noreply.github.com> Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com>
2022-06-20 07:54:01 -07:00
description: 'Whether to limit to moderators of a room',
},
{
displayName: 'Mentioned People',
name: 'mentionedPeople',
type: 'string',
displayOptions: {
show: {
'/resource': ['message'],
'/event': ['created', 'deleted'],
},
},
default: '',
description:
'Limit to messages which contain these mentioned people, by person ID; accepts me as a shorthand for your own person ID; separate multiple values with commas',
},
{
displayName: 'Message ID',
name: 'messageId',
type: 'string',
displayOptions: {
show: {
'/resource': ['attachmentAction'],
'/event': ['created'],
},
},
default: '',
description: 'Limit to a particular message, by ID',
},
{
displayName: 'Owned By',
name: 'ownedBy',
displayOptions: {
show: {
'/resource': ['meeting'],
},
},
type: 'string',
default: '',
},
{
displayName: 'Person Email',
name: 'personEmail',
type: 'string',
displayOptions: {
show: {
'/resource': ['membership'],
'/event': ['created', 'updated', 'deleted'],
},
},
default: '',
description: 'Limit to a particular person, by email',
},
{
displayName: 'Person Email',
name: 'personEmail',
type: 'string',
displayOptions: {
show: {
'/resource': ['message'],
'/event': ['created', 'deleted'],
},
},
default: '',
description: 'Limit to a particular person, by email',
},
{
displayName: 'Person ID',
name: 'personId',
type: 'string',
displayOptions: {
show: {
'/resource': ['attachmentAction'],
'/event': ['created'],
},
},
default: '',
description: 'Limit to a particular person, by ID',
},
{
displayName: 'Person ID',
name: 'personId',
type: 'string',
displayOptions: {
show: {
'/resource': ['membership'],
'/event': ['created', 'updated', 'deleted'],
},
},
default: '',
description: 'Limit to a particular person, by ID',
},
{
displayName: 'Person ID',
name: 'personId',
type: 'string',
displayOptions: {
show: {
'/resource': ['message'],
'/event': ['created', 'deleted'],
},
},
default: '',
description: 'Limit to a particular person, by ID',
},
{
displayName: 'Room ID',
name: 'roomId',
type: 'string',
displayOptions: {
show: {
'/resource': ['attachmentAction'],
'/event': ['created'],
},
},
default: '',
description: 'Limit to a particular room, by ID',
},
{
displayName: 'Room ID',
name: 'roomId',
type: 'string',
displayOptions: {
show: {
'/resource': ['membership'],
'/event': ['created', 'updated', 'deleted'],
},
},
default: '',
description: 'Limit to a particular room, by ID',
},
{
displayName: 'Room ID',
name: 'roomId',
type: 'string',
displayOptions: {
show: {
'/resource': ['message'],
'/event': ['created', 'updated'],
},
},
default: '',
description: 'Limit to a particular room, by ID',
},
{
displayName: 'Room Type',
name: 'roomType',
type: 'options',
options: [
{
name: 'Direct',
value: 'direct',
},
{
name: 'Group',
value: 'group',
},
],
displayOptions: {
show: {
'/resource': ['message'],
'/event': ['created', 'deleted'],
},
},
default: '',
description: 'Limit to a particular room type',
},
{
displayName: 'Type',
name: 'type',
type: 'options',
options: [
{
name: 'Direct',
value: 'direct',
},
{
name: 'Group',
value: 'group',
},
],
displayOptions: {
show: {
'/resource': ['room'],
'/event': ['created', 'updated'],
},
},
default: '',
description: 'Limit to a particular room type',
},
// {
// displayName: 'Call Type',
// name: 'callType',
// type: 'options',
// options: [
// {
// name: 'Emergency',
// value: 'emergency',
// },
// {
// name: 'External',
// value: 'external',
// },
// {
// name: 'Location',
// value: 'location',
// },
// {
// name: 'Disconnected',
// value: 'disconnected',
// },
// {
// name: 'Organization',
// value: 'organization',
// },
// {
// name: 'Other',
// value: 'other',
// },
// {
// name: 'Repair',
// value: 'repair',
// },
// ],
// displayOptions: {
// show: {
// '/resource': [
// 'telephonyCall',
// ],
// '/event': [
// 'created',
// 'deleted',
// 'updated',
// ],
// },
// },
// default: '',
// description: `Limit to a particular call type`,
// },
// {
// displayName: 'Person ID',
// name: 'personId',
// type: 'string',
// displayOptions: {
// show: {
// '/resource': [
// 'telephonyCall',
// ],
// '/event': [
// 'created',
// 'deleted',
// 'updated',
// ],
// },
// },
// default: '',
// description: 'Limit to a particular person, by ID',
// },
// {
// displayName: 'Personality',
// name: 'personality',
// type: 'options',
// options: [
// {
// name: 'Click To Dial',
// value: 'clickToDial',
// },
// {
// name: 'Originator',
// value: 'originator',
// },
// {
// name: 'Terminator',
// value: 'terminator',
// },
// ],
// displayOptions: {
// show: {
// '/resource': [
// 'telephonyCall',
// ],
// '/event': [
// 'created',
// 'deleted',
// 'updated',
// ],
// },
// },
// default: '',
// description: `Limit to a particular call personality`,
// },
// {
// displayName: 'State',
// name: 'state',
// type: 'options',
// options: [
// {
// name: 'Alerting',
// value: 'alerting',
// },
// {
// name: 'Connected',
// value: 'connected',
// },
// {
// name: 'Connecting',
// value: 'connecting',
// },
// {
// name: 'Disconnected',
// value: 'disconnected',
// },
// {
// name: 'Held',
// value: 'held',
// },
// {
// name: 'Remote Held',
// value: 'remoteHeld',
// },
// ],
// displayOptions: {
// show: {
// '/resource': [
// 'telephonyCall',
// ],
// '/event': [
// 'created',
// 'deleted',
// 'updated',
// ],
// },
// },
// default: '',
// description: `Limit to a particular call state`,
// },
],
},
],
};
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {
const webhookUrl = this.getNodeWebhookUrl('default');
const webhookData = this.getWorkflowStaticData('node');
const resource = this.getNodeParameter('resource') as string;
const event = this.getNodeParameter('event') as string;
// Check all the webhooks which exist already if it is identical to the
// one that is supposed to get created.
const data = await webexApiRequestAllItems.call(this, 'items', 'GET', '/webhooks');
for (const webhook of data) {
if (
webhook.url === webhookUrl &&
webhook.resource === mapResource(resource) &&
webhook.event === event &&
webhook.status === 'active'
) {
webhookData.webhookId = webhook.id as string;
return true;
}
}
return false;
},
async create(this: IHookFunctions): Promise<boolean> {
const webhookData = this.getWorkflowStaticData('node');
const webhookUrl = this.getNodeWebhookUrl('default');
const event = this.getNodeParameter('event') as string;
const resource = this.getNodeParameter('resource') as string;
const filters = this.getNodeParameter('filters', {}) as IDataObject;
const credentials = await this.getCredentials('ciscoWebexOAuth2Api');
const secret = getAutomaticSecret(credentials);
const filter = [];
for (const key of Object.keys(filters)) {
if (key !== 'ownedBy') {
filter.push(`${key}=${filters[key]}`);
}
}
const endpoint = '/webhooks';
const body: IDataObject = {
name: `n8n-webhook:${webhookUrl}`,
targetUrl: webhookUrl,
event,
resource: mapResource(resource),
};
if (filters.ownedBy) {
body.ownedBy = filters.ownedBy as string;
}
body.secret = secret;
if (filter.length) {
body.filter = filter.join('&');
}
const responseData = await webexApiRequest.call(this, 'POST', endpoint, body);
if (responseData.id === undefined) {
// Required data is missing so was not successful
return false;
}
webhookData.webhookId = responseData.id as string;
webhookData.secret = secret;
return true;
},
async delete(this: IHookFunctions): Promise<boolean> {
const webhookData = this.getWorkflowStaticData('node');
if (webhookData.webhookId !== undefined) {
const endpoint = `/webhooks/${webhookData.webhookId}`;
try {
await webexApiRequest.call(this, 'DELETE', endpoint);
} catch (error) {
return false;
}
// Remove from the static workflow data so that it is clear
// that no webhooks are registered anymore
delete webhookData.webhookId;
}
return true;
},
},
};
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
let bodyData = this.getBodyData();
const webhookData = this.getWorkflowStaticData('node');
const headers = this.getHeaderData() as IDataObject;
const req = this.getRequestObject();
const resolveData = this.getNodeParameter('resolveData', false) as boolean;
//@ts-ignore
const computedSignature = createHmac('sha1', webhookData.secret)
.update(req.rawBody)
.digest('hex');
if (headers['x-spark-signature'] !== computedSignature) {
return {};
}
if (resolveData) {
const {
data: { id },
} = bodyData as { data: { id: string } };
bodyData = await webexApiRequest.call(this, 'GET', `/attachment/actions/${id}`);
}
return {
workflowData: [this.helpers.returnJsonArray(bodyData)],
};
}
}