diff --git a/packages/api/src/generated/graphql.ts b/packages/api/src/generated/graphql.ts index 3e3119db6..e5f8bb85a 100644 --- a/packages/api/src/generated/graphql.ts +++ b/packages/api/src/generated/graphql.ts @@ -2501,6 +2501,7 @@ export enum RuleActionType { AddLabel = 'ADD_LABEL', Archive = 'ARCHIVE', Delete = 'DELETE', + Export = 'EXPORT', MarkAsRead = 'MARK_AS_READ', SendNotification = 'SEND_NOTIFICATION', Webhook = 'WEBHOOK' diff --git a/packages/api/src/generated/schema.graphql b/packages/api/src/generated/schema.graphql index 1782328b8..26684a5c0 100644 --- a/packages/api/src/generated/schema.graphql +++ b/packages/api/src/generated/schema.graphql @@ -1877,6 +1877,7 @@ enum RuleActionType { ADD_LABEL ARCHIVE DELETE + EXPORT MARK_AS_READ SEND_NOTIFICATION WEBHOOK diff --git a/packages/api/src/jobs/trigger_rule.ts b/packages/api/src/jobs/trigger_rule.ts index 550f9cacf..e7f1040cb 100644 --- a/packages/api/src/jobs/trigger_rule.ts +++ b/packages/api/src/jobs/trigger_rule.ts @@ -1,5 +1,6 @@ import { LiqeQuery } from '@omnivore/liqe' import axios from 'axios' +import { Any } from 'typeorm' import { ReadingProgressDataSource } from '../datasources/reading_progress_data_source' import { IntegrationType } from '../entity/integration' import { LibraryItem, LibraryItemState } from '../entity/library_item' @@ -115,7 +116,9 @@ const sendToWebhook = async (obj: RuleActionObj) => { const exportItem = async (obj: RuleActionObj) => { const userId = obj.userId + const integrationNames = obj.action.params const integrations = await findIntegrations(userId, { + name: Any(integrationNames.map((param) => param.toUpperCase())), enabled: true, type: IntegrationType.Export, }) diff --git a/packages/api/src/schema.ts b/packages/api/src/schema.ts index d2279407e..c510e5a5c 100755 --- a/packages/api/src/schema.ts +++ b/packages/api/src/schema.ts @@ -2168,6 +2168,7 @@ const schema = gql` MARK_AS_READ SEND_NOTIFICATION WEBHOOK + EXPORT } type RulesError { diff --git a/packages/api/src/services/integrations/notion.ts b/packages/api/src/services/integrations/notion.ts index c274f062a..fb1667c56 100644 --- a/packages/api/src/services/integrations/notion.ts +++ b/packages/api/src/services/integrations/notion.ts @@ -64,7 +64,7 @@ interface NotionPage { url: string } 'Omnivore ID': { - unique_id: string + url: string } 'Omnivore URL'?: { url: string @@ -231,7 +231,7 @@ export class NotionClient implements IntegrationClient { } : undefined, 'Omnivore ID': { - unique_id: item.id, + url: item.id, }, 'Omnivore URL': item.slug ? { @@ -275,7 +275,10 @@ export class NotionClient implements IntegrationClient { text: { content: highlight.quote || '', link: { - url: getHighlightUrl(item.slug!, highlight.id), + url: getHighlightUrl( + item.slug || item.id, + highlight.id + ), }, }, annotations: { diff --git a/packages/web/lib/networking/queries/useGetRulesQuery.tsx b/packages/web/lib/networking/queries/useGetRulesQuery.tsx index 77b11154d..08dfd35ad 100644 --- a/packages/web/lib/networking/queries/useGetRulesQuery.tsx +++ b/packages/web/lib/networking/queries/useGetRulesQuery.tsx @@ -14,6 +14,7 @@ export enum RuleActionType { Delete = 'DELETE', SendNotification = 'SEND_NOTIFICATION', Webhook = 'WEBHOOK', + Export = 'EXPORT', } export enum RuleEventType { diff --git a/packages/web/pages/settings/rules.tsx b/packages/web/pages/settings/rules.tsx index 7d5be493c..9144114b6 100644 --- a/packages/web/pages/settings/rules.tsx +++ b/packages/web/pages/settings/rules.tsx @@ -132,6 +132,8 @@ const CreateActionModal = (props: CreateActionModalProps): JSX.Element => { params = form.getFieldValue('labels') } else if (actionType == RuleActionType.Webhook) { params = [form.getFieldValue('url')] + } else if (actionType == RuleActionType.Export) { + params = form.getFieldValue('integrations') } if (props.rule) { @@ -229,6 +231,25 @@ const CreateActionModal = (props: CreateActionModalProps): JSX.Element => { )} + + {actionType == RuleActionType.Export && ( + + + + )} )