Skip to content

Conversation

@nevo-david
Copy link
Contributor

@nevo-david nevo-david commented Feb 6, 2025

Webhook feature

Summary by CodeRabbit

  • New Features

    • Introduced comprehensive webhook management, enabling users to add, update, view, and delete webhooks.
    • Updated the settings interface with a popup design that offers streamlined access to features.
  • Enhancements

    • Improved channel management with interactive confirmations and clearer feedback.
    • Refined team management labels for better clarity.
    • Expanded subscription permissions to enforce webhook limits.
    • Applied minor UI adjustments for more consistent presentation across pages.

@vercel
Copy link

vercel bot commented Feb 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
gitroom 🔄 Building (Inspect) Visit Preview 💬 Add feedback Feb 6, 2025 2:16pm
postiz 🔄 Building (Inspect) Visit Preview 💬 Add feedback Feb 6, 2025 2:16pm

@coderabbitai
Copy link

coderabbitai bot commented Feb 6, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request introduces webhook functionality into the system. A new WebhookController is added to the backend API and registered with authentication. The changes extend permission checks to include a new WEBHOOKS section and adjust error messaging. On the frontend, settings and menu components are updated to integrate with webhook features, and new UI components are provided for managing webhooks. Additionally, workers and various libraries are enhanced to support webhook creation, notification (digest and fire), and database schema modifications to store webhook data.

Changes

File(s) Change Summary
apps/backend/.../api.module.ts
apps/backend/.../webhooks.controller.ts
Registered new WebhookController with GET, POST, PUT, DELETE methods for handling webhook HTTP requests.
apps/backend/.../permissions.service.ts
apps/backend/.../subscription.exception.ts
Enhanced permission logic with new WEBHOOKS section and updated error handling (formatting and messaging) for webhook limits.
apps/frontend/.../settings/page.tsx
apps/frontend/.../layout/settings.component.tsx
apps/frontend/.../layout/top.menu.tsx
Replaced SettingsComponent with SettingsPopup, updated settings navigation, and added a hidden "Settings" menu item.
apps/frontend/.../launches/menu.tsx
apps/frontend/.../layout/impersonate.tsx
apps/frontend/.../public-api/public.component.tsx
apps/frontend/.../settings/teams.component.tsx
Refined UI components: updated channel functions with confirmation dialogs and error handling; adjusted heading levels and removed extraneous styling.
apps/frontend/.../webhooks/webhooks.tsx New React components for managing webhooks, including a form component for adding or editing a webhook.
apps/workers/.../posts.controller.ts Injected WebhooksService and added a new event handler method to process webhook events within the posts controller.
libraries/.../database.module.ts
libraries/.../posts/posts.repository.ts
libraries/.../posts/posts.service.ts
libraries/.../schema.prisma
libraries/.../subscriptions/pricing.ts
Updated database module and posts logic: added providers, new repository method (getPostsSince), pricing model extension for webhook limits, and schema modifications to support webhook and integration models.
libraries/.../webhooks/webhooks.repository.ts
libraries/.../webhooks/webhooks.service.ts
libraries/.../webhooks/webhooks.dto.ts
Introduced a new domain for webhooks: added repository and service classes for managing webhooks (creation, deletion, digesting, and firing notifications), plus DTO classes for validation and data transfer.

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant WC as WebhookController
    participant WS as WebhooksService
    participant WR as WebhooksRepository
    participant DB as Database

    C->>WC: POST /webhooks (payload)
    WC->>WS: createAWebhook(org, body)
    WS->>WR: createWebhook(org, body)
    WR->>DB: Upsert webhook record
    DB-->>WR: Confirmation
    WR-->>WS: Return created webhook
    WS-->>WC: Return success response
    WC-->>C: HTTP 200 OK
Loading
sequenceDiagram
    participant P as PostsController
    participant WS as WebhooksService
    participant BQ as BullMqClient
    participant WH as ExternalWebhook

    P->>WS: webhooks(data: {org, since})
    WS->>BQ: Schedule digest/webhook job
    loop For each webhook
       WS->>WH: POST notification with filtered posts
       WH-->>WS: Acknowledgement (or error logged)
    end
Loading

Possibly related PRs

  • Public API #490: Introduced changes in WebhookController similar to modifications in PublicIntegrationsController, both handling HTTP requests for webhook management.
  • Internal plugs #500: Added a new method in IntegrationsController for internal plug handling; closely related to the webhook management changes introduced here.

Poem

I'm hopping through lines of code so bright,
Adding webhooks to guide our flight.
With controllers and services, I bound with glee,
Managing data like clover in a field, you see.
From API to UI, I hop in delight,
Coding magic in the moonlit night.
🐇✨ Happy hops to changes done right!

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 16dd349 and fc11d8c.

📒 Files selected for processing (21)
  • apps/backend/src/api/api.module.ts (2 hunks)
  • apps/backend/src/api/routes/webhooks.controller.ts (1 hunks)
  • apps/backend/src/services/auth/permissions/permissions.service.ts (4 hunks)
  • apps/backend/src/services/auth/permissions/subscription.exception.ts (3 hunks)
  • apps/frontend/src/app/(site)/settings/page.tsx (2 hunks)
  • apps/frontend/src/components/launches/menu/menu.tsx (0 hunks)
  • apps/frontend/src/components/layout/impersonate.tsx (1 hunks)
  • apps/frontend/src/components/layout/settings.component.tsx (5 hunks)
  • apps/frontend/src/components/layout/top.menu.tsx (3 hunks)
  • apps/frontend/src/components/public-api/public.component.tsx (1 hunks)
  • apps/frontend/src/components/settings/teams.component.tsx (2 hunks)
  • apps/frontend/src/components/webhooks/webhooks.tsx (1 hunks)
  • apps/workers/src/app/posts.controller.ts (2 hunks)
  • libraries/nestjs-libraries/src/database/prisma/database.module.ts (2 hunks)
  • libraries/nestjs-libraries/src/database/prisma/posts/posts.repository.ts (1 hunks)
  • libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts (3 hunks)
  • libraries/nestjs-libraries/src/database/prisma/schema.prisma (3 hunks)
  • libraries/nestjs-libraries/src/database/prisma/subscriptions/pricing.ts (6 hunks)
  • libraries/nestjs-libraries/src/database/prisma/webhooks/webhooks.repository.ts (1 hunks)
  • libraries/nestjs-libraries/src/database/prisma/webhooks/webhooks.service.ts (1 hunks)
  • libraries/nestjs-libraries/src/dtos/webhooks/webhooks.dto.ts (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@nevo-david nevo-david merged commit d574486 into main Feb 6, 2025
6 of 9 checks passed
@@ -0,0 +1,245 @@
import React, { FC, Fragment, useCallback, useMemo, useState } from 'react';

Check warning

Code scanning / ESLint

Disallow unused variables Warning

'useMemo' is defined but never used.

const list = useCallback(async () => {
return (await fetch('/webhooks')).json();
}, []);

Check warning

Code scanning / ESLint

verifies the list of dependencies for Hooks like useEffect and similar Warning

React Hook useCallback has a missing dependency: 'fetch'. Either include it or remove the dependency array.
children: <AddOrEditWebhook data={data} reload={mutate} />,
});
},
[]

Check warning

Code scanning / ESLint

verifies the list of dependencies for Hooks like useEffect and similar Warning

React Hook useCallback has missing dependencies: 'modal' and 'mutate'. Either include them or remove the dependency array.
toaster.show('Webhook deleted successfully', 'success');
}
},
[]

Check warning

Code scanning / ESLint

verifies the list of dependencies for Hooks like useEffect and similar Warning

React Hook useCallback has missing dependencies: 'fetch', 'mutate', and 'toaster'. Either include them or remove the dependency array.

const integration = useCallback(async () => {
return (await fetch('/integrations/list')).json();
}, []);

Check warning

Code scanning / ESLint

verifies the list of dependencies for Hooks like useEffect and similar Warning

React Hook useCallback has a missing dependency: 'fetch'. Either include it or remove the dependency array.
Comment on lines +142 to +144
const findValue = options.find(
(option) => option.value === e.target.value
)!;

Check warning

Code scanning / ESLint

Disallow non-null assertions using the `!` postfix operator Warning

Forbidden non-null assertion.
form.setValue('integrations', []);
}
},
[]

Check warning

Code scanning / ESLint

verifies the list of dependencies for Hooks like useEffect and similar Warning

React Hook useCallback has a missing dependency: 'form'. Either include it or remove the dependency array.
modal.closeAll();
reload();
},
[data, integrations]

Check warning

Code scanning / ESLint

verifies the list of dependencies for Hooks like useEffect and similar Warning

React Hook useCallback has missing dependencies: 'fetch', 'modal', 'reload', and 'toast'. Either include them or remove the dependency array.
@egelhaus
Copy link
Collaborator

egelhaus commented Feb 6, 2025

Really nice work!

@egelhaus egelhaus deleted the feat/webhook branch March 10, 2025 12:17
arampersand pushed a commit to arampersand/flowsupply that referenced this pull request Jun 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants